--- /dev/null
+<?xml version='1.0'?>
+<?eclipse-cdt version="2.0"?>
+<cdtproject/>
\ No newline at end of file
--- /dev/null
+<?xml version='1.0'?>
+<launchConfiguration type='org.eclipse.ui.externaltools.ProgramBuilderLaunchConfigurationType'><stringAttribute key='org.eclipse.debug.core.ATTR_REFRESH_SCOPE' value='${working_set:<?xml version="1.0" encoding="UTF-8"?> <launchConfigurationWorkingSet factoryID="org.eclipse.ui.internal.WorkingSetFactory" name="working set" editPageId="org.eclipse.ui.resourceWorkingSetPage"> <item factoryID="org.eclipse.ui.internal.model.ResourceFactory" path="/classpath/native" type="2"/> </launchConfigurationWorkingSet>}'/><stringAttribute key='org.eclipse.ui.externaltools.ATTR_RUN_BUILD_KINDS' value='full,incremental,'/><stringAttribute key='org.eclipse.ui.externaltools.ATTR_BUILD_SCOPE' value='${working_set:<?xml version="1.0" encoding="UTF-8"?> <launchConfigurationWorkingSet factoryID="org.eclipse.ui.internal.WorkingSetFactory" name="workingSet" editPageId="org.eclipse.ui.resourceWorkingSetPage"> <item factoryID="org.eclipse.ui.internal.model.ResourceFactory" path="/classpath/native" type="2"/> </launchConfigurationWorkingSet>}'/><stringAttribute key='org.eclipse.ui.externaltools.ATTR_LOCATION' value='${system_path:make}'/><booleanAttribute key='org.eclipse.ui.externaltools.ATTR_TRIGGERS_CONFIGURED' value='true'/><stringAttribute key='org.eclipse.ui.externaltools.ATTR_WORKING_DIRECTORY' value='${build_project}'/><stringAttribute key='org.eclipse.ui.externaltools.ATTR_TOOL_ARGUMENTS' value='-C ${build_project}/native all install'/><booleanAttribute key='org.eclipse.debug.ui.ATTR_LAUNCH_IN_BACKGROUND' value='false'/><booleanAttribute key='org.eclipse.debug.core.appendEnvironmentVariables' value='true'/></launchConfiguration>
\ No newline at end of file
--- /dev/null
+<?xml version='1.0'?>
+<launchConfiguration type='org.eclipse.ui.externaltools.ProgramBuilderLaunchConfigurationType'><stringAttribute key='org.eclipse.debug.core.ATTR_REFRESH_SCOPE' value='${working_set:<?xml version="1.0" encoding="UTF-8"?> <launchConfigurationWorkingSet factoryID="org.eclipse.ui.internal.WorkingSetFactory" name="working set" editPageId="org.eclipse.ui.resourceWorkingSetPage"> <item factoryID="org.eclipse.ui.internal.model.ResourceFactory" path="/classpath/java/util" type="2"/> </launchConfigurationWorkingSet>}'/><stringAttribute key='org.eclipse.ui.externaltools.ATTR_RUN_BUILD_KINDS' value='full,incremental,'/><stringAttribute key='org.eclipse.ui.externaltools.ATTR_LOCATION' value='${system_path:make}'/><booleanAttribute key='org.eclipse.ui.externaltools.ATTR_TRIGGERS_CONFIGURED' value='true'/><stringAttribute key='org.eclipse.ui.externaltools.ATTR_WORKING_DIRECTORY' value='${build_project}'/><stringAttribute key='org.eclipse.ui.externaltools.ATTR_TOOL_ARGUMENTS' value='-C ${build_project}/lib ../java/util/LocaleData.java'/><booleanAttribute key='org.eclipse.debug.ui.ATTR_LAUNCH_IN_BACKGROUND' value='false'/><booleanAttribute key='org.eclipse.debug.core.appendEnvironmentVariables' value='true'/></launchConfiguration>
\ No newline at end of file
--- /dev/null
+#include "include/layout.wml"
+
+<subject "GNU Classpath Bug Reports">
+
+<box>
+
+<boxtitle>GNU Classpath::Bugs</boxtitle>
+<boxitem>
+Unfortunately GNU Classpath is not bug free yet.
+<br>
+But you can help!
+<br>
+If you find a bug please report it here.
+</boxitem>
+
+<boxtitle>Query</boxtitle>
+<boxitem>
+Please first check the following lists:
+<ul>
+<li><a href="http://gcc.gnu.org/bugzilla/query.cgi?product=classpath">Query bugs</a></li>
+<li><a href="http://gcc.gnu.org/bugzilla/buglist.cgi?product=classpath&bug_status=UNCONFIRMED&bug_status=NEW&bug_status=ASSIGNED&bug_status=SUSPENDED&bug_status=WAITING&bug_status=REOPENED">All open bugs</a></li>
+<li><a href="http://gcc.gnu.org/bugzilla/duplicates.cgi?sortby=count&product=classpath">Most Frequently Reported Bugs</a></li>
+</ul>
+<p>
+</boxitem>
+
+<boxtitle>Report</boxtitle>
+<boxitem>
+If your bug wasn't in any of the above lists, please
+<ul>
+<li><a href="http://gcc.gnu.org/bugzilla/enter_bug.cgi?product=classpath">Report it</a></li>
+<ul>
+<p>
+</boxitem>
+
+<boxtitle>Overview</boxtitle>
+<boxitem>
+You can also look at some pretty
+<ul>
+<li><a href="http://gcc.gnu.org/bugzilla/reports.cgi?product=classpath&datasets=NEW%3A&datasets=ASSIGNED%3A&datasets=REOPENED%3A&datasets=UNCONFIRMED%3A&datasets=RESOLVED%3A&datasets=VERIFIED%3A&datasets=CLOSED%3A&datasets=FIXED%3A&datasets=INVALID%3A&datasets=WONTFIX%3A&datasets=DUPLICATE%3A&datasets=WORKSFORME%3A">Status Counts</a></li>
+<li><a href="http://gcc.gnu.org/bugzilla/report.cgi?bug_file_loc_type=allwordssubstr&bug_status=UNCONFIRMED&bug_status=NEW&bug_status=ASSIGNED&bug_status=SUSPENDED&bug_status=WAITING&bug_status=REOPENED&bug_status=RESOLVED&bug_status=VERIFIED&bug_status=CLOSED&cumulate=1&gccbuild_type=allwordssubstr&gcchost_type=allwordssubstr&gcctarget_type=allwordssubstr&keywords_type=allwords&known_to_fail_type=allwordssubstr&known_to_work_type=allwordssubstr&long_desc_type=substring&product=classpath&short_desc_type=allwordssubstr&x_axis_field=component&y_axis_field=bug_status&width=600&height=350&action=wrap&format=table">Component/Status Tables</a></li>
+</ul>
+<p>
+</boxitem>
+
+</box>
--- /dev/null
+# @configure_input@
+
+prefix = @prefix@
+exec_prefix = @exec_prefix@
+includedir = @includedir@
+libdir = @libdir@
+pkglibdir = $(libdir)/@PACKAGE@
+
+all: gnu/classpath/examples/jawt/DemoJAWT.class libDemoJAWT.so
+ @echo "RUN with:"
+ @echo " LD_LIBRARY_PATH=$$LD_LIBRARY_PATH:.:$(pkglibdir) jamvm \\"
+ @echo " gnu.classpath.examples.jawt.DemoJAWT"
+
+gnu/classpath/examples/jawt/DemoJAWT.class: gnu/classpath/examples/jawt/DemoJAWT.java
+ gcj -C gnu/classpath/examples/jawt/DemoJAWT.java
+
+DemoJAWT.h: gnu/classpath/examples/jawt/DemoJAWT.class
+ gcjh -jni gnu.classpath.examples.jawt.DemoJAWT -o DemoJAWT.h
+
+libDemoJAWT.so: gnu/classpath/examples/jawt/DemoJAWT.c DemoJAWT.h
+ gcc -g -O0 -Wall -I. -I/usr/X11R6/include -L. -L/usr/X11R6/lib \
+ -I$(includedir) -L$(pkglibdir) \
+ -lX11 -ljawtgnu -shared -o libDemoJAWT.so \
+ gnu/classpath/examples/jawt/DemoJAWT.c
+
+clean:
+ rm -f DemoJAWT.h
+ rm -f gnu/classpath/examples/jawt/DemoJAWT*.class
+ rm -f libDemoJAWT.so
--- /dev/null
+/* Demo.java -- And example of copy/paste datatransfer
+ Copyright (C) 2005 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath examples.
+
+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., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA. */
+
+package gnu.classpath.examples.datatransfer;
+
+import java.awt.*;
+import java.awt.event.*;
+import java.awt.datatransfer.*;
+
+import java.io.*;
+import java.net.URL;
+import java.util.Arrays;
+import java.util.Iterator;
+import java.util.Random;
+
+/**
+ * An example how datatransfer works for copying and pasting data to
+ * and from other programs.
+ */
+class Demo
+ extends Frame
+ implements ActionListener, ItemListener, FlavorListener
+{
+ public static void main(String args[])
+ {
+ new Demo();
+ }
+
+ private TextArea text;
+ private Button copyText;
+ private Button pasteText;
+
+ private ImageComponent image;
+ private Button copyImage;
+ private Button pasteImage;
+
+ private ObjectComponent object;
+ private Button copyObject;
+ private Button pasteObject;
+
+ private FilesComponent files;
+ private Button copyFiles;
+ private Button pasteFiles;
+
+ private FlavorsComponent flavors;
+ private FlavorDetailsComponent details;
+
+ private Demo()
+ {
+ super("GNU Classpath datatransfer");
+
+ /* Add all the different panel to the main window in one row. */
+ setLayout(new GridLayout(5, 1, 10, 10));
+ add(createTextPanel());
+ add(createImagePanel());
+ add(createObjectPanel());
+ add(createFilesPanel());
+ add(createFlavorsPanel());
+
+ /* Add listeners for the various buttons and events we are
+ interested in. */
+ addWindowListener(new WindowAdapter ()
+ {
+ public void windowClosing (WindowEvent e)
+ {
+ dispose();
+ }
+ });
+ flavors.addItemListener(this);
+ Toolkit t = Toolkit.getDefaultToolkit();
+ Clipboard c = t.getSystemClipboard();
+ c.addFlavorListener(this);
+
+ /* Show time! */
+ pack();
+ show();
+ }
+
+ /**
+ * The Text Panel will show simple text that can be copied and pasted.
+ */
+ private Panel createTextPanel()
+ {
+ Panel textPanel = new Panel();
+ textPanel.setLayout(new BorderLayout());
+ text = new TextArea("GNU Everywhere!",
+ 2, 80,
+ TextArea.SCROLLBARS_VERTICAL_ONLY);
+ text.setEditable(false);
+ text.setEnabled(true);
+ Panel textButtons = new Panel();
+ textButtons.setLayout(new FlowLayout());
+ copyText = new Button("Copy text");
+ copyText.addActionListener(this);
+ pasteText = new Button("Paste text");
+ pasteText.addActionListener(this);
+ textButtons.add(copyText);
+ textButtons.add(pasteText);
+ textPanel.add(text, BorderLayout.CENTER);
+ textPanel.add(textButtons, BorderLayout.SOUTH);
+ return textPanel;
+ }
+
+ /**
+ * The Image Panel shows an image that can be copied to another
+ * program or be replaced by pasting in an image from another
+ * application.
+ */
+ private Panel createImagePanel()
+ {
+ Panel imagePanel = new Panel();
+ imagePanel.setLayout(new BorderLayout());
+ URL imageurl = this.getClass()
+ .getResource("/gnu/classpath/examples/icons/big-fullscreen.png");
+ Image img = Toolkit.getDefaultToolkit().createImage(imageurl);
+ image = new ImageComponent(img);
+ Panel imageButtons = new Panel();
+ copyImage = new Button("Copy image");
+ copyImage.addActionListener(this);
+ pasteImage = new Button("Paste image");
+ pasteImage.addActionListener(this);
+ imageButtons.add(copyImage);
+ imageButtons.add(pasteImage);
+ imagePanel.add(image, BorderLayout.CENTER);
+ imagePanel.add(imageButtons, BorderLayout.SOUTH);
+ return imagePanel;
+ }
+
+ /**
+ * The Object Panel holds a simple (Point) object that can be copied
+ * and pasted to another program that supports exchanging serialized
+ * objects.
+ */
+ private Panel createObjectPanel()
+ {
+ Panel objectPanel = new Panel();
+ objectPanel.setLayout(new BorderLayout());
+ Random random = new Random();
+ int x = (byte) random.nextInt();
+ int y = (byte) random.nextInt();
+ object = new ObjectComponent(new Point(x, y));
+ Panel objectButtons = new Panel();
+ copyObject = new Button("Copy object");
+ copyObject.addActionListener(this);
+ pasteObject = new Button("Paste object");
+ pasteObject.addActionListener(this);
+ objectButtons.add(copyObject);
+ objectButtons.add(pasteObject);
+ objectPanel.add(object, BorderLayout.CENTER);
+ objectPanel.add(objectButtons, BorderLayout.SOUTH);
+ return objectPanel;
+ }
+
+ /**
+ * The Files Panel shows the files from the current working
+ * directory. They can be copied and pasted between other
+ * applications that support the exchange of file lists.
+ */
+ private Panel createFilesPanel()
+ {
+ Panel filesPanel = new Panel();
+ filesPanel.setLayout(new BorderLayout());
+ files = new FilesComponent(new File(".").listFiles());
+ Panel filesButtons = new Panel();
+ copyFiles = new Button("Copy files");
+ copyFiles.addActionListener(this);
+ pasteFiles = new Button("Paste files");
+ pasteFiles.addActionListener(this);
+ filesButtons.add(copyFiles);
+ filesButtons.add(pasteFiles);
+ filesPanel.add(files, BorderLayout.CENTER);
+ filesPanel.add(filesButtons, BorderLayout.SOUTH);
+ return filesPanel;
+ }
+
+ /**
+ * The Flavors Panel shows the different formats (mime-types) that
+ * data on the clipboard is available in. By clicking on a flavor
+ * details about the representation class and object is given.
+ */
+ private Panel createFlavorsPanel()
+ {
+ Panel flavorsPanel = new Panel();
+ flavorsPanel.setLayout(new BorderLayout());
+ Label flavorsHeader = new Label("Flavors on clipboard:");
+ Toolkit t = Toolkit.getDefaultToolkit();
+ Clipboard c = t.getSystemClipboard();
+ DataFlavor[] dataflavors = c.getAvailableDataFlavors();
+ flavors = new FlavorsComponent(dataflavors);
+ details = new FlavorDetailsComponent(null);
+ flavorsPanel.add(flavorsHeader, BorderLayout.NORTH);
+ flavorsPanel.add(flavors, BorderLayout.CENTER);
+ flavorsPanel.add(details, BorderLayout.SOUTH);
+ return flavorsPanel;
+ }
+
+ /**
+ * FlavorListener implementation that updates the Flavors Panel
+ * whenever a change in the mime-types available has been detected.
+ */
+ public void flavorsChanged(FlavorEvent event)
+ {
+ Toolkit t = Toolkit.getDefaultToolkit();
+ Clipboard c = t.getSystemClipboard();
+ DataFlavor[] dataflavors = c.getAvailableDataFlavors();
+ flavors.setFlavors(dataflavors);
+ details.setDataFlavor(null);
+ }
+
+ /**
+ * ItemChangeListener implementation that updates the flavor details
+ * whenever the user selects a different representation of the data
+ * available on the clipboard.
+ */
+ public void itemStateChanged(ItemEvent evt)
+ {
+ DataFlavor df = null;
+ String s = flavors.getSelectedItem();
+ if (s != null)
+ {
+ try
+ {
+ df = new DataFlavor(s);
+ }
+ catch (ClassNotFoundException cnfe)
+ {
+ cnfe.printStackTrace();
+ }
+ }
+ details.setDataFlavor(df);
+ }
+
+ /**
+ * ActionListener implementations that will copy or past data
+ * to/from the clipboard when the user requests that for the text,
+ * image, object of file component.
+ */
+ public void actionPerformed (ActionEvent evt)
+ {
+ Button b = (Button) evt.getSource();
+ Toolkit t = Toolkit.getDefaultToolkit();
+ Clipboard c = t.getSystemClipboard();
+ if (b == copyText)
+ c.setContents(new StringSelection(text.getText()), null);
+
+ if (b == pasteText)
+ {
+ String s = null;
+ try
+ {
+ s = (String) c.getData(DataFlavor.stringFlavor);
+ }
+ catch (UnsupportedFlavorException dfnse)
+ {
+ }
+ catch (IOException ioe)
+ {
+ }
+ catch (ClassCastException cce)
+ {
+ }
+ if (s == null)
+ t.beep();
+ else
+ text.setText(s);
+ }
+
+ if (b == copyImage)
+ c.setContents(new ImageSelection(image.getImage()), null);
+
+ if (b == pasteImage)
+ {
+ Image i = null;
+ try
+ {
+ i = (Image) c.getData(DataFlavor.imageFlavor);
+ }
+ catch (UnsupportedFlavorException dfnse)
+ {
+ }
+ catch (IOException ioe)
+ {
+ }
+ catch (ClassCastException cce)
+ {
+ }
+ if (i == null)
+ t.beep();
+ else
+ image.setImage(i);
+ }
+
+ if (b == copyObject)
+ c.setContents(new ObjectSelection(object.getObject()), null);
+
+ if (b == pasteObject)
+ {
+ Serializable o = null;
+ try
+ {
+ o = (Serializable) c.getData(ObjectSelection.objFlavor);
+ }
+ catch (UnsupportedFlavorException dfnse)
+ {
+ }
+ catch (IOException ioe)
+ {
+ }
+ catch (ClassCastException cce)
+ {
+ }
+ if (o == null)
+ t.beep();
+ else
+ object.setObject(o);
+ }
+
+ if (b == copyFiles)
+ c.setContents(new FilesSelection(files.getFiles()), null);
+
+ if (b == pasteFiles)
+ {
+ java.util.List fs = null;
+ try
+ {
+ fs = (java.util.List) c.getData(DataFlavor.javaFileListFlavor);
+ }
+ catch (UnsupportedFlavorException dfnse)
+ {
+ }
+ catch (IOException ioe)
+ {
+ }
+ catch (ClassCastException cce)
+ {
+ }
+ if (fs == null)
+ t.beep();
+ else
+ files.setFiles(fs);
+ }
+ }
+
+ /**
+ * Simple awt component that shows an settable image.
+ */
+ static class ImageComponent extends Component
+ {
+ private Image image;
+
+ ImageComponent(Image image)
+ {
+ setSize(20, 20);
+ setImage(image);
+ }
+
+ Image getImage()
+ {
+ return image;
+ }
+
+ void setImage(Image image)
+ {
+ this.image = image;
+ repaint();
+ }
+
+ public void paint(Graphics g)
+ {
+ g.drawImage(image, 0, 0, getWidth(), getHeight(), this);
+ }
+ }
+
+ /**
+ * Simple awt component that shows a settable Serializable object.
+ */
+ static class ObjectComponent extends TextArea
+ {
+ private Serializable object;
+
+ ObjectComponent(Serializable object)
+ {
+ super("", 2, 80, TextArea.SCROLLBARS_NONE);
+ setEditable(false);
+ setEnabled(false);
+ setObject(object);
+ }
+
+ Serializable getObject()
+ {
+ return object;
+ }
+
+ void setObject(Serializable object)
+ {
+ this.object = object;
+ setText("Class: " + object.getClass().getName()
+ + "\n"
+ + "toString(): " + object.toString());
+ repaint();
+ }
+ }
+
+ /**
+ * Simple awt component that shows a settable list of Files.
+ */
+ static class FilesComponent extends List
+ {
+ private File[] files;
+
+ FilesComponent(File[] files)
+ {
+ super(4, true);
+ setFiles(files);
+ }
+
+ File[] getFiles()
+ {
+ String[] strings = getSelectedItems();
+ if (strings == null || strings.length == 0)
+ return (File[]) files.clone();
+
+ File[] fs = new File[strings.length];
+ for (int i = 0; i < strings.length; i++)
+ fs[i] = new File(strings[i]);
+ return fs;
+ }
+
+ void setFiles(File[] files)
+ {
+ this.files = files;
+ removeAll();
+ for (int i = 0; i < files.length; i++)
+ {
+ addItem(files[i].toString());
+ select(i);
+ }
+ }
+
+ void setFiles(java.util.List list)
+ {
+ File[] fs = new File[list.size()];
+ int i = 0;
+ Iterator it = list.iterator();
+ while (it.hasNext())
+ fs[i++] = (File) it.next();
+
+ setFiles(fs);
+ }
+ }
+
+ /**
+ * Simple awt component that shows a settable list of DataFlavors.
+ */
+ static class FlavorsComponent extends List
+ {
+ FlavorsComponent(DataFlavor[] flavors)
+ {
+ super(4);
+ setFlavors(flavors);
+ }
+
+ void setFlavors(DataFlavor[] flavors)
+ {
+ removeAll();
+ for (int i = 0; i < flavors.length; i++)
+ {
+ addItem(flavors[i].getMimeType());
+ }
+ }
+ }
+
+ /**
+ * Simple awt component that shows the details for and an object as
+ * found on the system clipboard as represented by a given
+ * DataFlavor.
+ */
+ static class FlavorDetailsComponent extends TextArea
+ {
+ private DataFlavor df;
+
+ FlavorDetailsComponent(DataFlavor df)
+ {
+ super("", 2, 80, TextArea.SCROLLBARS_NONE);
+ setEditable(false);
+ setEnabled(false);
+ setDataFlavor(df);
+ }
+
+ void setDataFlavor(DataFlavor df)
+ {
+ if (df == this.df
+ || (df != null && df.equals(this.df)))
+ return;
+
+ this.df = df;
+
+ if (df == null)
+ setText("No flavor selected");
+ else
+ {
+ Object o = null;
+ Throwable exception = null;
+ try
+ {
+ Toolkit t = Toolkit.getDefaultToolkit();
+ Clipboard c = t.getSystemClipboard();
+ o = c.getData(df);
+ }
+ catch (Throwable t)
+ {
+ exception = t;
+ }
+ if (o != null)
+ {
+ setText("Data: " + o.getClass().getName()
+ + "\n"
+ + o);
+ }
+ else
+ {
+ setText("Error retrieving: " + df
+ + "\n"
+ + exception != null ? exception.toString() : "");
+ }
+ }
+ repaint();
+ }
+ }
+
+ /**
+ * Helper class to put an Image on a clipboard as
+ * DataFlavor.imageFlavor.
+ */
+ static class ImageSelection implements Transferable
+ {
+ private final Image img;
+
+ ImageSelection(Image img)
+ {
+ this.img = img;
+ }
+
+ static DataFlavor[] flavors = new DataFlavor[] { DataFlavor.imageFlavor };
+ public DataFlavor[] getTransferDataFlavors()
+ {
+ return (DataFlavor[]) flavors.clone();
+ }
+
+ public boolean isDataFlavorSupported(DataFlavor flavor)
+ {
+ return flavor.equals(DataFlavor.imageFlavor);
+ }
+
+ public Object getTransferData(DataFlavor flavor)
+ throws UnsupportedFlavorException
+ {
+ if (!isDataFlavorSupported(flavor))
+ throw new UnsupportedFlavorException(flavor);
+
+ return img;
+ }
+ }
+
+ /**
+ * Helper class to put an Object on a clipboard as Serializable
+ * object.
+ */
+ static class ObjectSelection implements Transferable
+ {
+ private final Serializable obj;
+
+ ObjectSelection(Serializable obj)
+ {
+ this.obj = obj;
+ }
+
+ static DataFlavor objFlavor = new DataFlavor(Serializable.class,
+ "Serialized Object");
+ static DataFlavor[] flavors = new DataFlavor[] { objFlavor };
+ public DataFlavor[] getTransferDataFlavors()
+ {
+ return (DataFlavor[]) flavors.clone();
+ }
+
+ public boolean isDataFlavorSupported(DataFlavor flavor)
+ {
+ return flavor.equals(objFlavor);
+ }
+
+ public Object getTransferData(DataFlavor flavor)
+ throws UnsupportedFlavorException
+ {
+ if (!isDataFlavorSupported(flavor))
+ throw new UnsupportedFlavorException(flavor);
+
+ return obj;
+ }
+ }
+
+ /**
+ * Helper class to put a List of Files on the clipboard as
+ * DataFlavor.javaFileListFlavor.
+ */
+ static class FilesSelection implements Transferable
+ {
+ private final File[] files;
+
+ FilesSelection(File[] files)
+ {
+ this.files = files;
+ }
+
+ static DataFlavor[] flavors = new DataFlavor[]
+ { DataFlavor.javaFileListFlavor };
+ public DataFlavor[] getTransferDataFlavors()
+ {
+ return (DataFlavor[]) flavors.clone();
+ }
+
+ public boolean isDataFlavorSupported(DataFlavor flavor)
+ {
+ return flavor.equals(DataFlavor.javaFileListFlavor);
+ }
+
+ public Object getTransferData(DataFlavor flavor)
+ throws UnsupportedFlavorException
+ {
+ if (!isDataFlavorSupported(flavor))
+ throw new UnsupportedFlavorException(flavor);
+
+ return Arrays.asList(files);
+ }
+ }
+}
--- /dev/null
+/* DemoJAWT.c -- native portion of AWT Native Interface demo
+ Copyright (C) 2005 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath examples.
+
+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., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA. */
+
+#include "DemoJAWT.h"
+#include "jawt_md.h"
+#include <string.h>
+
+JNIEXPORT void JNICALL
+Java_gnu_classpath_examples_jawt_DemoJAWT_paintIt (JNIEnv* env,
+ jobject canvas,
+ jobject graphics,
+ jboolean on)
+{
+ JAWT awt;
+ JAWT_DrawingSurface* surface;
+ JAWT_DrawingSurfaceInfo* surface_info;
+ JAWT_X11DrawingSurfaceInfo* surface_info_x11;
+ jint lock;
+ GC gc;
+ int c;
+ char* test_string = "JAWT";
+ XColor orange;
+ XColor yellow;
+ XColor blue;
+ Display* display;
+ Drawable drawable;
+ Status status;
+
+ awt.version = JAWT_VERSION_1_3;
+ if (JAWT_GetAWT (env, &awt) == JNI_FALSE)
+ {
+ printf ("couldn't find AWT\n");
+ return;
+ }
+
+ surface = awt.GetDrawingSurface (env, canvas);
+ if (surface == NULL)
+ {
+ printf ("drawing surface is NULL\n");
+ return;
+ }
+
+ lock = surface->Lock (surface);
+ if ((lock & JAWT_LOCK_ERROR) != 0)
+ {
+ printf ("couldn't lock drawing surface\n");
+ awt.FreeDrawingSurface (surface);
+ return;
+ }
+
+ surface_info = surface->GetDrawingSurfaceInfo (surface);
+ if (surface_info == NULL)
+ {
+ printf ("couldn't get surface information\n");
+ surface->Unlock (surface);
+ awt.FreeDrawingSurface (surface);
+ return;
+ }
+
+ surface_info_x11 = (JAWT_X11DrawingSurfaceInfo*) surface_info->platformInfo;
+
+ display = surface_info_x11->display;
+ drawable = surface_info_x11->drawable;
+
+ gc = XCreateGC (display, drawable, 0, 0);
+ XSetBackground (display, gc, 0);
+
+ orange.red = 254 * 65535 / 255;
+ orange.green = 90 * 65535 / 255;
+ orange.blue = 16 * 65535 / 255;
+
+ /* assume color lookups succeed */
+ status = XAllocColor (display, DefaultColormap (display,
+ DefaultScreen (display)),
+ &orange);
+
+ if (!status)
+ {
+ printf ("color allocation failed\n");
+ goto cleanup;
+ }
+
+ yellow.red = 255 * 65535 / 255;
+ yellow.green = 255 * 65535 / 255;
+ yellow.blue = 0 * 65535 / 255;
+
+ XAllocColor (display, DefaultColormap (display,
+ DefaultScreen (display)),
+ &yellow);
+
+ if (!status)
+ {
+ printf ("color allocation failed\n");
+ goto cleanup;
+ }
+
+ blue.red = 16 * 65535 / 255;
+ blue.green = 30 * 65535 / 255;
+ blue.blue = 137 * 65535 / 255;
+
+ XAllocColor (display, DefaultColormap (display,
+ DefaultScreen (display)),
+ &blue);
+
+ if (!status)
+ {
+ printf ("color allocation failed\n");
+ goto cleanup;
+ }
+
+ for (c = 5; c >= 0; c--)
+ {
+ if (c % 2 == on)
+ XSetForeground (display, gc, yellow.pixel);
+ else
+ XSetForeground (display, gc, orange.pixel);
+
+ XFillArc (display, drawable, gc, 140 - c * 15, 140 - c * 15, c * 30, c * 30, 0, 360 * 64);
+ }
+
+ XSetForeground (display, gc, blue.pixel);
+ XDrawString (display, drawable,
+ gc, 129, 145, test_string, strlen (test_string));
+
+ cleanup:
+ XFreeGC (display, gc);
+
+ surface->FreeDrawingSurfaceInfo (surface_info);
+
+ surface->Unlock (surface);
+
+ awt.FreeDrawingSurface (surface);
+}
--- /dev/null
+/* DemoJAWT.java -- AWT Native Interface demo
+ Copyright (C) 2005 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath examples.
+
+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., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA. */
+
+package gnu.classpath.examples.jawt;
+
+import java.awt.*;
+import java.awt.event.*;
+
+public class DemoJAWT extends Canvas
+{
+ static
+ {
+ System.loadLibrary ("DemoJAWT");
+ }
+
+ public native void paintIt (Graphics g, boolean on);
+
+ public void paint (Graphics g)
+ {
+ paintIt (g, on);
+ }
+
+ private boolean on;
+
+ public static void main (String[] args)
+ {
+ Frame f = new Frame ("GNU Classpath JAWT Demo");
+
+ f.setBounds (0, 0, 300, 300);
+
+ f.setResizable (false);
+
+ DemoJAWT jawtDemo = new DemoJAWT ();
+ f.add (jawtDemo);
+
+ f.addWindowListener (new WindowAdapter ()
+ {
+ public void windowClosing (WindowEvent evt)
+ {
+ System.exit (0);
+ }
+ });
+
+ f.show ();
+
+ while (true)
+ {
+ try
+ {
+ Thread.sleep (500);
+ }
+ catch (InterruptedException ie)
+ {
+ // ignored
+ }
+ jawtDemo.on = ! jawtDemo.on;
+ f.repaint();
+ }
+ }
+}
--- /dev/null
+/* noHeaderInput.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., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 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 org.omg.CORBA.CustomMarshal;
+import org.omg.CORBA.DataInputStream;
+import org.omg.CORBA.MARSHAL;
+import org.omg.CORBA.portable.BoxedValueHelper;
+import org.omg.CORBA.portable.Streamable;
+import org.omg.CORBA.portable.ValueFactory;
+
+import java.io.Serializable;
+
+/**
+ * Substitutes the main stream in factories when the header is already
+ * behind. Overrides methods that may be invoked from the factory,
+ * forcing not to read the header if called first time on this stream.
+ *
+ * This stream reverts to default behavior if one or more call are
+ * made (reading value types that are nested fields of the value type).
+ *
+ * @author Audrius Meskauskas, Lithuania (AudriusA@Bioinformatics.org)
+ */
+class noHeaderInput
+ extends cdrBufInput
+ implements DataInputStream
+{
+ /**
+ * If true, this is not the first call.
+ */
+ boolean notFirst;
+
+ /**
+ * Create an instance, reading from the given buffer.
+ */
+ public noHeaderInput(byte[] buffer)
+ {
+ super(buffer);
+ }
+
+ /**
+ * Read when knowning the class instance.
+ */
+ public Serializable read_value(Class clz)
+ {
+ if (notFirst)
+ return super.read_value(clz);
+ else
+ {
+ try
+ {
+ notFirst = true;
+ return read_value((Serializable) clz.newInstance());
+ }
+ catch (Exception ex)
+ {
+ MARSHAL m = new MARSHAL("Unable to create an instance");
+ m.initCause(ex);
+ throw m;
+ }
+ }
+ }
+
+ /**
+ * Tries to read using boxed value helper.
+ */
+ public Serializable read_value(BoxedValueHelper helper)
+ {
+ if (notFirst)
+ return super.read_value(helper);
+ else
+ {
+ notFirst = true;
+ return helper.read_value(this);
+ }
+ }
+
+ /**
+ * Tries to locate a factory using repository id.
+ */
+ public Serializable read_value(String repository_id)
+ {
+ if (notFirst)
+ return super.read_value(repository_id);
+ else
+ {
+ notFirst = true;
+
+ ValueFactory factory =
+ ((org.omg.CORBA_2_3.ORB) orb()).lookup_value_factory(repository_id);
+ if (factory == null)
+ throw new MARSHAL("No factory");
+ return factory.read_value(this);
+ }
+ }
+
+ /**
+ * Try to read when having an unitialised value.
+ */
+ public Serializable read_value(Serializable value)
+ {
+ if (notFirst)
+ return super.read_value(value);
+ else
+ {
+ notFirst = true;
+
+ // The user-defines io operations are implemented.
+ if (value instanceof CustomMarshal)
+ {
+ CustomMarshal marsh = (CustomMarshal) value;
+ try
+ {
+ marsh.unmarshal((DataInputStream) this);
+ }
+ catch (ClassCastException ex)
+ {
+ Vio.incorrect_plug_in(ex);
+ }
+ }
+ else
+ // The IDL-generated io operations are implemented.
+ if (value instanceof Streamable)
+ {
+ ((Streamable) value)._read(this);
+ }
+ return value;
+ }
+ }
+}
\ No newline at end of file
--- /dev/null
+/* abstractDynAny.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., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 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.DynAn;
+
+import gnu.CORBA.typeNamer;
+
+import org.omg.CORBA.Any;
+import org.omg.CORBA.LocalObject;
+import org.omg.CORBA.ORB;
+import org.omg.CORBA.TypeCode;
+import org.omg.DynamicAny.DynAnyPackage.TypeMismatch;
+
+import java.io.Serializable;
+
+/**
+ * The top of our DynAny implementation, this class provides ORB that is
+ * required to create anys and factory that is required to initialise DynAnys.
+ *
+ * @author Audrius Meskauskas, Lithuania (AudriusA@Bioinformatics.org)
+ */
+public abstract class abstractDynAny
+ extends LocalObject
+ implements Serializable
+{
+ /**
+ * Use serialVersionUID for interoperability.
+ */
+ private static final long serialVersionUID = 1;
+
+ /**
+ * The "initial final_type" that can be an alias of the known final_type.
+ */
+ public TypeCode official_type;
+
+ /**
+ * The "basic" final_type to that the final_type finally evaluates.
+ */
+ public final TypeCode final_type;
+
+ /**
+ * The DynAny factory, required in initializations.
+ */
+ public final gnuDynAnyFactory factory;
+
+ /**
+ * The ORB, to that this DynAny belongs.
+ */
+ public final ORB orb;
+
+ /**
+ * The minor code, indicating the error, related to work with non - GNU
+ * Classpath DynAny.
+ */
+ short MINOR = 8148;
+
+ /**
+ * The message about the empty structure or exception.
+ */
+ static final String EMPTY = "Empty structure with no fields.";
+
+ /**
+ * The message about the structure or exception size mismatch.
+ */
+ static final String SIZE = "Size mismatch.";
+
+ /**
+ * The message about the content of this DynAny being equal to
+ * <code>null</code>
+ */
+ static final String ISNULL = "The content is null";
+
+ /**
+ * The change value listener.
+ */
+ valueChangedListener listener;
+
+ /**
+ * Create the abstract dyn any.
+ */
+ public abstractDynAny(TypeCode oType, TypeCode aType,
+ gnuDynAnyFactory aFactory, ORB anOrb
+ )
+ {
+ official_type = oType;
+ final_type = aType;
+ factory = aFactory;
+ orb = anOrb;
+ }
+
+ /**
+ * Get the typecode.
+ */
+ public TypeCode type()
+ {
+ return official_type;
+ }
+
+ /**
+ * Create the Any.
+ */
+ public Any createAny()
+ {
+ return orb.create_any();
+ }
+
+ /**
+ * The "value changed" listener.
+ */
+ protected void valueChanged()
+ {
+ if (listener != null)
+ listener.changed();
+ }
+
+ /**
+ * Check the type.
+ */
+ void checkType(TypeCode expected, TypeCode actual)
+ throws TypeMismatch
+ {
+ if (!expected.equal(actual))
+ throw new TypeMismatch(typeMismatch(expected, actual));
+ }
+
+ /**
+ * Format "Type mismatch" string.
+ */
+ String typeMismatch(TypeCode expected, TypeCode actual)
+ {
+ return typeNamer.nameIt(expected) + " expected " +
+ typeNamer.nameIt(actual);
+ }
+
+ /**
+ * Format "size mismatch" string.
+ */
+ String sizeMismatch(int here, int other)
+ {
+ return "Size mismatch, " + other + " (expected " + here + ")";
+ }
+}
\ No newline at end of file
--- /dev/null
+/* abstractRecord.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., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 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.DynAn;
+
+import gnu.CORBA.Unexpected;
+import gnu.CORBA.holderFactory;
+
+import org.omg.CORBA.Any;
+import org.omg.CORBA.ORB;
+import org.omg.CORBA.TCKind;
+import org.omg.CORBA.TypeCode;
+import org.omg.CORBA.TypeCodePackage.BadKind;
+import org.omg.CORBA.TypeCodePackage.Bounds;
+import org.omg.CORBA.portable.Streamable;
+import org.omg.DynamicAny.DynAny;
+import org.omg.DynamicAny.DynAnyPackage.InvalidValue;
+import org.omg.DynamicAny.DynAnyPackage.TypeMismatch;
+import org.omg.DynamicAny.DynStruct;
+import org.omg.DynamicAny.DynValueCommonOperations;
+import org.omg.DynamicAny.NameDynAnyPair;
+import org.omg.DynamicAny.NameValuePair;
+
+import java.io.Serializable;
+
+import java.lang.reflect.Field;
+
+/**
+ * A shared base for both dynamic structure an dynamic value final_type.
+ *
+ * @author Audrius Meskauskas, Lithuania (AudriusA@Bioinformatics.org)
+ */
+public abstract class abstractRecord
+ extends anyDivideable
+ implements DynAny, Serializable
+{
+ /**
+ * Use serialVersionUID for interoperability.
+ */
+ private static final long serialVersionUID = 1;
+ String[] fNames;
+
+ /**
+ * Creates the structure with the given typecode.
+ *
+ * @param fields The DynAny's, representing the fields of the structure.
+ */
+ public abstractRecord(TypeCode oType, TypeCode aType,
+ gnuDynAnyFactory aFactory, ORB anOrb
+ )
+ {
+ super(oType, aType, aFactory, anOrb);
+ }
+
+ /** @inheritDoc */
+ public TCKind current_member_kind()
+ throws TypeMismatch, InvalidValue
+ {
+ if (array.length == 0)
+ throw new TypeMismatch(EMPTY);
+ try
+ {
+ return final_type.member_type(pos).kind();
+ }
+ catch (BadKind e)
+ {
+ TypeMismatch t = new TypeMismatch();
+ t.initCause(e);
+ throw t;
+ }
+ catch (Bounds e)
+ {
+ InvalidValue t = new InvalidValue();
+ t.initCause(e);
+ throw t;
+ }
+ }
+
+ /** @inheritDoc */
+ public String current_member_name()
+ throws TypeMismatch, InvalidValue
+ {
+ if (array.length == 0)
+ throw new TypeMismatch(EMPTY);
+ try
+ {
+ return final_type.member_name(pos);
+ }
+ catch (BadKind e)
+ {
+ TypeMismatch t = new TypeMismatch();
+ t.initCause(e);
+ throw t;
+ }
+ catch (Bounds e)
+ {
+ InvalidValue t = new InvalidValue();
+ t.initCause(e);
+ throw t;
+ }
+ }
+
+ /**
+ * Get content of the structure. This method must be defined on a different
+ * name because get_members_as_dyn_any() throws exception only in some of the
+ * supported interfaces.
+ */
+ public NameDynAnyPair[] gnu_get_members_as_dyn_any()
+ {
+ NameDynAnyPair[] r = new NameDynAnyPair[ array.length ];
+ for (int i = 0; i < r.length; i++)
+ {
+ try
+ {
+ r [ i ] = new NameDynAnyPair(fNames [ i ], array [ i ]);
+ }
+ catch (Exception ex)
+ {
+ throw new Unexpected(ex);
+ }
+ }
+ return r;
+ }
+
+ /**
+ * Get content of the structure. This method must be defined on a different
+ * name because get_members_as_dyn_any() throws exception only in some of the
+ * supported interfaces.
+ */
+ public NameValuePair[] gnu_get_members()
+ {
+ NameValuePair[] r = new NameValuePair[ array.length ];
+ for (int i = 0; i < r.length; i++)
+ {
+ try
+ {
+ r [ i ] = new NameValuePair(fNames [ i ], array [ i ].to_any());
+ }
+ catch (Exception ex)
+ {
+ throw new Unexpected(ex);
+ }
+ }
+ return r;
+ }
+
+ /**
+ * Set members from the provided array.
+ */
+ public void set_members_as_dyn_any(NameDynAnyPair[] value)
+ throws TypeMismatch, InvalidValue
+ {
+ if (value.length != array.length)
+ throw new InvalidValue(sizeMismatch(array.length, value.length));
+
+ for (int i = 0; i < value.length; i++)
+ {
+ DynAny dynAny = value [ i ].value;
+ checkType(dynAny.type(), i);
+ checkName(value [ i ].id, i);
+
+ array [ i ] = dynAny;
+ }
+ pos = 0;
+ }
+
+ /**
+ * Check the name at the given position ("" matches everything).
+ */
+ private void checkName(String xName, int i)
+ throws TypeMismatch
+ {
+ if (xName.length() > 0 && fNames [ i ].length() > 0)
+ if (!xName.equals(fNames [ i ]))
+ throw new TypeMismatch("Field name mismatch " + xName + " expected " +
+ fNames [ i ]
+ );
+ }
+
+ /**
+ * Check the type at the given position.
+ */
+ private void checkType(TypeCode t, int i)
+ throws TypeMismatch
+ {
+ if (!array [ i ].type().equal(t))
+ throw new TypeMismatch(typeMismatch(array [ i ].type(), t) + " field " +
+ i
+ );
+ }
+
+ /**
+ * Set members from the provided array.
+ */
+ public void set_members(NameValuePair[] value)
+ throws TypeMismatch, InvalidValue
+ {
+ if (value.length != array.length)
+ throw new InvalidValue(sizeMismatch(array.length, value.length));
+
+ for (int i = 0; i < value.length; i++)
+ {
+ Any any = value [ i ].value;
+ checkType(any.type(), i);
+ checkName(value [ i ].id, i);
+
+ array [ i ].from_any(any);
+ }
+ pos = 0;
+ }
+
+ /** @inheritDoc */
+ public void assign(DynAny from)
+ throws TypeMismatch
+ {
+ checkType(official_type, from.type());
+ if (from instanceof DynStruct)
+ {
+ try
+ {
+ set_members_as_dyn_any(((DynStruct) from).get_members_as_dyn_any());
+ }
+ catch (InvalidValue e)
+ {
+ TypeMismatch t = new TypeMismatch("Invalid value");
+ t.initCause(e);
+ throw t;
+ }
+ }
+ else
+ throw new TypeMismatch("Not a DynStruct");
+ }
+
+ /**
+ * Create a copy.
+ */
+ public DynAny copy()
+ {
+ DynAny[] c = new DynAny[ array.length ];
+ for (int i = 0; i < c.length; i++)
+ {
+ c [ i ] = array [ i ].copy();
+ }
+
+ abstractRecord d = newInstance(official_type, final_type, factory, orb);
+ d.array = c;
+ return d;
+ }
+
+ /**
+ * Create a new instance when copying.
+ */
+ protected abstract abstractRecord newInstance(TypeCode oType, TypeCode aType,
+ gnuDynAnyFactory aFactory,
+ ORB anOrb
+ );
+
+ /**
+ * Done via reflection.
+ */
+ public Any to_any()
+ {
+ try
+ {
+ Streamable sHolder = holderFactory.createHolder(official_type);
+
+ Class sHolderClass = sHolder.getClass();
+ Field sHolderValue = sHolderClass.getField("value");
+ Class sClass = sHolderValue.getType();
+
+ Object structure = sClass.newInstance();
+ Object member;
+ Any am;
+ Field vread;
+ Field vwrite;
+ Streamable memberHolder;
+
+ for (int i = 0; i < array.length; i++)
+ {
+ am = array [ i ].to_any();
+ memberHolder = am.extract_Streamable();
+ vwrite = structure.getClass().getField(final_type.member_name(i));
+ vread = memberHolder.getClass().getField("value");
+ member = vread.get(memberHolder);
+ vwrite.set(structure, member);
+ }
+
+ Any g = createAny();
+ sHolderValue.set(sHolder, structure);
+ g.insert_Streamable(sHolder);
+ g.type(official_type);
+ return g;
+ }
+ catch (Exception e)
+ {
+ throw new Unexpected(e);
+ }
+ }
+
+ /**
+ * Done via reflection.
+ */
+ public void from_any(Any an_any)
+ throws TypeMismatch, InvalidValue
+ {
+ checkType(official_type, an_any.type());
+ try
+ {
+ Streamable s = an_any.extract_Streamable();
+ if (s == null)
+ {
+ if (this instanceof DynValueCommonOperations)
+ {
+ ((DynValueCommonOperations) this).set_to_null();
+ return;
+ }
+ else
+ throw new InvalidValue(ISNULL);
+ }
+
+ Object structure = s.getClass().getField("value").get(s);
+ if (structure == null && (this instanceof DynValueCommonOperations))
+ {
+ ((DynValueCommonOperations) this).set_to_null();
+ return;
+ }
+
+ Any member;
+ Streamable holder;
+ Object field;
+ TypeCode fType;
+ Field fField;
+
+ for (int i = 0; i < array.length; i++)
+ {
+ fField = structure.getClass().getField(fNames [ i ]);
+ field = fField.get(structure);
+ fType = array [ i ].type();
+ holder = holderFactory.createHolder(fType);
+
+ member = createAny();
+ holder.getClass().getField("value").set(holder, field);
+ member.insert_Streamable(holder);
+ member.type(fType);
+
+ array [ i ].from_any(member);
+ }
+
+ if (this instanceof DynValueCommonOperations)
+ ((DynValueCommonOperations) this).set_to_value();
+ }
+ catch (InvalidValue v)
+ {
+ throw v;
+ }
+ catch (NoSuchFieldException ex)
+ {
+ TypeMismatch v =
+ new TypeMismatch("holder value does not match typecode");
+ v.initCause(ex);
+ throw v;
+ }
+ catch (Exception ex)
+ {
+ TypeMismatch t = new TypeMismatch();
+ t.initCause(ex);
+ throw t;
+ }
+ }
+}
\ No newline at end of file
--- /dev/null
+/* anyDivideable.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., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 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.DynAn;
+
+import gnu.CORBA.typeNamer;
+
+import org.omg.CORBA.Any;
+import org.omg.CORBA.CompletionStatus;
+import org.omg.CORBA.ORB;
+import org.omg.CORBA.Object;
+import org.omg.CORBA.TypeCode;
+import org.omg.CORBA.UNKNOWN;
+import org.omg.DynamicAny.DynAny;
+import org.omg.DynamicAny.DynAnyPackage.InvalidValue;
+import org.omg.DynamicAny.DynAnyPackage.TypeMismatch;
+import org.omg.DynamicAny.DynValueCommon;
+
+import java.io.Serializable;
+
+/**
+ * Provides a base for DynAnys, having multiple components.
+ *
+ * @author Audrius Meskauskas, Lithuania (AudriusA@Bioinformatics.org)
+ */
+public abstract class anyDivideable
+ extends abstractDynAny
+ implements Serializable
+{
+ /**
+ * Use serialVersionUID for interoperability.
+ */
+ private static final long serialVersionUID = 1;
+
+ /**
+ * The array of the components that in general case may have different
+ * final_type.
+ */
+ protected DynAny[] array;
+
+ /**
+ * The internal pointer.
+ */
+ protected int pos = 0;
+
+ public anyDivideable(TypeCode oType, TypeCode aType,
+ gnuDynAnyFactory aFactory, ORB anOrb
+ )
+ {
+ super(oType, aType, aFactory, anOrb);
+ }
+
+ /**
+ * Advance forward.
+ */
+ public boolean next()
+ {
+ pos++;
+ return array.length > pos;
+ }
+
+ /**
+ * Set zero position.
+ */
+ public void rewind()
+ {
+ pos = 0;
+ }
+
+ /**
+ * Set a position.
+ */
+ public boolean seek(int p)
+ {
+ pos = p;
+ return pos >= 0 && array.length > pos;
+ }
+
+ /**
+ * Get the insertion point as DynAny. This method may throw exceptions if the
+ * current insertion point does not support reading or insertion of the
+ * primitive types.
+ *
+ * @return the focused component, from where the primitve value can be read or
+ * where it can be inserted.
+ * @throws InvalidValue if the primitive value cannot be inserted at the given
+ * point.
+ */
+ protected DynAny focused()
+ throws InvalidValue, TypeMismatch
+ {
+ if (pos >= 0 && pos < array.length)
+ {
+ if (array [ pos ].component_count() == 0)
+ return array [ pos ];
+ else
+ throw new TypeMismatch("Multiple coponents at " + pos);
+ }
+ else
+ throw new InvalidValue("Out of bounds at " + pos + " valid 0.." +
+ (array.length - 1)
+ );
+ }
+
+ /** {@inheritDoc} */
+ public int component_count()
+ {
+ return array.length;
+ }
+
+ /**
+ * Return the second (enclosed any) that is stored in the wrapped Any.
+ */
+ public Any get_any()
+ throws TypeMismatch, InvalidValue
+ {
+ return focused().get_any();
+ }
+
+ /** {@inheritDoc} */
+ public boolean get_boolean()
+ throws TypeMismatch, InvalidValue
+ {
+ return focused().get_boolean();
+ }
+
+ /** {@inheritDoc} */
+ public char get_char()
+ throws TypeMismatch, InvalidValue
+ {
+ return focused().get_char();
+ }
+
+ /** {@inheritDoc} */
+ public double get_double()
+ throws TypeMismatch, InvalidValue
+ {
+ return focused().get_double();
+ }
+
+ /** {@inheritDoc} */
+ public float get_float()
+ throws TypeMismatch, InvalidValue
+ {
+ return focused().get_float();
+ }
+
+ /** {@inheritDoc} */
+ public int get_long()
+ throws TypeMismatch, InvalidValue
+ {
+ return focused().get_long();
+ }
+
+ /** {@inheritDoc} */
+ public long get_longlong()
+ throws TypeMismatch, InvalidValue
+ {
+ return focused().get_longlong();
+ }
+
+ /** {@inheritDoc} */
+ public byte get_octet()
+ throws TypeMismatch, InvalidValue
+ {
+ return focused().get_octet();
+ }
+
+ /** {@inheritDoc} */
+ public Object get_reference()
+ throws TypeMismatch, InvalidValue
+ {
+ return focused().get_reference();
+ }
+
+ /** {@inheritDoc} */
+ public short get_short()
+ throws TypeMismatch, InvalidValue
+ {
+ return focused().get_short();
+ }
+
+ /** {@inheritDoc} */
+ public String get_string()
+ throws TypeMismatch, InvalidValue
+ {
+ return focused().get_string();
+ }
+
+ /** {@inheritDoc} */
+ public TypeCode get_typecode()
+ throws TypeMismatch, InvalidValue
+ {
+ return focused().get_typecode();
+ }
+
+ /** {@inheritDoc} */
+ public int get_ulong()
+ throws TypeMismatch, InvalidValue
+ {
+ return focused().get_ulong();
+ }
+
+ /** {@inheritDoc} */
+ public long get_ulonglong()
+ throws TypeMismatch, InvalidValue
+ {
+ return focused().get_ulonglong();
+ }
+
+ /** {@inheritDoc} */
+ public short get_ushort()
+ throws TypeMismatch, InvalidValue
+ {
+ return focused().get_ushort();
+ }
+
+ /** {@inheritDoc} */
+ public Serializable get_val()
+ throws TypeMismatch, InvalidValue
+ {
+ if (pos >= 0 && pos < array.length)
+ {
+ if (array [ pos ] instanceof DynValueCommon)
+ return array [ pos ].get_val();
+ else
+ throw new TypeMismatch();
+ }
+ else
+ throw new InvalidValue("Out of bounds at " + pos + " valid 0.." +
+ (array.length - 1)
+ );
+ }
+
+ /** {@inheritDoc} */
+ public char get_wchar()
+ throws TypeMismatch, InvalidValue
+ {
+ return focused().get_wchar();
+ }
+
+ /** {@inheritDoc} */
+ public String get_wstring()
+ throws TypeMismatch, InvalidValue
+ {
+ return focused().get_wstring();
+ }
+
+ /** {@inheritDoc} */
+ public void insert_any(Any a_x)
+ throws TypeMismatch, InvalidValue
+ {
+ focused().insert_any(a_x);
+ valueChanged();
+ }
+
+ /** {@inheritDoc} */
+ public void insert_boolean(boolean a_x)
+ throws InvalidValue, TypeMismatch
+ {
+ focused().insert_boolean(a_x);
+ valueChanged();
+ }
+
+ /** {@inheritDoc} */
+ public void insert_char(char a_x)
+ throws InvalidValue, TypeMismatch
+ {
+ focused().insert_char(a_x);
+ valueChanged();
+ }
+
+ /** {@inheritDoc} */
+ public void insert_double(double a_x)
+ throws InvalidValue, TypeMismatch
+ {
+ focused().insert_double(a_x);
+ valueChanged();
+ }
+
+ /** {@inheritDoc} */
+ public void insert_float(float a_x)
+ throws InvalidValue, TypeMismatch
+ {
+ focused().insert_float(a_x);
+ valueChanged();
+ }
+
+ /** {@inheritDoc} */
+ public void insert_long(int a_x)
+ throws InvalidValue, TypeMismatch
+ {
+ focused().insert_long(a_x);
+ valueChanged();
+ }
+
+ /** {@inheritDoc} */
+ public void insert_longlong(long a_x)
+ throws InvalidValue, TypeMismatch
+ {
+ focused().insert_longlong(a_x);
+ valueChanged();
+ }
+
+ /** {@inheritDoc} */
+ public void insert_octet(byte a_x)
+ throws InvalidValue, TypeMismatch
+ {
+ focused().insert_octet(a_x);
+ valueChanged();
+ }
+
+ /** {@inheritDoc} */
+ public void insert_reference(Object a_x)
+ throws InvalidValue, TypeMismatch
+ {
+ focused().insert_reference(a_x);
+ valueChanged();
+ }
+
+ /** {@inheritDoc} */
+ public void insert_short(short a_x)
+ throws InvalidValue, TypeMismatch
+ {
+ focused().insert_short(a_x);
+ valueChanged();
+ }
+
+ /** {@inheritDoc} */
+ public void insert_string(String a_x)
+ throws InvalidValue, TypeMismatch
+ {
+ focused().insert_string(a_x);
+ valueChanged();
+ }
+
+ /** {@inheritDoc} */
+ public void insert_typecode(TypeCode a_x)
+ throws InvalidValue, TypeMismatch
+ {
+ focused().insert_typecode(a_x);
+ valueChanged();
+ }
+
+ /** {@inheritDoc} */
+ public void insert_ulong(int a_x)
+ throws InvalidValue, TypeMismatch
+ {
+ focused().insert_ulong(a_x);
+ valueChanged();
+ }
+
+ /** {@inheritDoc} */
+ public void insert_ulonglong(long a_x)
+ throws InvalidValue, TypeMismatch
+ {
+ focused().insert_ulonglong(a_x);
+ valueChanged();
+ }
+
+ /** {@inheritDoc} */
+ public void insert_ushort(short a_x)
+ throws InvalidValue, TypeMismatch
+ {
+ focused().insert_ushort(a_x);
+ valueChanged();
+ }
+
+ /** {@inheritDoc} */
+ public void insert_val(Serializable a_x)
+ throws InvalidValue, TypeMismatch
+ {
+ if (pos >= 0 && pos < array.length)
+ {
+ if (array [ pos ] instanceof DynValueCommon)
+ array [ pos ].insert_val(a_x);
+ else
+ throw new TypeMismatch();
+ }
+ else
+ throw new InvalidValue("Out of bounds at " + pos + " valid 0.." +
+ (array.length - 1)
+ );
+ valueChanged();
+ }
+
+ /** {@inheritDoc} */
+ public void insert_wchar(char a_x)
+ throws InvalidValue, TypeMismatch
+ {
+ focused().insert_wchar(a_x);
+ valueChanged();
+ }
+
+ /** {@inheritDoc} */
+ public void insert_wstring(String a_x)
+ throws InvalidValue, TypeMismatch
+ {
+ focused().insert_wstring(a_x);
+ valueChanged();
+ }
+
+ /** {@inheritDoc} */
+ public DynAny get_dyn_any()
+ throws TypeMismatch, InvalidValue
+ {
+ return focused().get_dyn_any();
+ }
+
+ /** {@inheritDoc} */
+ public void insert_dyn_any(DynAny insert_it)
+ throws TypeMismatch, InvalidValue
+ {
+ focused().insert_dyn_any(insert_it);
+ }
+
+ /**
+ * Get current component.
+ *
+ * @return current component or <code>null</code> if the pointer is out of
+ * bounds.
+ */
+ public DynAny current_component()
+ throws TypeMismatch
+ {
+ if (array.length == 0)
+ throw new TypeMismatch("empty");
+ return (pos >= 0 && pos < array.length) ? array [ pos ] : null;
+ }
+
+ /**
+ * No action, cleanup is done by garbage collector in java.
+ */
+ public void destroy()
+ {
+ }
+
+ /**
+ * Involved in equal(DynAny).
+ */
+ public abstract Any to_any()
+ throws TypeMismatch;
+
+ /**
+ * Compares with other DynAny for equality. The final_type, array size and
+ * array members must match.
+ */
+ public boolean equal(DynAny other)
+ {
+ try
+ {
+ if (!official_type.equal(other.type()))
+ return false;
+ else if (other instanceof anyDivideable)
+ {
+ anyDivideable x = (anyDivideable) other;
+ if (x.array.length != array.length)
+ return false;
+
+ for (int i = 0; i < array.length; i++)
+ {
+ if (!array [ i ].equal(x.array [ i ]))
+ return false;
+ }
+ return true;
+ }
+ else if (other == null || other instanceof abstractDynAny)
+ return false;
+ else
+ return other.to_any().equal(to_any());
+ }
+ catch (TypeMismatch e)
+ {
+ UNKNOWN u = new UNKNOWN(MINOR, CompletionStatus.COMPLETED_NO);
+ u.initCause(e);
+ throw u;
+ }
+ }
+}
\ No newline at end of file
--- /dev/null
+/* Undivideable.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., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 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.DynAn;
+
+import java.io.Serializable;
+
+import org.omg.CORBA.Any;
+import org.omg.CORBA.ORB;
+import org.omg.CORBA.Object;
+import org.omg.CORBA.TypeCode;
+import org.omg.DynamicAny.DynAny;
+import org.omg.DynamicAny.DynAnyPackage.InvalidValue;
+import org.omg.DynamicAny.DynAnyPackage.TypeMismatch;
+
+/**
+ * Represent DynAny that has no internal components (DynEnum and so on). The
+ * methods, related to internal components, throw exceptions or return agreed
+ * values like null.
+ *
+ * @author Audrius Meskauskas, Lithuania (AudriusA@Bioinformatics.org)
+ */
+public abstract class anyUndivideable
+ extends abstractDynAny
+ implements Serializable
+{
+ /**
+ * Use serialVersionUID for interoperability.
+ */
+ private static final long serialVersionUID = 1;
+
+ /**
+ * Create a new instance with the given typecode.
+ */
+ public anyUndivideable(TypeCode oType, TypeCode aType,
+ gnuDynAnyFactory aFactory, ORB anOrb)
+ {
+ super(oType, aType, aFactory, anOrb);
+ }
+
+ /**
+ * There are no components.
+ *
+ * @return 0, always.
+ */
+ public int component_count()
+ {
+ return 0;
+ }
+
+ /**
+ * There is no current component.
+ *
+ * @throws TypeMismatch, always.
+ */
+ public DynAny current_component()
+ throws TypeMismatch
+ {
+ throw new TypeMismatch("Not applicable");
+ }
+
+ /**
+ * Returns without action.
+ */
+ public void destroy()
+ {
+ }
+
+ /**
+ * Not in use.
+ */
+ public Any get_any()
+ throws TypeMismatch, InvalidValue
+ {
+ throw new TypeMismatch();
+ }
+
+ /**
+ * Not in use.
+ */
+ public boolean get_boolean()
+ throws TypeMismatch, InvalidValue
+ {
+ throw new TypeMismatch();
+ }
+
+ /**
+ * Not in use.
+ */
+ public char get_char()
+ throws TypeMismatch, InvalidValue
+ {
+ throw new TypeMismatch();
+ }
+
+ /**
+ * Not in use.
+ */
+ public double get_double()
+ throws TypeMismatch, InvalidValue
+ {
+ throw new TypeMismatch();
+ }
+
+ /**
+ * Not in use.
+ */
+ public DynAny get_dyn_any()
+ throws TypeMismatch, InvalidValue
+ {
+ throw new TypeMismatch();
+ }
+
+ /**
+ * Not in use.
+ */
+ public float get_float()
+ throws TypeMismatch, InvalidValue
+ {
+ throw new TypeMismatch();
+ }
+
+ /**
+ * Not in use.
+ */
+ public int get_long()
+ throws TypeMismatch, InvalidValue
+ {
+ throw new TypeMismatch();
+ }
+
+ /**
+ * Not in use.
+ */
+ public long get_longlong()
+ throws TypeMismatch, InvalidValue
+ {
+ throw new TypeMismatch();
+ }
+
+ /**
+ * Not in use.
+ */
+ public byte get_octet()
+ throws TypeMismatch, InvalidValue
+ {
+ throw new TypeMismatch();
+ }
+
+ /**
+ * Not in use.
+ */
+ public Object get_reference()
+ throws TypeMismatch, InvalidValue
+ {
+ throw new TypeMismatch();
+ }
+
+ /**
+ * Not in use.
+ */
+ public short get_short()
+ throws TypeMismatch, InvalidValue
+ {
+ throw new TypeMismatch();
+ }
+
+ /**
+ * Not in use.
+ */
+ public String get_string()
+ throws TypeMismatch, InvalidValue
+ {
+ throw new TypeMismatch();
+ }
+
+ /**
+ * Not in use.
+ */
+ public TypeCode get_typecode()
+ throws TypeMismatch, InvalidValue
+ {
+ throw new TypeMismatch();
+ }
+
+ /**
+ * Not in use.
+ */
+ public int get_ulong()
+ throws TypeMismatch, InvalidValue
+ {
+ throw new TypeMismatch();
+ }
+
+ /**
+ * Not in use.
+ */
+ public long get_ulonglong()
+ throws TypeMismatch, InvalidValue
+ {
+ throw new TypeMismatch();
+ }
+
+ /**
+ * Not in use.
+ */
+ public short get_ushort()
+ throws TypeMismatch, InvalidValue
+ {
+ throw new TypeMismatch();
+ }
+
+ /**
+ * Not in use.
+ */
+ public Serializable get_val()
+ throws TypeMismatch, InvalidValue
+ {
+ throw new TypeMismatch();
+ }
+
+ /**
+ * Not in use.
+ */
+ public char get_wchar()
+ throws TypeMismatch, InvalidValue
+ {
+ throw new TypeMismatch();
+ }
+
+ /**
+ * Not in use.
+ */
+ public String get_wstring()
+ throws TypeMismatch, InvalidValue
+ {
+ throw new TypeMismatch();
+ }
+
+ /**
+ * Not in use.
+ */
+ public void insert_any(Any an_any)
+ throws TypeMismatch, InvalidValue
+ {
+ throw new TypeMismatch();
+ }
+
+ /**
+ * Not in use.
+ */
+ public void insert_boolean(boolean a_x)
+ throws InvalidValue, TypeMismatch
+ {
+ throw new TypeMismatch();
+ }
+
+ /**
+ * Not in use.
+ */
+ public void insert_char(char a_x)
+ throws InvalidValue, TypeMismatch
+ {
+ throw new TypeMismatch();
+ }
+
+ /**
+ * Not in use.
+ */
+ public void insert_double(double a_x)
+ throws InvalidValue, TypeMismatch
+ {
+ throw new TypeMismatch();
+ }
+
+ /**
+ * Not in use.
+ */
+ public void insert_dyn_any(DynAny insert_it)
+ throws TypeMismatch, InvalidValue
+ {
+ throw new TypeMismatch();
+ }
+
+ /**
+ * Not in use.
+ */
+ public void insert_float(float a_x)
+ throws InvalidValue, TypeMismatch
+ {
+ throw new TypeMismatch();
+ }
+
+ /**
+ * Not in use.
+ */
+ public void insert_long(int a_x)
+ throws InvalidValue, TypeMismatch
+ {
+ throw new TypeMismatch();
+ }
+
+ /**
+ * Not in use.
+ */
+ public void insert_longlong(long a_x)
+ throws InvalidValue, TypeMismatch
+ {
+ throw new TypeMismatch();
+ }
+
+ /**
+ * Not in use.
+ */
+ public void insert_octet(byte a_x)
+ throws InvalidValue, TypeMismatch
+ {
+ throw new TypeMismatch();
+ }
+
+ /**
+ * Not in use.
+ */
+ public void insert_reference(Object a_x)
+ throws InvalidValue, TypeMismatch
+ {
+ throw new TypeMismatch();
+ }
+
+ /**
+ * Not in use.
+ */
+ public void insert_short(short a_x)
+ throws InvalidValue, TypeMismatch
+ {
+ throw new TypeMismatch();
+ }
+
+ /**
+ * Not in use.
+ */
+ public void insert_string(String a_x)
+ throws InvalidValue, TypeMismatch
+ {
+ throw new TypeMismatch();
+ }
+
+ /**
+ * Not in use.
+ */
+ public void insert_typecode(TypeCode a_x)
+ throws InvalidValue, TypeMismatch
+ {
+ throw new TypeMismatch();
+ }
+
+ /**
+ * Not in use.
+ */
+ public void insert_ulong(int a_x)
+ throws InvalidValue, TypeMismatch
+ {
+ throw new TypeMismatch();
+ }
+
+ /**
+ * Not in use.
+ */
+ public void insert_ulonglong(long a_x)
+ throws InvalidValue, TypeMismatch
+ {
+ throw new TypeMismatch();
+ }
+
+ /**
+ * Not in use.
+ */
+ public void insert_ushort(short a_x)
+ throws InvalidValue, TypeMismatch
+ {
+ throw new TypeMismatch();
+ }
+
+ /**
+ * Not in use.
+ */
+ public void insert_val(Serializable a_x)
+ throws InvalidValue, TypeMismatch
+ {
+ throw new TypeMismatch();
+ }
+
+ /**
+ * Not in use.
+ */
+ public void insert_wchar(char a_x)
+ throws InvalidValue, TypeMismatch
+ {
+ throw new TypeMismatch();
+ }
+
+ /**
+ * Not in use.
+ */
+ public void insert_wstring(String a_x)
+ throws InvalidValue, TypeMismatch
+ {
+ throw new TypeMismatch();
+ }
+
+ /**
+ * Not in use.
+ */
+ public boolean next()
+ {
+ return false;
+ }
+
+ /**
+ * Not in use.
+ */
+ public void rewind()
+ {
+ }
+
+ /**
+ * Not in use.
+ */
+ public boolean seek(int p)
+ {
+ return false;
+ }
+
+ /**
+ * Get the typecode of this enumeration.
+ */
+ public TypeCode type()
+ {
+ return official_type;
+ }
+
+ /**
+ * Compares with other DynAny for equality.
+ */
+ public boolean equals(java.lang.Object other)
+ {
+ if (other instanceof DynAny)
+ return equal((DynAny) other);
+ else
+ return false;
+ }
+
+ /**
+ * This depends on an object.
+ */
+ public abstract boolean equal(DynAny other);
+
+}
--- /dev/null
+/* gnuDynAny.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., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 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.DynAn;
+
+import gnu.CORBA.CDR.cdrBufOutput;
+import gnu.CORBA.OctetHolder;
+import gnu.CORBA.Unexpected;
+import gnu.CORBA.WCharHolder;
+import gnu.CORBA.WStringHolder;
+import gnu.CORBA.holderFactory;
+import gnu.CORBA.typeNamer;
+import gnu.CORBA.universalHolder;
+
+import org.omg.CORBA.Any;
+import org.omg.CORBA.AnyHolder;
+import org.omg.CORBA.BooleanHolder;
+import org.omg.CORBA.CharHolder;
+import org.omg.CORBA.DoubleHolder;
+import org.omg.CORBA.FloatHolder;
+import org.omg.CORBA.IntHolder;
+import org.omg.CORBA.LongHolder;
+import org.omg.CORBA.MARSHAL;
+import org.omg.CORBA.ORB;
+import org.omg.CORBA.Object;
+import org.omg.CORBA.ObjectHolder;
+import org.omg.CORBA.ShortHolder;
+import org.omg.CORBA.StringHolder;
+import org.omg.CORBA.TCKind;
+import org.omg.CORBA.TypeCode;
+import org.omg.CORBA.TypeCodeHolder;
+import org.omg.CORBA.TypeCodePackage.BadKind;
+import org.omg.CORBA.ValueBaseHolder;
+import org.omg.CORBA.portable.InputStream;
+import org.omg.CORBA.portable.OutputStream;
+import org.omg.CORBA.portable.Streamable;
+import org.omg.DynamicAny.DynAny;
+import org.omg.DynamicAny.DynAnyPackage.InvalidValue;
+import org.omg.DynamicAny.DynAnyPackage.TypeMismatch;
+
+import java.io.IOException;
+import java.io.Serializable;
+
+import java.util.Arrays;
+
+/**
+ * The primitive dynamic Any holds the value basic final_type that cannot be
+ * traversed.
+ *
+ * @author Audrius Meskauskas, Lithuania (AudriusA@Bioinformatics.org)
+ */
+public class gnuDynAny extends abstractDynAny implements DynAny, Serializable
+{
+ /**
+ * Use serialVersionUID for interoperability.
+ */
+ private static final long serialVersionUID = 1;
+
+ /**
+ * The enclosed Streamable, holding the actual value.
+ */
+ protected Streamable holder;
+
+ /**
+ * Create DynAny providing the holder.
+ *
+ * @param a_holder
+ */
+ public gnuDynAny(Streamable aHolder, TypeCode oType, TypeCode aType,
+ gnuDynAnyFactory aFactory, ORB anOrb
+ )
+ {
+ super(oType, aType, aFactory, anOrb);
+ holder = aHolder;
+ }
+
+ /**
+ * Assign the contents of the given {@link DynAny} to this DynAny.
+ *
+ * @param from the source to assign from.
+ */
+ public void assign(DynAny from) throws TypeMismatch
+ {
+ checkType(official_type, from.type());
+
+ if (from instanceof gnuDynAny)
+ holder = ((gnuDynAny) from).holder;
+ else
+ holder = from.to_any().extract_Streamable();
+ valueChanged();
+ }
+
+ /**
+ * Create a copy of this {@link DynAny} via buffer read/write.
+ */
+ public DynAny copy()
+ {
+ if (holder != null)
+ {
+ cdrBufOutput buffer = new cdrBufOutput();
+ holder._write(buffer);
+
+ gnuDynAny other;
+ try
+ {
+ other =
+ new gnuDynAny((Streamable) (holder.getClass().newInstance()),
+ official_type, final_type, factory, orb
+ );
+ }
+ catch (Exception e)
+ {
+ // Holder must have parameterless constructor.
+ throw new Unexpected(e);
+ }
+ other.holder._read(buffer.create_input_stream());
+ return other;
+ }
+ else
+ {
+ return new gnuDynAny(null, official_type, final_type, factory, orb);
+ }
+ }
+
+ /**
+ * Always returns <code>null</code>.
+ *
+ * @return <code>null</code>, always.
+ */
+ public DynAny current_component() throws TypeMismatch
+ {
+ throw new TypeMismatch("Not applicable for " +
+ typeNamer.nameIt(final_type)
+ );
+ }
+
+ /**
+ * Returns without action, leaving all work to the garbage collector.
+ */
+ public void destroy()
+ {
+ }
+
+ /**
+ * Takes the passed parameter as the enclosed {@link Any} reference.
+ *
+ * @param an_any the {@link Any} that will be used as an enclosed reference.
+ *
+ * @throws TypeMismatch if the final_type of the passed Any is not the same as
+ * the final_type, currently stored in this Any.
+ */
+ public void from_any(Any an_any) throws TypeMismatch, InvalidValue
+ {
+ checkType(official_type, an_any.type());
+
+ Streamable a_holder = an_any.extract_Streamable();
+ if (a_holder == null)
+ {
+ throw new InvalidValue(ISNULL);
+ }
+ else if (a_holder instanceof universalHolder)
+ {
+ holder = holderFactory.createHolder(official_type);
+ if (holder == null)
+ holder = holderFactory.createHolder(final_type);
+
+ if (holder == null)
+ holder = ((universalHolder) a_holder).Clone();
+ else
+ {
+ InputStream in = an_any.create_input_stream();
+ holder._read(in);
+ try
+ {
+ in.close();
+ }
+ catch (IOException ex)
+ {
+ throw new Unexpected(ex);
+ }
+ }
+ }
+ else
+ {
+ try
+ {
+ InputStream in = an_any.create_input_stream();
+ holder = (Streamable) a_holder.getClass().newInstance();
+ holder._read(in);
+ in.close();
+ }
+ catch (Exception ex)
+ {
+ TypeMismatch t = new TypeMismatch();
+ t.initCause(ex);
+ throw t;
+ }
+ }
+ valueChanged();
+ }
+
+ /**
+ * Return the second (enclosed any) that is stored in the wrapped Any.
+ */
+ public Any get_any() throws TypeMismatch
+ {
+ try
+ {
+ return ((AnyHolder) holder).value;
+ }
+ catch (ClassCastException cex)
+ {
+ TypeMismatch m = new TypeMismatch();
+ m.initCause(cex);
+ throw m;
+ }
+ }
+
+ /** {@inheritDoc} */
+ public boolean get_boolean() throws TypeMismatch
+ {
+ try
+ {
+ return ((BooleanHolder) holder).value;
+ }
+ catch (ClassCastException cex)
+ {
+ TypeMismatch m = new TypeMismatch();
+ m.initCause(cex);
+ throw m;
+ }
+ }
+
+ /** {@inheritDoc} */
+ public char get_char() throws TypeMismatch
+ {
+ try
+ {
+ return ((CharHolder) holder).value;
+ }
+ catch (ClassCastException cex)
+ {
+ TypeMismatch m = new TypeMismatch();
+ m.initCause(cex);
+ throw m;
+ }
+ }
+
+ /** {@inheritDoc} */
+ public double get_double() throws TypeMismatch
+ {
+ try
+ {
+ return ((DoubleHolder) holder).value;
+ }
+ catch (ClassCastException cex)
+ {
+ TypeMismatch m = new TypeMismatch();
+ m.initCause(cex);
+ throw m;
+ }
+ }
+
+ /** {@inheritDoc} */
+ public float get_float() throws TypeMismatch
+ {
+ try
+ {
+ return ((FloatHolder) holder).value;
+ }
+ catch (ClassCastException cex)
+ {
+ TypeMismatch m = new TypeMismatch();
+ m.initCause(cex);
+ throw m;
+ }
+ }
+
+ /** {@inheritDoc} */
+ public int get_long() throws TypeMismatch
+ {
+ try
+ {
+ return ((IntHolder) holder).value;
+ }
+ catch (ClassCastException cex)
+ {
+ TypeMismatch m = new TypeMismatch();
+ m.initCause(cex);
+ throw m;
+ }
+ }
+
+ /** {@inheritDoc} */
+ public long get_longlong() throws TypeMismatch
+ {
+ try
+ {
+ return ((LongHolder) holder).value;
+ }
+ catch (ClassCastException cex)
+ {
+ TypeMismatch m = new TypeMismatch();
+ m.initCause(cex);
+ throw m;
+ }
+ }
+
+ /** {@inheritDoc} */
+ public byte get_octet() throws TypeMismatch
+ {
+ try
+ {
+ return ((OctetHolder) holder).value;
+ }
+ catch (ClassCastException cex)
+ {
+ TypeMismatch m = new TypeMismatch();
+ m.initCause(cex);
+ throw m;
+ }
+ }
+
+ /** {@inheritDoc} */
+ public Object get_reference() throws TypeMismatch
+ {
+ try
+ {
+ return ((ObjectHolder) holder).value;
+ }
+ catch (ClassCastException cex)
+ {
+ TypeMismatch m = new TypeMismatch();
+ m.initCause(cex);
+ throw m;
+ }
+ }
+
+ /** {@inheritDoc} */
+ public short get_short() throws TypeMismatch
+ {
+ try
+ {
+ return ((ShortHolder) holder).value;
+ }
+ catch (ClassCastException cex)
+ {
+ TypeMismatch m = new TypeMismatch();
+ m.initCause(cex);
+ throw m;
+ }
+ }
+
+ /** {@inheritDoc} */
+ public String get_string() throws TypeMismatch
+ {
+ try
+ {
+ return ((StringHolder) holder).value;
+ }
+ catch (ClassCastException cex)
+ {
+ TypeMismatch m = new TypeMismatch();
+ m.initCause(cex);
+ throw m;
+ }
+ }
+
+ /** {@inheritDoc} */
+ public TypeCode get_typecode() throws TypeMismatch
+ {
+ try
+ {
+ return ((TypeCodeHolder) holder).value;
+ }
+ catch (ClassCastException cex)
+ {
+ TypeMismatch m = new TypeMismatch();
+ m.initCause(cex);
+ throw m;
+ }
+ }
+
+ /** {@inheritDoc} */
+ public int get_ulong() throws TypeMismatch
+ {
+ check(TCKind.tk_ulong);
+ return get_long();
+ }
+
+ /** {@inheritDoc} */
+ public long get_ulonglong() throws TypeMismatch
+ {
+ check(TCKind.tk_ulonglong);
+ return get_longlong();
+ }
+
+ /** {@inheritDoc} */
+ public short get_ushort() throws TypeMismatch
+ {
+ check(TCKind.tk_ushort);
+ return get_short();
+ }
+
+ /** {@inheritDoc} */
+ public Serializable get_val() throws TypeMismatch
+ {
+ try
+ {
+ return ((ValueBaseHolder) holder).value;
+ }
+ catch (ClassCastException cex)
+ {
+ TypeMismatch m = new TypeMismatch();
+ m.initCause(cex);
+ throw m;
+ }
+ }
+
+ /** {@inheritDoc} */
+ public char get_wchar() throws TypeMismatch
+ {
+ try
+ {
+ return ((WCharHolder) holder).value;
+ }
+ catch (ClassCastException cex)
+ {
+ TypeMismatch m = new TypeMismatch();
+ m.initCause(cex);
+ throw m;
+ }
+ }
+
+ /** {@inheritDoc} */
+ public String get_wstring() throws TypeMismatch
+ {
+ try
+ {
+ return ((WStringHolder) holder).value;
+ }
+ catch (ClassCastException cex)
+ {
+ TypeMismatch m = new TypeMismatch();
+ m.initCause(cex);
+ throw m;
+ }
+ }
+
+ /** {@inheritDoc} */
+ public void insert_any(Any a_x) throws TypeMismatch, InvalidValue
+ {
+ try
+ {
+ if (a_x.type().kind().value() == TCKind._tk_null)
+ ((AnyHolder) holder).value = a_x;
+ else
+ {
+ OutputStream buf = a_x.create_output_stream();
+ buf.write_any(a_x);
+ holder._read(buf.create_input_stream());
+ buf.close();
+ }
+ valueChanged();
+ }
+ catch (ClassCastException cex)
+ {
+ TypeMismatch t = new TypeMismatch();
+ t.initCause(cex);
+ throw t;
+ }
+ catch (MARSHAL m)
+ {
+ InvalidValue v = new InvalidValue();
+ v.initCause(m);
+ throw v;
+ }
+ catch (IOException ex)
+ {
+ throw new Unexpected(ex);
+ }
+ }
+
+ /** {@inheritDoc} */
+ public void insert_boolean(boolean a_x) throws InvalidValue, TypeMismatch
+ {
+ try
+ {
+ ((BooleanHolder) holder).value = a_x;
+ valueChanged();
+ }
+ catch (ClassCastException cex)
+ {
+ TypeMismatch t = new TypeMismatch();
+ t.initCause(cex);
+ throw t;
+ }
+ }
+
+ /** {@inheritDoc} */
+ public void insert_char(char a_x) throws InvalidValue, TypeMismatch
+ {
+ try
+ {
+ ((CharHolder) holder).value = a_x;
+ valueChanged();
+ }
+ catch (ClassCastException cex)
+ {
+ TypeMismatch t = new TypeMismatch();
+ t.initCause(cex);
+ throw t;
+ }
+ }
+
+ /** {@inheritDoc} */
+ public void insert_double(double a_x) throws InvalidValue, TypeMismatch
+ {
+ try
+ {
+ ((DoubleHolder) holder).value = a_x;
+ valueChanged();
+ }
+ catch (ClassCastException cex)
+ {
+ TypeMismatch t = new TypeMismatch();
+ t.initCause(cex);
+ throw t;
+ }
+ }
+
+ /** {@inheritDoc} */
+ public void insert_float(float a_x) throws InvalidValue, TypeMismatch
+ {
+ try
+ {
+ ((FloatHolder) holder).value = a_x;
+ valueChanged();
+ }
+ catch (ClassCastException cex)
+ {
+ TypeMismatch t = new TypeMismatch();
+ t.initCause(cex);
+ throw t;
+ }
+ }
+
+ /** {@inheritDoc} */
+ public void insert_long(int a_x) throws InvalidValue, TypeMismatch
+ {
+ try
+ {
+ ((IntHolder) holder).value = a_x;
+ valueChanged();
+ }
+ catch (ClassCastException cex)
+ {
+ TypeMismatch t = new TypeMismatch();
+ t.initCause(cex);
+ throw t;
+ }
+ }
+
+ /** {@inheritDoc} */
+ public void insert_longlong(long a_x) throws InvalidValue, TypeMismatch
+ {
+ try
+ {
+ ((LongHolder) holder).value = a_x;
+ valueChanged();
+ }
+ catch (ClassCastException cex)
+ {
+ TypeMismatch t = new TypeMismatch();
+ t.initCause(cex);
+ throw t;
+ }
+ }
+
+ /** {@inheritDoc} */
+ public void insert_octet(byte a_x) throws InvalidValue, TypeMismatch
+ {
+ try
+ {
+ ((OctetHolder) holder).value = a_x;
+ valueChanged();
+ }
+ catch (ClassCastException cex)
+ {
+ TypeMismatch t = new TypeMismatch();
+ t.initCause(cex);
+ throw t;
+ }
+ }
+
+ /** {@inheritDoc} */
+ public void insert_reference(Object a_x) throws InvalidValue, TypeMismatch
+ {
+ try
+ {
+ ((ObjectHolder) holder).value = a_x;
+ valueChanged();
+ }
+ catch (ClassCastException cex)
+ {
+ TypeMismatch t = new TypeMismatch();
+ t.initCause(cex);
+ throw t;
+ }
+ }
+
+ /** {@inheritDoc} */
+ public void insert_short(short a_x) throws InvalidValue, TypeMismatch
+ {
+ try
+ {
+ ((ShortHolder) holder).value = a_x;
+ valueChanged();
+ }
+ catch (ClassCastException cex)
+ {
+ TypeMismatch t = new TypeMismatch();
+ t.initCause(cex);
+ throw t;
+ }
+ }
+
+ /** {@inheritDoc} */
+ public void insert_string(String a_x) throws InvalidValue, TypeMismatch
+ {
+ try
+ {
+ if (a_x != null &&
+ final_type.length() > 0 &&
+ a_x.length() > final_type.length()
+ )
+ throw new InvalidValue(a_x.length() + " exceeds bound, " +
+ final_type.length()
+ );
+ ((StringHolder) holder).value = a_x;
+ valueChanged();
+ }
+ catch (ClassCastException cex)
+ {
+ TypeMismatch t = new TypeMismatch();
+ t.initCause(cex);
+ throw t;
+ }
+ catch (BadKind e)
+ {
+ TypeMismatch t = new TypeMismatch();
+ t.initCause(e);
+ throw t;
+ }
+ }
+
+ /** {@inheritDoc} */
+ public void insert_typecode(TypeCode a_x) throws InvalidValue, TypeMismatch
+ {
+ try
+ {
+ ((TypeCodeHolder) holder).value = a_x;
+ valueChanged();
+ }
+ catch (ClassCastException cex)
+ {
+ TypeMismatch t = new TypeMismatch();
+ t.initCause(cex);
+ throw t;
+ }
+ }
+
+ /** {@inheritDoc} */
+ public void insert_ulong(int a_x) throws InvalidValue, TypeMismatch
+ {
+ try
+ {
+ ((IntHolder) holder).value = a_x;
+ valueChanged();
+ }
+ catch (ClassCastException cex)
+ {
+ TypeMismatch t = new TypeMismatch();
+ t.initCause(cex);
+ throw t;
+ }
+ }
+
+ /** {@inheritDoc} */
+ public void insert_ulonglong(long a_x) throws InvalidValue, TypeMismatch
+ {
+ try
+ {
+ ((LongHolder) holder).value = a_x;
+ valueChanged();
+ }
+ catch (ClassCastException cex)
+ {
+ TypeMismatch t = new TypeMismatch();
+ t.initCause(cex);
+ throw t;
+ }
+ }
+
+ /** {@inheritDoc} */
+ public void insert_ushort(short a_x) throws InvalidValue, TypeMismatch
+ {
+ try
+ {
+ ((ShortHolder) holder).value = a_x;
+ valueChanged();
+ }
+ catch (ClassCastException cex)
+ {
+ TypeMismatch t = new TypeMismatch();
+ t.initCause(cex);
+ throw t;
+ }
+ }
+
+ /** {@inheritDoc} */
+ public void insert_val(Serializable a_x) throws InvalidValue, TypeMismatch
+ {
+ try
+ {
+ ((ValueBaseHolder) holder).value = a_x;
+ valueChanged();
+ }
+ catch (ClassCastException cex)
+ {
+ TypeMismatch t = new TypeMismatch();
+ t.initCause(cex);
+ throw t;
+ }
+ }
+
+ /** {@inheritDoc} */
+ public void insert_wchar(char a_x) throws InvalidValue, TypeMismatch
+ {
+ try
+ {
+ ((WCharHolder) holder).value = a_x;
+ valueChanged();
+ }
+ catch (ClassCastException cex)
+ {
+ TypeMismatch t = new TypeMismatch();
+ t.initCause(cex);
+ throw t;
+ }
+ }
+
+ /** {@inheritDoc} */
+ public void insert_wstring(String a_x) throws InvalidValue, TypeMismatch
+ {
+ try
+ {
+ if (a_x != null &&
+ final_type.length() > 0 &&
+ a_x.length() > type().length()
+ )
+ throw new InvalidValue(a_x.length() + " exceeds bound, " +
+ final_type.length()
+ );
+ ((WStringHolder) holder).value = a_x;
+ valueChanged();
+ }
+ catch (ClassCastException cex)
+ {
+ TypeMismatch t = new TypeMismatch();
+ t.initCause(cex);
+ throw t;
+ }
+ catch (BadKind e)
+ {
+ TypeMismatch t = new TypeMismatch();
+ t.initCause(e);
+ throw t;
+ }
+ }
+
+ /**
+ * The objects, enclosed inside this class, have only one component (self).
+ *
+ * @return false, always (no other action).
+ */
+ public boolean next()
+ {
+ return false;
+ }
+
+ /**
+ * Returns without action.
+ */
+ public void rewind()
+ {
+ }
+
+ /**
+ * This objects, stored in this wrapper, never have multiple internal
+ * components to seek.
+ *
+ * @return false, always (no other action).
+ */
+ public boolean seek(int p)
+ {
+ return false;
+ }
+
+ /**
+ * Returns the enclosed {@link Any}.
+ *
+ * @return the enclosed {@link Any}.
+ */
+ public Any to_any()
+ {
+ Any a = createAny();
+ a.insert_Streamable(holder);
+ a.type(official_type);
+ return a;
+ }
+
+ /** {@inheritDoc} */
+ public TypeCode type()
+ {
+ return official_type;
+ }
+
+ /**
+ * Compute hashcode in a trivial way.
+ */
+ protected int getHashCodeSimple(int maximum)
+ {
+ int h = super.hashCode() / 2;
+ if (h < 0)
+ h = -h;
+ return h % maximum;
+ }
+
+ /**
+ * Inserts Any, contained in the parameter, into Any, contained in this
+ * DynAny.
+ */
+ public void insert_dyn_any(DynAny d) throws TypeMismatch, InvalidValue
+ {
+ check(d.type().kind());
+
+ Any a = d.to_any();
+ holder = a.extract_Streamable();
+ valueChanged();
+ }
+
+ /**
+ * Checks for equality. The DynAnys are equal if the stored Anys are equal.
+ */
+ public boolean equal(DynAny other)
+ {
+ if (other instanceof abstractDynAny)
+ {
+ if (other instanceof gnuDynAny)
+ {
+ gnuDynAny x = (gnuDynAny) other;
+
+ if (!x.holder.getClass().equals(holder.getClass()))
+ return false;
+
+ cdrBufOutput b1 = new cdrBufOutput();
+ x.holder._write(b1);
+
+ cdrBufOutput b2 = new cdrBufOutput(b1.buffer.size() + 10);
+ holder._write(b2);
+
+ return Arrays.equals(b1.buffer.toByteArray(),
+ b2.buffer.toByteArray()
+ );
+ }
+ else
+ return false;
+ }
+ if (other == null)
+ return false;
+ else if (other.component_count() != component_count() ||
+ !official_type.equal(other.type())
+ )
+ return false;
+ else
+ return other.to_any().equal(to_any());
+ }
+
+ /**
+ * This final_type has no components.
+ *
+ * @return 0, always.
+ */
+ public int component_count()
+ {
+ return 0;
+ }
+
+ public DynAny get_dyn_any() throws TypeMismatch, InvalidValue
+ {
+ return new gnuDynAny(holder, official_type, final_type, factory, orb);
+ }
+
+ private void check(TCKind t) throws TypeMismatch
+ {
+ if (t.value() != final_type.kind().value())
+ throw new TypeMismatch(t.value() + "!=" + final_type.kind().value());
+ }
+}
\ No newline at end of file
--- /dev/null
+/* gnuDynAnyFactory.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., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 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.DynAn;
+
+import gnu.CORBA.Poa.ORB_1_4;
+import gnu.CORBA.Unexpected;
+import gnu.CORBA.holderFactory;
+import gnu.CORBA.typeNamer;
+
+import org.omg.CORBA.Any;
+import org.omg.CORBA.LocalObject;
+import org.omg.CORBA.TCKind;
+import org.omg.CORBA.TypeCode;
+import org.omg.CORBA.TypeCodePackage.BadKind;
+import org.omg.CORBA.UserException;
+import org.omg.CORBA.portable.Streamable;
+import org.omg.DynamicAny.DynAny;
+import org.omg.DynamicAny.DynAnyFactory;
+import org.omg.DynamicAny.DynAnyFactoryPackage.InconsistentTypeCode;
+import org.omg.DynamicAny.DynArray;
+import org.omg.DynamicAny.DynEnum;
+import org.omg.DynamicAny.DynFixed;
+import org.omg.DynamicAny.DynSequence;
+import org.omg.DynamicAny.DynStruct;
+import org.omg.DynamicAny.DynUnion;
+import org.omg.DynamicAny.DynValue;
+import org.omg.DynamicAny.DynValueBox;
+
+/**
+ * This class is returned by ORB when resolving
+ * initial reference "DynAnyFactory".
+ *
+ * @author Audrius Meskauskas, Lithuania (AudriusA@Bioinformatics.org)
+ */
+public class gnuDynAnyFactory
+ extends LocalObject
+ implements DynAnyFactory
+{
+ /**
+ * Use serialVersionUID for interoperability.
+ */
+ private static final long serialVersionUID = 1;
+
+ /**
+ * The ORB, to that the factory belongs.
+ */
+ final ORB_1_4 orb;
+
+ /**
+ * Create a new factory, specifying the ORB to that the factory belongs.
+ *
+ * @param anOrb
+ */
+ public gnuDynAnyFactory(ORB_1_4 anOrb)
+ {
+ orb = anOrb;
+ }
+
+ /**
+ * Get the orb.
+ */
+ public ORB_1_4 getOrb()
+ {
+ return orb;
+ }
+
+ /**
+ * Create an initialised array.
+ */
+ public DynArray create_array(TypeCode official, TypeCode type)
+ {
+ return new gnuDynArray(official, type, this, orb, true);
+ }
+
+ /**
+ * Create an empty sequence.
+ */
+ public DynSequence create_sequence(TypeCode official, TypeCode type)
+ {
+ return new gnuDynSequence(official, type, this, orb);
+ }
+
+ /**
+ * Create structure.
+ *
+ * @param official the type that was originally passed as a parameter by user.
+ * May be alias of some other type.
+ * @param type the type into that the "official type" evaluates during alias
+ * resolving. Initially equal to "official type".
+ */
+ public DynStruct create_structure(TypeCode official, TypeCode type)
+ {
+ return new gnuDynStruct(official, type, this, orb);
+ }
+
+ /**
+ * Create union.
+ *
+ * @param official the type that was originally passed as a parameter by user.
+ * May be alias of some other type.
+ * @param type the type into that the "official type" evaluates during alias
+ * resolving. Initially equal to "official type".
+ */
+ public DynUnion create_union(TypeCode official, TypeCode type)
+ {
+ try
+ {
+ return new gnuDynUnion(official, type, this, orb);
+ }
+ catch (Exception ex)
+ {
+ throw new Unexpected(ex);
+ }
+ }
+
+ /**
+ * Create value.
+ *
+ * @param official the type that was originally passed as a parameter by user.
+ * May be alias of some other type.
+ * @param type the type into that the "official type" evaluates during alias
+ * resolving. Initially equal to "official type".
+ */
+ public DynValue create_value(TypeCode official, TypeCode type)
+ {
+ return new gnuDynValue(official, type, this, orb);
+ }
+
+ /**
+ * Create value box.
+ *
+ * @param official the type that was originally passed as a parameter by user.
+ * May be alias of some other type.
+ * @param type the type into that the "official type" evaluates during alias
+ * resolving. Initially equal to "official type".
+ */
+ public DynValueBox create_value_box(TypeCode official, TypeCode type)
+ {
+ return new gnuDynValueBox(official, type, this, orb);
+ }
+
+ /**
+ * Create enumeration.
+ *
+ * @param official the type that was originally passed as a parameter by user.
+ * May be alias of some other type.
+ * @param type the type into that the "official type" evaluates during alias
+ * resolving. Initially equal to "official type".
+ */
+ public DynEnum create_enumeration(TypeCode official, TypeCode type)
+ {
+ return new gnuDynEnum(official, type, this, orb);
+ }
+
+ /**
+ * Create fixed.
+ *
+ * @param official the type that was originally passed as a parameter by user.
+ * May be alias of some other type.
+ * @param type the type into that the "official type" evaluates during alias
+ * resolving. Initially equal to "official type".
+ */
+ public DynFixed create_fixed(TypeCode official, TypeCode type)
+ {
+ return new gnuDynFixed(official, type, this, orb);
+ }
+
+ /**
+ * Create alias.
+ *
+ * @param official the type that was originally passed as a parameter by user.
+ * May be alias of some other type.
+ * @param type the type into that the "official type" evaluates during alias
+ * resolving. Initially equal to "official type".
+ */
+ public DynAny create_alias(TypeCode official, TypeCode type)
+ throws InconsistentTypeCode
+ {
+ try
+ {
+ return create_dyn_any_from_type_code(official, type.content_type());
+ }
+ catch (BadKind e)
+ {
+ throw new Unexpected(e);
+ }
+ }
+
+ /**
+ * Create the undivideable DynAny.
+ */
+ public DynAny create_simple(TypeCode official, TypeCode type)
+ {
+ Streamable holder = holderFactory.createHolder(type);
+ return new gnuDynAny(holder, official, type, this, orb);
+ }
+
+ /**
+ * Create the DynAny from typecode.
+ */
+ public DynAny create_dyn_any_from_type_code(TypeCode type)
+ throws InconsistentTypeCode
+ {
+ return create_dyn_any_from_type_code(type, type);
+ }
+
+ /**
+ * Create the DynAny from typecode.
+ *
+ * @param official the type that was originally passed as a parameter by user.
+ * May be alias of some other type.
+ * @param type the type into that the "official type" evaluates during alias
+ * resolving. Initially equal to "official type".
+ */
+ public DynAny create_dyn_any_from_type_code(TypeCode official, TypeCode type)
+ throws InconsistentTypeCode
+ {
+ DynAny d;
+ try
+ {
+ switch (type.kind().value())
+ {
+ case TCKind._tk_array :
+ return create_array(official, type);
+
+ case TCKind._tk_sequence :
+ return create_sequence(official, type);
+
+ case TCKind._tk_struct :
+ case TCKind._tk_except :
+ return create_structure(official, type);
+
+ case TCKind._tk_union :
+ return create_union(official, type);
+
+ case TCKind._tk_value :
+ return create_value(official, type);
+
+ case TCKind._tk_value_box :
+ return create_value_box(official, type);
+
+ case TCKind._tk_enum :
+ return create_enumeration(official, type);
+
+ case TCKind._tk_fixed :
+ return create_fixed(official, type);
+
+ case TCKind._tk_alias :
+ return create_alias(official, type);
+
+ case TCKind._tk_null :
+ return new gnuDynAny(null, official, type, this, orb);
+
+ case TCKind._tk_TypeCode :
+ d = create_simple(official, type);
+ d.insert_typecode(orb.get_primitive_tc(TCKind.tk_null));
+ return d;
+
+ case TCKind._tk_any :
+ d = create_simple(official, type);
+
+ Any empty_any = orb.create_any();
+ empty_any.type(orb.get_primitive_tc(TCKind.tk_null));
+ d.insert_any(empty_any);
+ return d;
+
+ case TCKind._tk_wstring :
+ d = create_simple(official, type);
+ d.insert_wstring("");
+ return d;
+
+ case TCKind._tk_string :
+ d = create_simple(official, type);
+ d.insert_string("");
+ return d;
+
+ case TCKind._tk_native :
+ case TCKind._tk_Principal :
+ case TCKind._tk_abstract_interface :
+ throw new InconsistentTypeCode("Following API, the " +
+ typeNamer.nameIt(type) +
+ " must not be supported."
+ );
+
+ default :
+ return create_simple(official, type);
+ }
+ }
+ catch (UserException uex)
+ {
+ InconsistentTypeCode it = new InconsistentTypeCode();
+ it.initCause(uex);
+ throw it;
+ }
+ }
+
+ /**
+ * Create the DynAny using the passed value as template and assign this value.
+ */
+ public DynAny create_dyn_any(Any value)
+ throws InconsistentTypeCode
+ {
+ DynAny created = create_dyn_any_from_type_code(value.type());
+ try
+ {
+ created.from_any(value);
+ }
+ catch (UserException uex)
+ {
+ InconsistentTypeCode t = new InconsistentTypeCode("Inconsistent Any");
+ t.initCause(uex);
+ throw t;
+ }
+ catch (Exception e)
+ {
+ throw new Unexpected(e);
+ }
+ return created;
+ }
+}
\ No newline at end of file
--- /dev/null
+/* gnuDynArray.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., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 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.DynAn;
+
+import gnu.CORBA.Unexpected;
+import gnu.CORBA.holderFactory;
+
+import org.omg.CORBA.Any;
+import org.omg.CORBA.BAD_PARAM;
+import org.omg.CORBA.ORB;
+import org.omg.CORBA.TCKind;
+import org.omg.CORBA.TypeCode;
+import org.omg.CORBA.TypeCodePackage.BadKind;
+import org.omg.CORBA.portable.Streamable;
+import org.omg.DynamicAny.DynAny;
+import org.omg.DynamicAny.DynAnyFactoryPackage.InconsistentTypeCode;
+import org.omg.DynamicAny.DynAnyPackage.InvalidValue;
+import org.omg.DynamicAny.DynAnyPackage.TypeMismatch;
+import org.omg.DynamicAny.DynArray;
+
+import java.io.Serializable;
+
+import java.lang.reflect.Array;
+import java.lang.reflect.Field;
+
+/**
+ * Provides support for dynamic array or sequence, where all members have the
+ * same final_type.
+ *
+ * @author Audrius Meskauskas, Lithuania (AudriusA@Bioinformatics.org)
+ */
+public class gnuDynArray
+ extends anyDivideable
+ implements DynArray, Serializable
+{
+ /**
+ * Use serialVersionUID for interoperability.
+ */
+ private static final long serialVersionUID = 1;
+
+ /**
+ * The component "official" type (may be alias).
+ */
+ final TypeCode official_components;
+
+ /**
+ * The component "final" type, after resolving any aliases.
+ */
+ final TypeCode final_components;
+
+ /**
+ * Creates new array.
+ *
+ * @param aType the final_type of array.
+ * @param aFactory the factory, used to initialise default values.
+ * @param orb the ORB to that this DynAny belongs.
+ * @param initialise_array if false, the array is not initialised in
+ * constructor.
+ *
+ *
+ * @throws BAD_PARAM if the passed typecode does not provide the length().
+ */
+ public gnuDynArray(TypeCode oType, TypeCode aType, gnuDynAnyFactory aFactory,
+ ORB anOrb, boolean initialise_array
+ )
+ throws BAD_PARAM
+ {
+ super(oType, aType, aFactory, anOrb);
+
+ try
+ {
+ official_components = final_type.content_type();
+
+ TypeCode component = official_components;
+ while (component.kind().value() == TCKind._tk_alias)
+ component = component.content_type();
+ final_components = component;
+
+ if (initialise_array)
+ {
+ array = new DynAny[ aType.length() ];
+ for (int i = 0; i < array.length; i++)
+ {
+ array [ i ] =
+ factory.create_dyn_any_from_type_code(official_components);
+ }
+ }
+ }
+ catch (Exception e)
+ {
+ BAD_PARAM bad = new BAD_PARAM("Unable to initialise array");
+ bad.initCause(e);
+ throw bad;
+ }
+ }
+
+ /**
+ * Copy one DynAny into another.
+ */
+ public void assign(DynAny from)
+ throws TypeMismatch
+ {
+ checkType(official_type, from.type());
+ if (from instanceof DynArray && from.component_count() == array.length)
+ {
+ DynArray dyn = (DynArray) from;
+ array = dyn.get_elements_as_dyn_any();
+ }
+ else
+ throw new TypeMismatch();
+ }
+
+ /**
+ * Create a copy.
+ */
+ public DynAny copy()
+ {
+ DynAny[] c = new DynAny[ array.length ];
+ for (int i = 0; i < c.length; i++)
+ {
+ c [ i ] = array [ i ].copy();
+ }
+
+ gnuDynArray d =
+ new gnuDynArray(official_type, final_type, factory, orb, false);
+ d.array = c;
+ return d;
+ }
+
+ /**
+ * Get elements as array of anys.
+ */
+ public Any[] get_elements()
+ {
+ Any[] r = new Any[ array.length ];
+ for (int i = 0; i < r.length; i++)
+ r [ i ] = array [ i ].to_any();
+ return r;
+ }
+
+ /** {@inheritDoc} */
+ public DynAny[] get_elements_as_dyn_any()
+ {
+ DynAny[] a = new DynAny[ array.length ];
+ for (int i = 0; i < a.length; i++)
+ {
+ a [ i ] = array [ i ].copy();
+ }
+ return a;
+ }
+
+ /**
+ * Set elements when array of dyn anys is provided. This method can set nested
+ * data structures as an array components.
+ */
+ public void set_elements_as_dyn_any(DynAny[] value)
+ throws InvalidValue, TypeMismatch
+ {
+ if (value.length != array.length)
+ throw new InvalidValue(sizeMismatch(array.length, value.length));
+ for (int i = 0; i < value.length; i++)
+ {
+ checkType(official_components, value [ i ].type());
+ array [ i ].assign(value [ i ]);
+ }
+ pos = 0;
+ valueChanged();
+ }
+
+ /**
+ * Set elements when array of ordinary anys is provided.
+ */
+ public void set_elements(Any[] value)
+ throws InvalidValue, TypeMismatch
+ {
+ if (value.length != array.length)
+ throw new InvalidValue(sizeMismatch(array.length, value.length));
+
+ for (int i = 0; i < value.length; i++)
+ {
+ checkType(official_components, value [ i ].type());
+ try
+ {
+ array [ i ] = factory.create_dyn_any(value [ i ]);
+ }
+ catch (InconsistentTypeCode e)
+ {
+ TypeMismatch t = new TypeMismatch();
+ t.initCause(e);
+ throw t;
+ }
+ }
+ pos = 0;
+ valueChanged();
+ }
+
+ /**
+ * Done via reflection.
+ */
+ public Any to_any()
+ {
+ try
+ {
+ Streamable memberHolder =
+ holderFactory.createHolder(official_components);
+
+ if (memberHolder == null)
+ memberHolder = holderFactory.createHolder(final_components);
+
+ Class memberHolderClass = memberHolder.getClass();
+ Class memberClass = memberHolderClass.getField("value").getType();
+
+ Object members = Array.newInstance(memberClass, array.length);
+ Object member;
+ Any am;
+ Field value = memberHolder.getClass().getField("value");
+
+ for (int i = 0; i < array.length; i++)
+ {
+ // Recursive call should support multidimensional arrays.
+ am = array [ i ].to_any();
+ memberHolder = am.extract_Streamable();
+ member = value.get(memberHolder);
+ Array.set(members, i, member);
+ }
+
+ Streamable arrayHolder = holderFactory.createHolder(official_type);
+ arrayHolder.getClass().getField("value").set(arrayHolder, members);
+
+ Any g = createAny();
+ g.insert_Streamable(arrayHolder);
+ g.type(official_type);
+ return g;
+ }
+ catch (Exception e)
+ {
+ throw new Unexpected(e);
+ }
+ }
+
+ /**
+ * Done via reflection.
+ */
+ public void from_any(Any an_any)
+ throws TypeMismatch, InvalidValue
+ {
+ checkType(official_type, an_any.type());
+ try
+ {
+ Streamable s = an_any.extract_Streamable();
+ Object members = s.getClass().getField("value").get(s);
+
+ checkArrayValid(members);
+
+ Any member;
+ Streamable holder;
+ Class holderClass = null;
+
+ for (int i = 0; i < array.length; i++)
+ {
+ if (holderClass == null)
+ {
+ holder = holderFactory.createHolder(official_components);
+ if (holder == null)
+ holder = holderFactory.createHolder(final_components);
+ holderClass = holder.getClass();
+ }
+ else
+ holder = (Streamable) holderClass.newInstance();
+
+ member = createAny();
+ holder.getClass().getField("value").set(holder,
+ Array.get(members, i)
+ );
+ member.insert_Streamable(holder);
+ member.type(official_components);
+
+ // This may lead to recursion, supporting multidimensional
+ // arrays.
+ array [ i ].from_any(member);
+ }
+ }
+ catch (Exception ex)
+ {
+ TypeMismatch t = new TypeMismatch();
+ t.initCause(ex);
+ throw t;
+ }
+ valueChanged();
+ }
+
+ /**
+ * Check if array size is valid and (for sequences) resized
+ * if required. Called from from_any.
+ */
+ protected void checkArrayValid(Object members)
+ throws TypeMismatch, InvalidValue
+ {
+ if (array.length != Array.getLength(members))
+ throw new InvalidValue(sizeMismatch(array.length, Array.getLength(members)));
+ }
+}
\ No newline at end of file
--- /dev/null
+/* gnuDynEnum.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., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 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.DynAn;
+
+import gnu.CORBA.Unexpected;
+
+import org.omg.CORBA.Any;
+import org.omg.CORBA.BAD_PARAM;
+import org.omg.CORBA.MARSHAL;
+import org.omg.CORBA.ORB;
+import org.omg.CORBA.TypeCode;
+import org.omg.CORBA.portable.InputStream;
+import org.omg.DynamicAny.DynAny;
+import org.omg.DynamicAny.DynAnyPackage.InvalidValue;
+import org.omg.DynamicAny.DynAnyPackage.TypeMismatch;
+import org.omg.DynamicAny.DynEnum;
+
+import java.io.IOException;
+
+import java.util.Arrays;
+
+/**
+ * Our implementation of dynamic enumeration.
+ *
+ * @author Audrius Meskauskas, Lithuania (AudriusA@Bioinformatics.org)
+ */
+public class gnuDynEnum extends anyUndivideable implements DynEnum
+{
+ /**
+ * Use serialVersionUID for interoperability.
+ */
+ private static final long serialVersionUID = 1;
+
+ /**
+ * The valid string values of the enumeration. Most of enumerations are short,
+ * counting 2-5 memebers. With so small number of memebers, it seems not
+ * reasonable to use hashtables.
+ */
+ final String[] values;
+
+ /**
+ * The current value of enum.
+ */
+ int current;
+
+ /**
+ * Create a new dyn enum from the given typecode.
+ */
+ public gnuDynEnum(TypeCode oType, TypeCode aType, gnuDynAnyFactory aFactory,
+ ORB anOrb
+ )
+ {
+ super(oType, aType, aFactory, anOrb);
+ try
+ {
+ values = new String[ final_type.member_count() ];
+
+ for (int i = 0; i < values.length; i++)
+ {
+ values [ i ] = final_type.member_name(i);
+ }
+ }
+ catch (Exception e)
+ {
+ throw new BAD_PARAM("Not enum");
+ }
+ }
+
+ /**
+ * Create a clone of the given enum, sharing values and final_type.
+ */
+ public gnuDynEnum(gnuDynEnum from)
+ {
+ super(from.official_type, from.final_type, from.factory, from.orb);
+ values = from.values;
+ }
+
+ /**
+ * Assign the Enum from the passed value. The passed DynAny must hold the
+ * enumeration of exactly the same final_type.
+ */
+ public void assign(DynAny from) throws TypeMismatch
+ {
+ checkType(official_type, from.type());
+ if (!(from instanceof DynEnum))
+ throw new TypeMismatch("Not a DynEnum");
+ try
+ {
+ set_as_ulong(((DynEnum) from).get_as_ulong());
+ }
+ catch (InvalidValue e)
+ {
+ TypeMismatch t = new TypeMismatch();
+ t.initCause(e);
+ throw t;
+ }
+ }
+
+ /**
+ * Copy this DynEnum.
+ */
+ public DynAny copy()
+ {
+ gnuDynEnum other = new gnuDynEnum(this);
+ other.current = current;
+ return other;
+ }
+
+ /**
+ * Compares for equality.
+ */
+ public boolean equal(DynAny other)
+ {
+ if (other instanceof gnuDynEnum)
+ {
+ gnuDynEnum oe = (gnuDynEnum) other;
+ return current == oe.current &&
+ (oe.values == values || Arrays.equals(values, oe.values));
+ }
+ else if (other instanceof DynEnum)
+ {
+ DynEnum oe = (DynEnum) other;
+ return current == oe.get_as_ulong() && official_type.equal(oe.type());
+ }
+ else
+ return false;
+ }
+
+ /**
+ * Set value from any that must contain enumeration.
+ */
+ public void from_any(Any an_any) throws TypeMismatch, InvalidValue
+ {
+ checkType(official_type, an_any.type());
+ try
+ {
+ InputStream in = an_any.create_input_stream();
+ set_as_ulong(in.read_long());
+ in.close();
+ }
+ catch (MARSHAL eof)
+ {
+ throw new InvalidValue();
+ }
+ catch (IOException ex)
+ {
+ throw new Unexpected(ex);
+ }
+ }
+
+ /**
+ * Get the value of this enumeration as string.
+ */
+ public String get_as_string()
+ {
+ return values [ current ];
+ }
+
+ /**
+ * Get the value of this enumeration as int.
+ */
+ public int get_as_ulong()
+ {
+ return current;
+ }
+
+ /**
+ * Set the value of this enumeration as string.
+ */
+ public void set_as_string(String value) throws InvalidValue
+ {
+ for (int i = 0; i < values.length; i++)
+ {
+ if (values [ i ].equals(value))
+ {
+ current = i;
+ valueChanged();
+ return;
+ }
+ }
+ throw new InvalidValue(value);
+ }
+
+ /**
+ * Set the value of this enumeration as int.
+ */
+ public void set_as_ulong(int value) throws InvalidValue
+ {
+ if (value < 0 || value >= values.length)
+ throw new InvalidValue(value + " not in [0.." + values.length);
+ else
+ {
+ current = value;
+ valueChanged();
+ }
+ }
+
+ /**
+ * Wrap the enumeration value into any.
+ */
+ public Any to_any()
+ {
+ Any a = createAny();
+ a.insert_long(current);
+ a.type(official_type);
+ return a;
+ }
+}
\ No newline at end of file
--- /dev/null
+/* gnuDynFixed.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., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 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.DynAn;
+
+import org.omg.CORBA.Any;
+import org.omg.CORBA.BAD_OPERATION;
+import org.omg.CORBA.BAD_PARAM;
+import org.omg.CORBA.ORB;
+import org.omg.CORBA.TypeCode;
+import org.omg.DynamicAny.DynAny;
+import org.omg.DynamicAny.DynAnyPackage.InvalidValue;
+import org.omg.DynamicAny.DynAnyPackage.TypeMismatch;
+import org.omg.DynamicAny.DynFixed;
+import org.omg.DynamicAny.DynFixedOperations;
+
+import java.math.BigDecimal;
+
+/**
+ * Implements DynAny, holding CORBA <code>fixed</code>. This class is derived
+ * from gnuDynEnm to avoid repetetive inclusion of unused DynAny methods.
+ *
+ * @author Audrius Meskauskas, Lithuania (AudriusA@Bioinformatics.org)
+ */
+public class gnuDynFixed extends anyUndivideable implements DynFixed
+{
+ /**
+ * Use serialVersionUID for interoperability.
+ */
+ private static final long serialVersionUID = 1;
+
+ /**
+ * The default value, assigned in the new instance.
+ */
+ static final BigDecimal ZERO = new BigDecimal("0.0");
+
+ /**
+ * The content of the dyn fixed, wrapped in this DynAny.
+ */
+ BigDecimal value;
+
+ /**
+ * The number of digits after the decimal point.
+ */
+ final int scale;
+
+ /**
+ * The number of digits.
+ */
+ final int digits;
+
+ /**
+ * Create a new instance of the dyn fixed.
+ */
+ public gnuDynFixed(TypeCode oType, TypeCode aType,
+ gnuDynAnyFactory aFactory, ORB anOrb
+ )
+ {
+ super(oType, aType, aFactory, anOrb);
+ try
+ {
+ digits = final_type.fixed_digits();
+ scale = final_type.fixed_scale();
+ }
+ catch (Exception e)
+ {
+ throw new BAD_PARAM("Not a fixed");
+ }
+ value = ZERO;
+ }
+
+ /**
+ * Clone the current instance.
+ */
+ public gnuDynFixed(gnuDynFixed from)
+ {
+ super(from.official_type, from.final_type, from.factory, from.orb);
+ digits = from.digits;
+ scale = from.scale;
+ value = from.value;
+ }
+
+ /**
+ * Get the value of the wrapped dyn fixed, as string.
+ */
+ public String get_value()
+ {
+ return value.toString();
+ }
+
+ /**
+ * Set the value.
+ */
+ public boolean set_value(String fixed_value)
+ throws TypeMismatch, InvalidValue
+ {
+ // Count the digits till decimal point.
+ int digs = 0;
+ char c;
+ boolean leading0 = true;
+ Digs:
+ for (int i = 0; i < fixed_value.length(); i++)
+ {
+ c = fixed_value.charAt(i);
+ if (Character.isDigit(c))
+ {
+ if (!(c == '0' && leading0))
+ digs++;
+ if (c != '0')
+ leading0 = false;
+ }
+ else if (c == '.')
+ break Digs;
+ }
+ if (digs > (digits - scale))
+ throw new InvalidValue("Too many digits: " + digs + " for " + digits +
+ "." + scale
+ );
+
+ try
+ {
+ value = new BigDecimal(fixed_value);
+ }
+ catch (NumberFormatException ex)
+ {
+ if (fixed_value.trim().length() == 0)
+ throw new InvalidValue("Empty string passed");
+
+ TypeMismatch inva =
+ new TypeMismatch("Not a number: '" + fixed_value + "'");
+ inva.initCause(ex);
+ throw inva;
+ }
+
+ valueChanged();
+ return value.scale() <= scale;
+ }
+
+ /**
+ * Assign the value from another BigDecimal.
+ */
+ public void assign(DynAny from) throws TypeMismatch
+ {
+ checkType(official_type, from.type());
+
+ if (from instanceof gnuDynFixed)
+ {
+ gnuDynFixed other = (gnuDynFixed) from;
+ value = other.value;
+ }
+ else if (from instanceof DynFixedOperations)
+ {
+ value = new BigDecimal(((DynFixedOperations) from).get_value());
+ }
+ else
+ throw new TypeMismatch("Not a DynFixed");
+ valueChanged();
+ }
+
+ /**
+ * Create a copy.
+ */
+ public DynAny copy()
+ {
+ return new gnuDynFixed(this);
+ }
+
+ /**
+ * Compare for equality.
+ */
+ public boolean equal(DynAny other)
+ {
+ if (other instanceof gnuDynFixed)
+ {
+ // Normally, this code would be executed.
+ return value.equals(((gnuDynFixed) other).value);
+ }
+ if (other instanceof DynFixedOperations)
+ {
+ // This may be involved when mixing implementations.
+ return ((DynFixedOperations) other).get_value().equals(get_value());
+ }
+ else
+ return false;
+ }
+
+ /**
+ * Set the value from Any (must hold <code>fixed</code> with the matching
+ * typecode.).
+ */
+ public void from_any(Any an_any) throws TypeMismatch, InvalidValue
+ {
+ try
+ {
+ checkType(official_type, an_any.type());
+
+ value = an_any.extract_fixed();
+ valueChanged();
+ }
+ catch (BAD_OPERATION e)
+ {
+ InvalidValue t = new InvalidValue();
+ t.initCause(e);
+ throw t;
+ }
+ }
+
+ /**
+ * Create and return Any, holding this DynFixed value.
+ */
+ public Any to_any()
+ {
+ Any g = createAny();
+ g.insert_fixed(value, official_type);
+ return g;
+ }
+}
\ No newline at end of file
--- /dev/null
+/* gnuDynSequence.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., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 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.DynAn;
+
+import gnu.CORBA.Unexpected;
+
+import org.omg.CORBA.Any;
+import org.omg.CORBA.BAD_PARAM;
+import org.omg.CORBA.ORB;
+import org.omg.CORBA.TypeCode;
+import org.omg.CORBA.TypeCodePackage.BadKind;
+import org.omg.DynamicAny.DynAny;
+import org.omg.DynamicAny.DynAnyFactoryPackage.InconsistentTypeCode;
+import org.omg.DynamicAny.DynAnyPackage.InvalidValue;
+import org.omg.DynamicAny.DynAnyPackage.TypeMismatch;
+import org.omg.DynamicAny.DynSequence;
+
+import java.io.Serializable;
+
+import java.lang.reflect.*;
+
+public class gnuDynSequence
+ extends gnuDynArray
+ implements DynSequence, Serializable
+{
+ /**
+ * Use serialVersionUID for interoperability.
+ */
+ private static final long serialVersionUID = 1;
+
+ /**
+ * The bound of the sequence, as defined in typecode.
+ */
+ final int bound;
+
+ /**
+ * Create a new gnuDynSequence with the given typecode.
+ *
+ * @throws BAD_PARAM if the passed typecode is probably not a sequence
+ * typecode.
+ */
+ public gnuDynSequence(TypeCode oType, TypeCode aType,
+ gnuDynAnyFactory aFactory, ORB anOrb
+ )
+ throws BAD_PARAM
+ {
+ super(oType, aType, aFactory, anOrb, false);
+ array = new DynAny[ 0 ];
+ try
+ {
+ bound = final_type.length();
+ }
+ catch (BadKind ex)
+ {
+ throw new Unexpected(ex);
+ }
+ }
+
+ /**
+ * Get the length of the sequence.
+ */
+ public int get_length()
+ {
+ return array.length;
+ }
+
+ /**
+ * Resize the sequence, preserving components.
+ */
+ public void set_length(int length)
+ throws InvalidValue
+ {
+ checkBound(length);
+ if (length == array.length)
+ return; // Nothing to do.
+ else if (length < array.length)
+ {
+ // Truncate.
+ DynAny[] d = new DynAny[ length ];
+ for (int i = 0; i < d.length; i++)
+ d [ i ] = array [ i ];
+ array = d;
+ }
+ else
+ {
+ // Expand.
+ DynAny[] d = new DynAny[ length ];
+ for (int i = 0; i < array.length; i++)
+ d [ i ] = array [ i ];
+
+ for (int i = array.length; i < d.length; i++)
+ {
+ try
+ {
+ d [ i ] =
+ factory.create_dyn_any_from_type_code(official_components);
+ }
+ catch (InconsistentTypeCode e)
+ {
+ throw new Unexpected(e);
+ }
+ }
+ array = d;
+ }
+ valueChanged();
+ }
+
+ /**
+ * Copy one DynAny into another.
+ */
+ public void assign(DynAny from)
+ throws TypeMismatch
+ {
+ checkType(official_type, from.type());
+ if (from instanceof DynSequence)
+ {
+ DynSequence dyn = (DynSequence) from;
+ array = dyn.get_elements_as_dyn_any();
+ }
+ else
+ throw new TypeMismatch();
+ }
+
+ /*
+ * Set the contenst of the sequence, resizing if required.
+ */
+ public void set_elements_as_dyn_any(DynAny[] value)
+ throws InvalidValue, TypeMismatch
+ {
+ checkBound(value.length);
+ if (array.length != value.length)
+ set_length(value.length);
+
+ for (int i = 0; i < value.length; i++)
+ {
+ checkType(official_components, value [ i ].type());
+ array [ i ].assign(value [ i ]);
+ }
+ valueChanged();
+ }
+
+ /**
+ * Set the elements from array of Any's.
+ */
+ public void set_elements(Any[] value)
+ throws InvalidValue, TypeMismatch
+ {
+ checkBound(value.length);
+
+ DynAny[] prev = array;
+
+ array = new DynAny[ value.length ];
+ try
+ {
+ super.set_elements(value);
+
+ // valueChanged() is called in super.set_elements(value).
+ }
+
+ // On the problem, value does not change.
+ catch (TypeMismatch ex)
+ {
+ array = prev;
+ throw ex;
+ }
+ catch (InvalidValue ex)
+ {
+ array = prev;
+ throw ex;
+ }
+ catch (RuntimeException rex)
+ {
+ array = prev;
+ throw rex;
+ }
+ }
+
+ /**
+ * Create a copy.
+ */
+ public DynAny copy()
+ {
+ DynAny[] c = new DynAny[ array.length ];
+ for (int i = 0; i < c.length; i++)
+ {
+ c [ i ] = array [ i ].copy();
+ }
+
+ gnuDynSequence d =
+ new gnuDynSequence(official_type, final_type, factory, orb);
+ d.array = c;
+ return d;
+ }
+
+ /**
+ * Check the bound.
+ *
+ * @param x the value to check.
+ */
+ void checkBound(int x)
+ throws InvalidValue
+ {
+ if (bound != 0)
+ if (x < 0 || x > bound)
+ throw new InvalidValue(x + " out of bounds, valid [0.." + bound + "]");
+ }
+
+ /**
+ * Check if array size is valid. Called from from_any.
+ */
+ protected void checkArrayValid(Object members)
+ throws TypeMismatch, InvalidValue
+ {
+ checkBound(Array.getLength(members));
+ if (get_length() != Array.getLength(members))
+ set_length(Array.getLength(members));
+ }
+}
\ No newline at end of file
--- /dev/null
+/* gnuDynStruct.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., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 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.DynAn;
+
+import java.io.Serializable;
+
+import org.omg.CORBA.ORB;
+import org.omg.CORBA.TypeCode;
+import org.omg.DynamicAny.DynStruct;
+import org.omg.DynamicAny.NameDynAnyPair;
+import org.omg.DynamicAny.NameValuePair;
+import gnu.CORBA.Unexpected;
+import org.omg.DynamicAny.DynAny;
+
+/**
+ * Implementation of the DynStruct.
+ *
+ * @author Audrius Meskauskas, Lithuania (AudriusA@Bioinformatics.org)
+ */
+public class gnuDynStruct
+ extends abstractRecord
+ implements DynStruct, Serializable
+{
+ /**
+ * Use serialVersionUID for interoperability.
+ */
+ private static final long serialVersionUID = 1;
+
+ /**
+ * Create an instance.
+ */
+ public gnuDynStruct(TypeCode oType, TypeCode aType,
+ gnuDynAnyFactory aFactory, ORB anOrb)
+ {
+ super(oType, aType, aFactory, anOrb);
+
+ // Initialise fields.
+ try
+ {
+ array = new DynAny[ final_type.member_count() ];
+ fNames = new String[ array.length ];
+ for (int i = 0; i < array.length; i++)
+ {
+ array [ i ] =
+ factory.create_dyn_any_from_type_code(final_type.member_type(i));
+ fNames [ i ] = final_type.member_name(i);
+ }
+ }
+ catch (Exception e)
+ {
+ throw new Unexpected(e);
+ }
+ }
+
+ /** @inheritDoc */
+ protected abstractRecord newInstance(TypeCode oType, TypeCode aType,
+ gnuDynAnyFactory aFactory, ORB anOrb)
+ {
+ return new gnuDynStruct(oType, aType, aFactory, anOrb);
+ }
+
+ /** @inheritDoc */
+ public NameDynAnyPair[] get_members_as_dyn_any()
+ {
+ return super.gnu_get_members_as_dyn_any();
+ }
+
+ /** @inheritDoc */
+ public NameValuePair[] get_members()
+ {
+ return super.gnu_get_members();
+ }
+}
--- /dev/null
+/* gnuDynUnion.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., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 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.DynAn;
+
+import gnu.CORBA.Unexpected;
+
+import org.omg.CORBA.Any;
+import org.omg.CORBA.MARSHAL;
+import org.omg.CORBA.ORB;
+import org.omg.CORBA.TCKind;
+import org.omg.CORBA.TypeCode;
+import org.omg.CORBA.TypeCodePackage.BadKind;
+import org.omg.CORBA.portable.InputStream;
+import org.omg.CORBA.portable.OutputStream;
+import org.omg.DynamicAny.DynAny;
+import org.omg.DynamicAny.DynAnyFactoryPackage.InconsistentTypeCode;
+import org.omg.DynamicAny.DynAnyPackage.InvalidValue;
+import org.omg.DynamicAny.DynAnyPackage.TypeMismatch;
+import org.omg.DynamicAny.DynUnion;
+
+import java.io.Serializable;
+
+/**
+ * Implementation of DynUnion.
+ *
+ * @author Audrius Meskauskas, Lithuania (AudriusA@Bioinformatics.org)
+ */
+public class gnuDynUnion
+ extends anyDivideable
+ implements DynUnion, Serializable, valueChangedListener
+{
+ /**
+ * Use serialVersionUID for interoperability.
+ */
+ private static final long serialVersionUID = 1;
+
+ /**
+ * The discrimintor of this union.
+ */
+ DynAny discriminator;
+
+ /**
+ * The message string that occurs several times throwing exception.
+ */
+ static String NOAM = "No active member";
+
+ /**
+ * Create a new instance with the given typecode.
+ *
+ * @param aType the final_type, must be final_type of the union.
+ */
+ public gnuDynUnion(TypeCode oType, TypeCode aType, gnuDynAnyFactory aFactory,
+ ORB anOrb
+ )
+ throws InconsistentTypeCode
+ {
+ super(oType, aType, aFactory, anOrb);
+ try
+ {
+ discriminator =
+ factory.create_dyn_any_from_type_code(final_type.discriminator_type());
+
+ ((abstractDynAny) discriminator).listener = this;
+
+ if (final_type.default_index() >= 0)
+ set_to_default_member();
+ else
+ set_to_no_active_member();
+ }
+ catch (Exception ex)
+ {
+ InconsistentTypeCode inc = new InconsistentTypeCode("discriminator");
+ inc.initCause(ex);
+ throw inc;
+ }
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see gnu.CORBA.DynAn.anyDivideable#to_any()
+ */
+ public Any to_any()
+ {
+ Any a = createAny();
+ OutputStream ou = a.create_output_stream();
+ discriminator.to_any().write_value(ou);
+ if (array.length == 2)
+ array [ 1 ].to_any().write_value(ou);
+ a.read_value(ou.create_input_stream(), final_type);
+ return a;
+ }
+
+ /**
+ * Assign from another identical structure.
+ */
+ public void assign(DynAny from)
+ throws TypeMismatch
+ {
+ checkType(official_type, from.type());
+ if (!(from instanceof DynUnion))
+ throw new TypeMismatch("DynUnion required");
+ else
+ {
+ try
+ {
+ DynUnion u = (DynUnion) from;
+ discriminator.assign(u.get_discriminator());
+ if (u.has_no_active_member())
+ {
+ if (array.length != 1)
+ array = new DynAny[] { discriminator };
+ }
+ else
+ {
+ if (array.length != 2)
+ array = new DynAny[] { discriminator, u.member().copy() };
+ else
+ array [ 1 ] = u.member().copy();
+ }
+ }
+ catch (InvalidValue e)
+ {
+ throw new Unexpected(e);
+ }
+ }
+ valueChanged();
+ }
+
+ /** @inheritDoc */
+ public DynAny copy()
+ {
+ try
+ {
+ gnuDynUnion other =
+ new gnuDynUnion(official_type, final_type, factory, orb);
+ other.discriminator = discriminator.copy();
+ ((abstractDynAny) other.discriminator).listener = other;
+ if (array.length == 1)
+ {
+ other.array = new DynAny[] { other.discriminator };
+ }
+ else
+ {
+ other.array =
+ new DynAny[] { other.discriminator, array [ 1 ].copy() };
+ }
+ return other;
+ }
+ catch (InconsistentTypeCode ex)
+ {
+ throw new Unexpected(ex);
+ }
+ }
+
+ /**
+ * Done via reading from stream.
+ */
+ public void from_any(Any an_any)
+ throws TypeMismatch, InvalidValue
+ {
+ checkType(official_type, an_any.type());
+
+ Any adis = createAny();
+ try
+ {
+ InputStream stream = an_any.create_input_stream();
+ adis.read_value(stream, final_type.discriminator_type());
+
+ DynAny nd = factory.create_dyn_any(adis);
+
+ set_discriminator(nd);
+ if (array.length == 2)
+ {
+ // Reusing the same Any <code>adis</code>.
+ adis.read_value(stream, array [ 1 ].type());
+ array [ 1 ].from_any(adis);
+ }
+ }
+ catch (InconsistentTypeCode it)
+ {
+ TypeMismatch t = new TypeMismatch();
+ t.initCause(it);
+ throw t;
+ }
+ catch (MARSHAL m)
+ {
+ InvalidValue t = new InvalidValue();
+ t.initCause(m);
+ throw t;
+ }
+ catch (BadKind b)
+ {
+ throw new Unexpected(b);
+ }
+ valueChanged();
+ }
+
+ /** @inheritDoc */
+ public TCKind discriminator_kind()
+ {
+ return discriminator.type().kind();
+ }
+
+ /** @inheritDoc */
+ public DynAny get_discriminator()
+ {
+ return discriminator;
+ }
+
+ /** @inheritDoc */
+ public boolean has_no_active_member()
+ {
+ return array.length == 1;
+ }
+
+ /** @inheritDoc */
+ public TCKind member_kind()
+ throws InvalidValue
+ {
+ return member().type().kind();
+ }
+
+ /**
+ * Get the name of the current variant of the union.
+ */
+ public String member_name()
+ throws InvalidValue
+ {
+ if (array.length == 1)
+ throw new InvalidValue(NOAM);
+ try
+ {
+ Any da = discriminator.to_any();
+
+
+ // Get the discriminator variant.
+ Variants:
+ for (int i = 0; i < final_type.member_count(); i++)
+ {
+ if (final_type.member_label(i).equal(da))
+ return final_type.member_name(i);
+ }
+ throw new InvalidValue(NOAM);
+ }
+ catch (Exception e)
+ {
+ InvalidValue t = new InvalidValue("Err");
+ t.initCause(e);
+ throw t;
+ }
+ }
+
+ /** @inheritDoc */
+ public DynAny member()
+ throws InvalidValue
+ {
+ if (array.length < 2)
+ throw new InvalidValue(NOAM);
+ else
+ return array [ 1 ];
+ }
+
+ /**
+ * Set the union discriminator.
+ */
+ public void set_discriminator(DynAny aDiscriminator)
+ throws TypeMismatch
+ {
+ try
+ {
+ if (!aDiscriminator.type().equal(final_type.discriminator_type()))
+ throw new TypeMismatch("Wrong discriminator final_type for " +
+ final_type.name()
+ );
+
+ // Seting the same discriminator value again should not change
+ // the fields of the current member.
+ if (!discriminator.equal(aDiscriminator))
+ {
+ discriminator.assign(aDiscriminator);
+ updateMember();
+ }
+ else
+ {
+ pos = array.length == 2 ? 1 : 0;
+ }
+ }
+ catch (Exception e)
+ {
+ TypeMismatch t = new TypeMismatch();
+ t.initCause(e);
+ throw t;
+ }
+ }
+
+ /**
+ * Set to default member, if one exists.
+ */
+ public void set_to_default_member()
+ throws TypeMismatch
+ {
+ try
+ {
+ int di = final_type.default_index();
+ if (di < 0)
+ throw new TypeMismatch("Union " + final_type.name() +
+ "has no default index"
+ );
+
+ Any da = final_type.member_label(di);
+ discriminator.from_any(da);
+ updateMember();
+ }
+ catch (TypeMismatch m)
+ {
+ // This one OK.
+ throw m;
+ }
+ catch (Exception e)
+ {
+ TypeMismatch t = new TypeMismatch();
+ t.initCause(e);
+ throw t;
+ }
+ }
+
+ /** @inheritDoc */
+ public void set_to_no_active_member()
+ throws TypeMismatch
+ {
+ try
+ {
+ if (final_type.default_index() >= 0)
+ {
+ throw new TypeMismatch("Explicit default case defined.");
+ }
+ }
+ catch (BadKind ex)
+ {
+ // The default index is not set.
+ }
+ array = new DynAny[] { discriminator };
+ valueChanged();
+ }
+
+ /**
+ * Update member, in accordance with discriminator value.
+ */
+ public void updateMember()
+ throws TypeMismatch
+ {
+ try
+ {
+ Any da = discriminator.to_any();
+
+
+ // Get the discriminator variant.
+ Variants:
+ for (int i = 0; i < final_type.member_count(); i++)
+ {
+ if (final_type.member_label(i).equal(da))
+ {
+ array =
+ new DynAny[]
+ {
+ discriminator,
+ factory.create_dyn_any_from_type_code(final_type.member_type(i))
+ };
+ pos = 1;
+ valueChanged();
+ return;
+ }
+ }
+ }
+ catch (Exception e)
+ {
+ TypeMismatch t = new TypeMismatch();
+ t.initCause(e);
+ throw t;
+ }
+
+ // Discrimintator does not point to valid member.
+ array = new DynAny[] { discriminator };
+ pos = 0;
+ valueChanged();
+ }
+
+ /**
+ * Called when the discriminator is changed.
+ */
+ public void changed()
+ {
+ try
+ {
+ updateMember();
+ }
+ catch (TypeMismatch ex)
+ {
+ throw new Unexpected(ex);
+ }
+ }
+}
\ No newline at end of file
--- /dev/null
+/* gnuDynValue.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., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 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.DynAn;
+
+import gnu.CORBA.Unexpected;
+
+import org.omg.CORBA.Any;
+import org.omg.CORBA.BAD_PARAM;
+import org.omg.CORBA.MARSHAL;
+import org.omg.CORBA.ORB;
+import org.omg.CORBA.TCKind;
+import org.omg.CORBA.TypeCode;
+import org.omg.CORBA.VM_TRUNCATABLE;
+import org.omg.CORBA.portable.OutputStream;
+import org.omg.CORBA.portable.ValueFactory;
+import org.omg.DynamicAny.DynAny;
+import org.omg.DynamicAny.DynAnyPackage.InvalidValue;
+import org.omg.DynamicAny.DynAnyPackage.TypeMismatch;
+import org.omg.DynamicAny.DynStruct;
+import org.omg.DynamicAny.DynValue;
+import org.omg.DynamicAny.DynValueCommon;
+import org.omg.DynamicAny.DynValueOperations;
+import org.omg.DynamicAny.NameDynAnyPair;
+import org.omg.DynamicAny.NameValuePair;
+
+import java.io.Serializable;
+
+/**
+ * Implementation of DynValue.
+ *
+ * @author Audrius Meskauskas, Lithuania (AudriusA@Bioinformatics.org)
+ */
+public class gnuDynValue extends abstractRecord implements DynValue,
+ Serializable
+{
+ /**
+ * Use serialVersionUID for interoperability.
+ */
+ private static final long serialVersionUID = 1;
+
+ /**
+ * If true, the value of this ValueType is set to null.
+ */
+ boolean isNull;
+
+ /**
+ * Create an instance.
+ */
+ public gnuDynValue(TypeCode oType, TypeCode aType,
+ gnuDynAnyFactory aFactory, ORB anOrb
+ )
+ {
+ super(oType, aType, aFactory, anOrb);
+
+ // Initialise fields. The array of fields also includes all inherited
+ // fields.
+ try
+ {
+ array = new DynAny[ final_type.member_count() ];
+ fNames = new String[ array.length ];
+ for (int i = 0; i < array.length; i++)
+ {
+ array [ i ] =
+ factory.create_dyn_any_from_type_code(final_type.member_type(i));
+ fNames [ i ] = final_type.member_name(i);
+ }
+
+ // Search of inherited members.
+ if (final_type.type_modifier() == VM_TRUNCATABLE.value)
+ {
+ TypeCode parent = final_type.concrete_base_type();
+ DynAny ancestor = factory.create_dyn_any_from_type_code(parent);
+
+ if (ancestor instanceof DynValue)
+ {
+ // Add members of ancestor in front of the curren members.
+ DynValue anc = (DynValue) ancestor;
+ anc.set_to_value();
+
+ NameDynAnyPair[] aar = anc.get_members_as_dyn_any();
+ inheritFields(aar);
+ }
+ else if (ancestor instanceof DynStruct)
+ {
+ // Add members of ancestor in front of the curren members.
+ DynStruct anc = (DynStruct) ancestor;
+ NameDynAnyPair[] aar = anc.get_members_as_dyn_any();
+ inheritFields(aar);
+ }
+ else
+ throw new BAD_PARAM("The parent of " + final_type.id() + ", " +
+ parent.id() + ", is not structure nor value."
+ );
+ }
+ }
+ catch (Exception e)
+ {
+ throw new Unexpected(e);
+ }
+
+ set_to_null();
+ }
+
+ /**
+ * Inherit the provided fields.
+ */
+ private void inheritFields(NameDynAnyPair[] aar)
+ {
+ DynAny[] nArray = new DynAny[ array.length + aar.length ];
+ String[] nNames = new String[ array.length + aar.length ];
+ int p = 0;
+ for (int i = 0; i < aar.length; i++)
+ {
+ nArray [ p ] = aar [ i ].value;
+ nNames [ p ] = aar [ i ].id;
+ p++;
+ }
+
+ for (int i = 0; i < array.length; i++)
+ {
+ nArray [ p ] = array [ i ];
+ nNames [ p ] = fNames [ i ];
+ p++;
+ }
+
+ array = nArray;
+ fNames = nNames;
+ }
+
+ /** @inheritDoc */
+ public TCKind current_member_kind() throws TypeMismatch, InvalidValue
+ {
+ if (isNull)
+ throw new TypeMismatch(ISNULL);
+ else
+ return super.current_member_kind();
+ }
+ ;
+
+ /** @inheritDoc */
+ public String current_member_name() throws TypeMismatch, InvalidValue
+ {
+ if (isNull)
+ throw new TypeMismatch(ISNULL);
+ else
+ return super.current_member_name();
+ }
+ ;
+
+ /** @inheritDoc */
+ public NameDynAnyPair[] get_members_as_dyn_any() throws InvalidValue
+ {
+ if (isNull)
+ throw new InvalidValue(ISNULL);
+ return super.gnu_get_members_as_dyn_any();
+ }
+ ;
+
+ /** @inheritDoc */
+ public NameValuePair[] get_members() throws InvalidValue
+ {
+ if (isNull)
+ throw new InvalidValue(ISNULL);
+ else
+ return super.gnu_get_members();
+ }
+ ;
+
+ /** @inheritDoc */
+ public void set_members_as_dyn_any(NameDynAnyPair[] value)
+ throws TypeMismatch, InvalidValue
+ {
+ super.set_members_as_dyn_any(value);
+ isNull = false;
+ }
+ ;
+
+ /** @inheritDoc */
+ public void set_members(NameValuePair[] value)
+ throws TypeMismatch, InvalidValue
+ {
+ super.set_members(value);
+ isNull = false;
+ }
+ ;
+
+ /** @inheritDoc */
+ public boolean is_null()
+ {
+ return isNull;
+ }
+
+ /** @inheritDoc */
+ public void set_to_null()
+ {
+ isNull = true;
+ valueChanged();
+ }
+
+ /** @inheritDoc */
+ public void set_to_value()
+ {
+ isNull = false;
+ valueChanged();
+ }
+
+ /**
+ * Create a new instance.
+ */
+ protected abstractRecord newInstance(TypeCode oType, TypeCode aType,
+ gnuDynAnyFactory aFactory, ORB anOrb
+ )
+ {
+ gnuDynValue v = new gnuDynValue(oType, aType, aFactory, anOrb);
+ if (isNull)
+ v.set_to_null();
+ else
+ v.set_to_value();
+ return v;
+ }
+
+ /**
+ * Compare for equality, minding null values.
+ */
+ public boolean equal(DynAny other)
+ {
+ if (other instanceof DynValueOperations)
+ {
+ DynValueCommon o = (DynValueCommon) other;
+ if (isNull)
+ return o.is_null() && o.type().equal(official_type);
+ else
+ return !o.is_null() && super.equal(other);
+ }
+ else
+ return false;
+ }
+
+ /**
+ * Get the focused component, throwing exception if the current value is null.
+ */
+ protected DynAny focused() throws InvalidValue, TypeMismatch
+ {
+ if (isNull)
+ throw new TypeMismatch(ISNULL);
+ else
+ return super.focused();
+ }
+
+ /**
+ * Convert into Any.
+ */
+ public Any to_any()
+ {
+ if (isNull)
+ {
+ Any a0 = createAny();
+ a0.type(orb.get_primitive_tc(TCKind.tk_null));
+ return a0;
+ }
+ else
+ {
+ try
+ {
+ ValueFactory factory =
+ ((org.omg.CORBA_2_3.ORB) orb).lookup_value_factory(official_type.id());
+ if (factory == null)
+ throw new MARSHAL("Factory for " + official_type.id() +
+ " not registered."
+ );
+
+ OutputStream out = orb.create_output_stream();
+
+ for (int i = 0; i < array.length; i++)
+ array [ i ].to_any().write_value(out);
+
+ org.omg.CORBA_2_3.portable.InputStream in =
+ (org.omg.CORBA_2_3.portable.InputStream) out.create_input_stream();
+ Serializable v = factory.read_value(in);
+
+ Any g = createAny();
+ g.type(official_type);
+ g.insert_Value(v, official_type);
+
+ return g;
+ }
+ catch (Exception e)
+ {
+ throw new Unexpected(e);
+ }
+ }
+ }
+
+ /** @inheritDoc */
+ public void assign(DynAny from) throws TypeMismatch
+ {
+ checkType(official_type, from.type());
+
+ if (from instanceof DynValue)
+ {
+ DynValue other = (DynValue) from;
+ if (other.is_null())
+ set_to_null();
+ else
+ {
+ set_to_value();
+ try
+ {
+ DynValueOperations src = (DynValueOperations) from;
+ set_members_as_dyn_any(src.get_members_as_dyn_any());
+ }
+ catch (InvalidValue e)
+ {
+ TypeMismatch t = new TypeMismatch("Invalid value");
+ t.initCause(e);
+ throw t;
+ }
+ }
+ }
+ else
+ throw new TypeMismatch("Not a DynValue");
+ }
+
+ /**
+ * Get the number of components.
+ */
+ public int component_count()
+ {
+ return isNull ? 0 : super.component_count();
+ }
+
+ /** {@inheritDoc} */
+ public Serializable get_val() throws TypeMismatch, InvalidValue
+ {
+ return to_any().extract_Value();
+ }
+
+ /** {@inheritDoc} */
+ public void insert_val(Serializable a_x) throws InvalidValue, TypeMismatch
+ {
+ Any a = to_any();
+ a.insert_Value(a_x);
+ from_any(a);
+ valueChanged();
+ }
+}
\ No newline at end of file
--- /dev/null
+/* gnuDynValueBox.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., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 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.DynAn;
+
+import gnu.CORBA.Unexpected;
+import gnu.CORBA.holderFactory;
+
+import org.omg.CORBA.Any;
+import org.omg.CORBA.ORB;
+import org.omg.CORBA.TCKind;
+import org.omg.CORBA.TypeCode;
+import org.omg.CORBA.TypeCodePackage.BadKind;
+import org.omg.CORBA.portable.Streamable;
+import org.omg.DynamicAny.DynAny;
+import org.omg.DynamicAny.DynAnyFactoryPackage.InconsistentTypeCode;
+import org.omg.DynamicAny.DynAnyPackage.InvalidValue;
+import org.omg.DynamicAny.DynAnyPackage.TypeMismatch;
+import org.omg.DynamicAny.DynValueBox;
+import org.omg.DynamicAny.DynValueBoxOperations;
+import org.omg.DynamicAny.DynValueCommon;
+
+import java.io.Serializable;
+
+import java.lang.reflect.Field;
+
+/**
+ * Implementation of the DynValueBox.
+ *
+ * @author Audrius Meskauskas, Lithuania (AudriusA@Bioinformatics.org)
+ */
+public class gnuDynValueBox
+ extends anyDivideable
+ implements DynValueBox, Serializable
+{
+ /**
+ * Use serialVersionUID for interoperability.
+ */
+ private static final long serialVersionUID = 1;
+
+ /**
+ * The final_type of contents of this value box.
+ */
+ final TypeCode content;
+
+ /**
+ * The string for some TypeMismatch exceptions.
+ */
+ String CONTENT = "Box content final_type mismatch";
+
+ /**
+ * Create a new instance of gnuDynValueBox.
+ */
+ public gnuDynValueBox(TypeCode oType, TypeCode aType,
+ gnuDynAnyFactory aFactory, ORB anOrb
+ )
+ {
+ super(oType, aType, aFactory, anOrb);
+ try
+ {
+ content = final_type.content_type();
+ array = new DynAny[] { factory.create_dyn_any_from_type_code(content) };
+ set_to_null();
+ }
+ catch (Exception e)
+ {
+ throw new Unexpected(e);
+ }
+ }
+
+ /** @inheritDoc */
+ public void assign(DynAny from)
+ throws TypeMismatch
+ {
+ checkType(official_type, from.type());
+ if (from instanceof DynValueBoxOperations)
+ {
+ DynValueBoxOperations other = (DynValueBoxOperations) from;
+ if (other.is_null())
+ set_to_null();
+ else
+ {
+ DynAny inBox;
+ try
+ {
+ inBox = other.get_boxed_value_as_dyn_any();
+ }
+ catch (InvalidValue e)
+ {
+ TypeMismatch t = new TypeMismatch("Invalid value");
+ t.initCause(e);
+ throw t;
+ }
+ if (!content.equal(inBox.type()))
+ throw new TypeMismatch(CONTENT);
+ array = new DynAny[] { inBox.copy() };
+ }
+ }
+ valueChanged();
+ }
+
+ /** @inheritDoc */
+ public DynAny copy()
+ {
+ gnuDynValueBox other =
+ new gnuDynValueBox(official_type, final_type, factory, orb);
+ if (is_null())
+ other.set_to_null();
+ else
+ {
+ try
+ {
+ other.array = new DynAny[] { array [ 0 ].copy() };
+ }
+ catch (Exception e)
+ {
+ throw new Unexpected(e);
+ }
+ }
+ return other;
+ }
+
+ /**
+ * Returns null for null value, delegates to super. otherwise.
+ */
+ public DynAny current_component()
+ throws TypeMismatch
+ {
+ if (is_null())
+ return null;
+ else
+ return super.current_component();
+ }
+
+ /**
+ * Compare for equality, minding null values.
+ */
+ public boolean equal(DynAny other)
+ {
+ if (other instanceof DynValueCommon)
+ {
+ DynValueCommon o = (DynValueCommon) other;
+ if (is_null())
+ return o.is_null() && o.type().equal(official_type);
+ else
+ return !o.is_null() && super.equal(other);
+ }
+ else
+ return false;
+ }
+
+ /** @inheritDoc */
+ public void from_any(Any an_any)
+ throws TypeMismatch, InvalidValue
+ {
+ checkType(official_type, an_any.type());
+ try
+ {
+ if (!an_any.type().content_type().equal(content))
+ throw new InvalidValue(CONTENT);
+ }
+ catch (BadKind e)
+ {
+ TypeMismatch t = new TypeMismatch("Not a box");
+ t.initCause(e);
+ throw t;
+ }
+
+ Serializable s = an_any.extract_Value();
+ if (s == null)
+ set_to_null();
+ else
+ {
+ try
+ {
+ Streamable holder = holderFactory.createHolder(content);
+ Field v = holder.getClass().getField("value");
+ v.set(holder, s);
+
+ Any cont = createAny();
+ cont.insert_Streamable(holder);
+
+ array = new DynAny[] { factory.create_dyn_any(cont) };
+ }
+ catch (Exception ex)
+ {
+ throw new Unexpected(ex);
+ }
+ }
+ valueChanged();
+ }
+
+ /** @inheritDoc */
+ public Any get_boxed_value()
+ throws InvalidValue
+ {
+ try
+ {
+ if (is_null())
+ throw new InvalidValue(ISNULL);
+ else
+ return array [ 0 ].to_any();
+ }
+ catch (Exception e)
+ {
+ InvalidValue t = new InvalidValue();
+ t.initCause(e);
+ throw t;
+ }
+ }
+
+ /** @inheritDoc */
+ public DynAny get_boxed_value_as_dyn_any()
+ throws InvalidValue
+ {
+ if (is_null())
+ throw new InvalidValue(ISNULL);
+ else
+ return array [ 0 ].copy();
+ }
+
+ /** {@inheritDoc} */
+ public Serializable get_val()
+ throws TypeMismatch, InvalidValue
+ {
+ return to_any().extract_Value();
+ }
+
+ /** {@inheritDoc} */
+ public void insert_val(Serializable a_x)
+ throws InvalidValue, TypeMismatch
+ {
+ Any a = to_any();
+ a.insert_Value(a_x);
+ from_any(a);
+ valueChanged();
+ }
+
+ /** @inheritDoc */
+ public boolean is_null()
+ {
+ return array.length == 0;
+ }
+
+ /** @inheritDoc */
+ public void set_boxed_value(Any boxIt)
+ throws TypeMismatch
+ {
+ if (!content.equal(boxIt.type()))
+ throw new TypeMismatch(CONTENT);
+ try
+ {
+ if (is_null())
+ {
+ array = new DynAny[] { factory.create_dyn_any(boxIt) };
+ }
+ else
+ {
+ array [ 0 ].from_any(boxIt);
+ }
+ }
+ catch (Exception e)
+ {
+ TypeMismatch t = new TypeMismatch();
+ t.initCause(e);
+ throw t;
+ }
+ valueChanged();
+ }
+
+ /** @inheritDoc */
+ public void set_boxed_value_as_dyn_any(DynAny boxIt)
+ throws TypeMismatch
+ {
+ if (!content.equal(boxIt.type()))
+ throw new TypeMismatch(CONTENT);
+ try
+ {
+ if (is_null())
+ {
+ array = new DynAny[] { boxIt.copy() };
+ }
+ else
+ {
+ array [ 0 ].assign(boxIt);
+ }
+ }
+ catch (Exception e)
+ {
+ TypeMismatch t = new TypeMismatch();
+ t.initCause(e);
+ throw t;
+ }
+ valueChanged();
+ }
+
+ /** @inheritDoc */
+ public void set_to_null()
+ {
+ array = new DynAny[ 0 ];
+ valueChanged();
+ }
+
+ /** @inheritDoc */
+ public void set_to_value()
+ {
+ try
+ {
+ if (array.length == 0)
+ {
+ array =
+ new DynAny[] { factory.create_dyn_any_from_type_code(content) };
+ }
+ }
+ catch (InconsistentTypeCode e)
+ {
+ throw new Unexpected(e);
+ }
+ valueChanged();
+ }
+
+ /** @inheritDoc */
+ public Any to_any()
+ {
+ Any a = createAny();
+
+ if (!is_null())
+ {
+ try
+ {
+ Streamable holder;
+ if (array [ 0 ] instanceof gnuDynAny)
+ holder = ((gnuDynAny) array [ 0 ]).holder;
+ else
+ {
+ Any uan = array [ 0 ].to_any();
+ holder = uan.extract_Streamable();
+ }
+
+ Field v = holder.getClass().getField("value");
+ Serializable value = (Serializable) v.get(holder);
+ a.type(official_type);
+ a.insert_Value(value, content);
+ }
+ catch (Exception ex)
+ {
+ throw new Unexpected(ex);
+ }
+ }
+ else
+ a.type(orb.get_primitive_tc(TCKind.tk_null));
+ return a;
+ }
+}
\ No newline at end of file
--- /dev/null
+/* valueChangedListener.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., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 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.DynAn;
+
+/**
+ * An interface, able to receive notification about the change of value
+ * of some DynAny.
+ *
+ * @author Audrius Meskauskas, Lithuania (AudriusA@Bioinformatics.org)
+ */
+public interface valueChangedListener
+{
+ void changed();
+}
\ No newline at end of file
--- /dev/null
+/* DynAnySeqHolder.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., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 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.portable.InputStream;
+import org.omg.CORBA.portable.OutputStream;
+import org.omg.CORBA.portable.Streamable;
+import org.omg.DynamicAny.DynAny;
+import org.omg.DynamicAny.DynAnySeqHelper;
+
+/**
+ * A holder for the sequence of {@link DynAny}
+ * ({@link DynAnySeq}).
+ *
+ * @author Audrius Meskauskas, Lithuania (AudriusA@Bioinformatics.org)
+ */
+public class DynAnySeqHolder
+ implements Streamable
+{
+ /**
+ * The stored array of <code>DynAny</code>.
+ */
+ public DynAny[] value;
+
+ /**
+ * Create the unitialised instance, leaving the value array
+ * with default <code>null</code> value.
+ */
+ public DynAnySeqHolder()
+ {
+ }
+
+ /**
+ * Create the initialised instance.
+ * @param initialValue the array that will be assigned to
+ * the <code>value</code> array.
+ */
+ public DynAnySeqHolder(DynAny[] initialValue)
+ {
+ value = initialValue;
+ }
+
+ /**
+ * The method should read this object from the CDR input stream, but
+ * (following the JDK 1.5 API) it does not.
+ *
+ * @param input a org.omg.CORBA.portable stream to read from.
+ *
+ * @specenote Sun throws the same exception.
+ *
+ * @throws MARSHAL always.
+ */
+ public void _read(InputStream input)
+ {
+ value = DynAnySeqHelper.read(input);
+ }
+
+ /**
+ * The method should write this object to the CDR input stream, but
+ * (following the JDK 1.5 API) it does not.
+ *
+ * @param input a org.omg.CORBA.portable stream to read from.
+ *
+ * @specenote Sun throws the same exception.
+ *
+ * @throws MARSHAL always.
+ */
+ public void _write(OutputStream output)
+ {
+ DynAnySeqHelper.write(output, value);
+ }
+
+ /**
+ * Get the typecode of the DynAny.
+ */
+ public org.omg.CORBA.TypeCode _type()
+ {
+ return DynAnySeqHelper.type();
+ }
+}
\ No newline at end of file
--- /dev/null
+/* ForwardRequestHelper.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., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 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.Poa.ForwardRequestHolder;
+
+import org.omg.CORBA.Any;
+import org.omg.CORBA.BAD_OPERATION;
+import org.omg.CORBA.ORB;
+import org.omg.CORBA.ObjectHelper;
+import org.omg.CORBA.StructMember;
+import org.omg.CORBA.TypeCode;
+import org.omg.CORBA.portable.InputStream;
+import org.omg.CORBA.portable.OutputStream;
+import org.omg.PortableServer.ForwardRequest;
+
+/**
+ * The helper operations for the exception {@link ForwardRequest}.
+ *
+ * @specnote The helper must be here and not in POA subpackage as it must
+ * be discovered by the {@link ObjectCreator} when reading this remote
+ * exception.
+ *
+ * @author Audrius Meskauskas, Lithuania (AudriusA@Bioinformatics.org)
+ */
+public abstract class ForwardRequestHelper
+{
+ /**
+ * The cached typecode value, computed only once.
+ */
+ private static TypeCode typeCode;
+
+ /**
+ * Extract the ForwardRequest from given Any.
+ * This method uses the ForwardRequestHolder.
+ *
+ * @throws BAD_OPERATION if the passed Any does not contain ForwardRequest.
+ */
+ public static ForwardRequest extract(Any any)
+ {
+ try
+ {
+ return ((ForwardRequestHolder) any.extract_Streamable()).value;
+ }
+ catch (ClassCastException cex)
+ {
+ BAD_OPERATION bad = new BAD_OPERATION("ForwardRequest expected");
+ bad.initCause(cex);
+ throw bad;
+ }
+ }
+
+ /**
+ * Get the ForwardRequest repository id.
+ *
+ * @return "ForwardRequest", always.
+ */
+ public static String id()
+ {
+ return "ForwardRequest";
+ }
+
+ /**
+ * Insert the ForwardRequest into the given Any.
+ * This method uses the ForwardRequestHolder.
+ *
+ * @param any the Any to insert into.
+ * @param that the ForwardRequest to insert.
+ */
+ public static void insert(Any any, ForwardRequest that)
+ {
+ any.insert_Streamable(new ForwardRequestHolder(that));
+ }
+
+ /**
+ * Read the exception from the CDR intput stream.
+ *
+ * @param input a org.omg.CORBA.portable stream to read from.
+ */
+ public static ForwardRequest read(InputStream input)
+ {
+ // Read the exception repository id.
+ String id = input.read_string();
+ ForwardRequest value = new ForwardRequest();
+
+ value.forward_reference = input.read_Object();
+ return value;
+ }
+
+ /**
+ * Create the ForwardRequest typecode (structure,
+ * named "ForwardRequest").
+ * The typecode states that the structure contains the
+ * following fields: forward_reference.
+ */
+ public static TypeCode type()
+ {
+ if (typeCode == null)
+ {
+ ORB orb = ORB.init();
+ StructMember[] members = new StructMember[ 1 ];
+
+ TypeCode field;
+
+ field = ObjectHelper.type();
+ members [ 0 ] = new StructMember("forward_reference", field, null);
+ typeCode = orb.create_exception_tc(id(), "ForwardRequest", members);
+ }
+ return typeCode;
+ }
+
+ /**
+ * Write the exception to the CDR output stream.
+ *
+ * @param output a org.omg.CORBA.portable stream stream to write into.
+ * @param value a value to write.
+ */
+ public static void write(OutputStream output, ForwardRequest value)
+ {
+ // Write the exception repository id.
+ output.write_string(id());
+ output.write_Object(value.forward_reference);
+ }
+}
\ No newline at end of file
--- /dev/null
+/* contextSupportingHeader.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., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 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.GIOP;
+
+import org.omg.CORBA.BAD_INV_ORDER;
+
+/**
+ * A header, supporting the service contexts. Such header has a context field
+ * and methods for adding the new contexts.
+ *
+ * @author Audrius Meskauskas, Lithuania (AudriusA@Bioinformatics.org)
+ */
+public abstract class contextSupportingHeader
+{
+
+ /**
+ * Empty array, indicating that no service context is available.
+ */
+ protected static final ServiceContext[] NO_CONTEXT = new ServiceContext[0];
+
+ /**
+ * The context data.
+ */
+ public ServiceContext[] service_context = NO_CONTEXT;
+
+ /**
+ * Add service context to this header.
+ *
+ * @param context_to_add context to add.
+ * @param replace if true, the existing context with this ID is replaced.
+ * Otherwise, BAD_INV_ORDER is throwsn.
+ */
+ public void addContext(org.omg.IOP.ServiceContext context_to_add,
+ boolean replace)
+ throws BAD_INV_ORDER
+ {
+ service_context = ServiceContext.add(service_context, context_to_add,
+ replace);
+ }
+}
--- /dev/null
+/* ClientRequestInterceptors.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., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 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.Interceptor;
+
+import org.omg.PortableInterceptor.ClientRequestInfo;
+import org.omg.PortableInterceptor.ClientRequestInterceptor;
+import org.omg.PortableInterceptor.ClientRequestInterceptorOperations;
+import org.omg.PortableInterceptor.ForwardRequest;
+
+/**
+ * A block of the all registered ClientRequest interceptors.
+ *
+ * @author Audrius Meskauskas, Lithuania (AudriusA@Bioinformatics.org)
+ */
+public class ClientRequestInterceptors
+ implements ClientRequestInterceptorOperations
+{
+ /**
+ * The array of all registered ClientRequest interceptors.
+ */
+ private final ClientRequestInterceptor[] interceptors;
+
+ /**
+ * Create the interceptor pack with the registerend interceptor array,
+ * obtained from the registrator.
+ */
+ public ClientRequestInterceptors(Registrator registrator)
+ {
+ interceptors = registrator.getClientRequestInterceptors();
+ }
+
+ /** @inheritDoc */
+ public void receive_exception(ClientRequestInfo info)
+ throws ForwardRequest
+ {
+ for (int i = 0; i < interceptors.length; i++)
+ {
+ interceptors [ i ].receive_exception(info);
+ }
+ }
+
+ /** @inheritDoc */
+ public void receive_other(ClientRequestInfo info) throws ForwardRequest
+ {
+ for (int i = 0; i < interceptors.length; i++)
+ {
+ interceptors [ i ].receive_other(info);
+ }
+ }
+
+ /** @inheritDoc */
+ public void receive_reply(ClientRequestInfo info)
+ {
+ for (int i = 0; i < interceptors.length; i++)
+ {
+ interceptors [ i ].receive_reply(info);
+ }
+ }
+
+ /** @inheritDoc */
+ public void send_poll(ClientRequestInfo info)
+ {
+ for (int i = 0; i < interceptors.length; i++)
+ {
+ interceptors [ i ].send_poll(info);
+ }
+ }
+
+ /** @inheritDoc */
+ public void send_request(ClientRequestInfo info) throws ForwardRequest
+ {
+ for (int i = 0; i < interceptors.length; i++)
+ {
+ interceptors [ i ].send_request(info);
+ }
+ }
+
+ /**
+ * Call destroy on all registered interceptors.
+ */
+ public void destroy()
+ {
+ for (int i = 0; i < interceptors.length; i++)
+ {
+ try
+ {
+ interceptors [ i ].destroy();
+ }
+ catch (Exception exc)
+ {
+ // OMG states we should ignore.
+ }
+ }
+ }
+
+ /**
+ * Get the class name.
+ */
+ public String name()
+ {
+ return getClass().getName();
+ }
+}
\ No newline at end of file
--- /dev/null
+/* ForwardRequestHolder.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., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 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.Interceptor;
+
+import org.omg.CORBA.TypeCode;
+import org.omg.CORBA.portable.InputStream;
+import org.omg.CORBA.portable.OutputStream;
+import org.omg.CORBA.portable.Streamable;
+import org.omg.PortableInterceptor.ForwardRequest;
+import org.omg.PortableInterceptor.ForwardRequestHelper;
+
+/**
+ * A holder for the exception {@link ForwardRequest}.
+ *
+ * @author Audrius Meskauskas, Lithuania (AudriusA@Bioinformatics.org)
+ */
+public class ForwardRequestHolder implements Streamable
+{
+ /**
+ * The stored ForwardRequest value.
+ */
+ public ForwardRequest value;
+
+ /**
+ * Create the unitialised instance, leaving the value field with default
+ * <code>null</code> value.
+ */
+ public ForwardRequestHolder()
+ {
+ }
+
+ /**
+ * Create the initialised instance.
+ *
+ * @param initialValue the value that will be assigned to the
+ * <code>value</code> field.
+ */
+ public ForwardRequestHolder(ForwardRequest initialValue)
+ {
+ value = initialValue;
+ }
+
+ /**
+ * Fill in the {@link value} by data from the CDR stream.
+ *
+ * @param input the org.omg.CORBA.portable stream to read.
+ */
+ public void _read(InputStream input)
+ {
+ value = ForwardRequestHelper.read(input);
+ }
+
+ /**
+ * Write the stored value into the CDR stream.
+ *
+ * @param output the org.omg.CORBA.portable stream to write.
+ */
+ public void _write(OutputStream output)
+ {
+ ForwardRequestHelper.write(output, value);
+ }
+
+ /**
+ * Get the typecode of the ForwardRequest.
+ */
+ public TypeCode _type()
+ {
+ return ForwardRequestHelper.type();
+ }
+}
\ No newline at end of file
--- /dev/null
+/* IORInterceptors.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., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 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.Interceptor;
+
+import org.omg.PortableInterceptor.IORInfo;
+import org.omg.PortableInterceptor.IORInterceptor;
+import org.omg.PortableInterceptor.IORInterceptorOperations;
+
+/**
+ * A block of the all registered IOR interceptors.
+ *
+ * @author Audrius Meskauskas, Lithuania (AudriusA@Bioinformatics.org)
+ */
+public class IORInterceptors implements IORInterceptorOperations
+{
+ /**
+ * The array of all registered IOR interceptors.
+ */
+ private final IORInterceptor[] interceptors;
+
+ /**
+ * Create the interceptor pack with the registerend interceptor array,
+ * obtained from the registrator.
+ */
+ public IORInterceptors(Registrator registrator)
+ {
+ interceptors = registrator.getIORInterceptors();
+ }
+
+ /**
+ * Call this method for all registered interceptors.
+ */
+ public void establish_components(IORInfo info)
+ {
+ for (int i = 0; i < interceptors.length; i++)
+ {
+ try
+ {
+ interceptors [ i ].establish_components(info);
+ }
+ catch (Exception exc)
+ {
+ // OMG states we should ignore.
+ }
+ }
+ }
+
+ /**
+ * Call destroy on all registered interceptors.
+ */
+ public void destroy()
+ {
+ for (int i = 0; i < interceptors.length; i++)
+ {
+ try
+ {
+ interceptors [ i ].destroy();
+ }
+ catch (Exception exc)
+ {
+ // OMG states we should ignore.
+ }
+ }
+ }
+
+ /**
+ * Get the class name.
+ */
+ public String name()
+ {
+ return getClass().getName();
+ }
+}
\ No newline at end of file
--- /dev/null
+/* Registrator.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., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 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.Interceptor;
+
+import gnu.CORBA.Poa.ORB_1_4;
+import gnu.CORBA.gnuCodecFactory;
+
+import org.omg.CORBA.BAD_INV_ORDER;
+import org.omg.CORBA.CompletionStatus;
+import org.omg.CORBA.LocalObject;
+import org.omg.CORBA.Object;
+import org.omg.IOP.CodecFactory;
+import org.omg.PortableInterceptor.ClientRequestInterceptor;
+import org.omg.PortableInterceptor.IORInterceptor;
+import org.omg.PortableInterceptor.Interceptor;
+import org.omg.PortableInterceptor.ORBInitInfo;
+import org.omg.PortableInterceptor.ORBInitInfoPackage.DuplicateName;
+import org.omg.PortableInterceptor.ORBInitInfoPackage.InvalidName;
+import org.omg.PortableInterceptor.ORBInitializer;
+import org.omg.PortableInterceptor.ORBInitializerOperations;
+import org.omg.PortableInterceptor.PolicyFactory;
+import org.omg.PortableInterceptor.ServerRequestInterceptor;
+
+import java.io.BufferedInputStream;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.IOException;
+
+import java.util.ArrayList;
+import java.util.Enumeration;
+import java.util.Hashtable;
+import java.util.Iterator;
+import java.util.Map;
+import java.util.Properties;
+import java.util.TreeMap;
+
+/**
+ * Collects interceptors, references and factories into arrays during
+ * registration. As the class is security sensitive, the most of the fields are
+ * private.
+ *
+ * @author Audrius Meskauskas, Lithuania (AudriusA@Bioinformatics.org)
+ */
+public class Registrator extends LocalObject implements ORBInitInfo
+{
+ /**
+ * Use serialVersionUID for interoperability.
+ */
+ private static final long serialVersionUID = 1;
+
+ /**
+ * The agreed properties prefix.
+ */
+ public final static String m_prefix =
+ "org.omg.PortableInterceptor.ORBInitializerClass.";
+
+ /**
+ * The initialization - time server request interceptors.
+ */
+ private ArrayList m_server = new ArrayList();
+
+ /**
+ * The initialization - time client request interceptors.
+ */
+ private ArrayList m_client = new ArrayList();
+
+ /**
+ * The initialization - time ior interceptors.
+ */
+ private ArrayList m_ior = new ArrayList();
+
+ /**
+ * The policy factories.
+ */
+ public Hashtable m_policyFactories = new Hashtable();
+
+ /**
+ * The registered references. To avoid exposing the ORB's references map, the
+ * are added by ORB from inside the ORB code. The ORB is responsible for
+ * taking them from this field between pre_init and post_init.
+ */
+ public TreeMap m_references = new TreeMap();
+
+ /**
+ * The initializers.
+ */
+ public ArrayList m_initializers = new ArrayList();
+
+ /**
+ * The ORB being intialised.
+ */
+ final ORB_1_4 orb;
+
+ /**
+ * The argument string array, passed to ORB.init.
+ */
+ final String[] m_args;
+
+ /**
+ * The codec factory.
+ */
+ final gnuCodecFactory m_codecFactory;
+
+ /**
+ * Create the interceptor collection from the given properties, using the
+ * agreed naming convention.
+ *
+ * @param orb the ORB being initialised.
+ * @param props the cumulated set of properties where the orb initializer
+ * pattern is searched.
+ * @param an_args the argument string array, passed to ORB.init.
+ */
+ public Registrator(ORB_1_4 an_orb, Properties props, String[] an_args)
+ {
+ orb = an_orb;
+ m_args = an_args;
+ m_codecFactory = new gnuCodecFactory(orb);
+ checkProperties(props);
+ checkProperties(System.getProperties());
+ checkFile("user.home", null);
+ checkFile("java.home", "lib");
+ }
+
+ /**
+ * Scan the given properties for the possible interceptors.
+ */
+ private void checkProperties(Properties props)
+ {
+ if (props == null)
+ {
+ return;
+ }
+
+ Enumeration names = props.propertyNames();
+ java.lang.Object key;
+ String sk;
+
+ while (names.hasMoreElements())
+ {
+ key = names.nextElement();
+ if (key != null)
+ {
+ sk = key.toString();
+ if (sk.startsWith(m_prefix))
+ {
+ try
+ {
+ String cn = sk.substring(m_prefix.length());
+ Class iClass = Class.forName(cn);
+ ORBInitializer initializer =
+ (ORBInitializer) iClass.newInstance();
+ m_initializers.add(initializer);
+ }
+ catch (Exception exc)
+ {
+ // OMG states we should not throw an exception, but
+ // this will help the user to detect his error
+ // in initialiser properties. Should never print during
+ // normal run.
+ System.err.println(sk + " failed");
+ }
+ }
+ }
+ }
+ }
+
+ /**
+ * Check if the property is defined in the existsting file orb.properties.
+ */
+ private void checkFile(String dir, String subdir)
+ {
+ try
+ {
+ File f = new File(dir);
+ if (!f.exists())
+ {
+ return;
+ }
+
+ if (subdir != null)
+ {
+ f = new File(f, subdir);
+ }
+ f = new File(f, "orb.properties");
+
+ if (!f.exists())
+ {
+ return;
+ }
+
+ Properties p = new Properties();
+ p.load(new BufferedInputStream(new FileInputStream(f)));
+
+ checkProperties(p);
+ }
+ catch (IOException ex)
+ {
+ }
+ }
+
+ /**
+ * Called by ORB as a pre_init for all initializers.
+ */
+ public void pre_init()
+ {
+ Iterator iter = m_initializers.iterator();
+ while (iter.hasNext())
+ {
+ ORBInitializerOperations initializer =
+ (ORBInitializerOperations) iter.next();
+ initializer.pre_init(this);
+ }
+ }
+
+ /**
+ * Get the map of the registered references. The ORB calls this method to
+ * import the references into its references map.
+ */
+ public Map getRegisteredReferences()
+ {
+ return m_references;
+ }
+
+ /**
+ * Called by ORB as a post-init for all initializers. After this call, the
+ * interceptor sets are fixed and redundant information is discarded.
+ */
+ public void post_init()
+ {
+ Iterator iter = m_initializers.iterator();
+ while (iter.hasNext())
+ {
+ ORBInitializerOperations initializer =
+ (ORBInitializerOperations) iter.next();
+ initializer.post_init(this);
+ }
+ }
+
+ public ServerRequestInterceptor[] getServerRequestInterceptors()
+ {
+ ServerRequestInterceptor[] iServer =
+ new ServerRequestInterceptor[ m_server.size() ];
+ for (int i = 0; i < iServer.length; i++)
+ {
+ iServer [ i ] = (ServerRequestInterceptor) m_server.get(i);
+ }
+ return iServer;
+ }
+
+ public ClientRequestInterceptor[] getClientRequestInterceptors()
+ {
+ ClientRequestInterceptor[] iClient =
+ new ClientRequestInterceptor[ m_client.size() ];
+ for (int i = 0; i < iClient.length; i++)
+ {
+ iClient [ i ] = (ClientRequestInterceptor) m_client.get(i);
+ }
+ return iClient;
+ }
+
+ public IORInterceptor[] getIORInterceptors()
+ {
+ IORInterceptor[] iIor = new IORInterceptor[ m_ior.size() ];
+ for (int i = 0; i < iIor.length; i++)
+ {
+ iIor [ i ] = (IORInterceptor) m_ior.get(i);
+ }
+ return iIor;
+ }
+
+ public void add_client_request_interceptor(
+ ClientRequestInterceptor interceptor
+ ) throws DuplicateName
+ {
+ add(m_client, interceptor);
+ }
+
+ public void add_ior_interceptor(IORInterceptor interceptor)
+ throws DuplicateName
+ {
+ add(m_ior, interceptor);
+ }
+
+ public void add_server_request_interceptor(
+ ServerRequestInterceptor interceptor
+ ) throws DuplicateName
+ {
+ add(m_server, interceptor);
+ }
+
+ /**
+ * Allocate a new slot for request - specific records.
+ */
+ public int allocate_slot_id()
+ {
+ return orb.icSlotSize++;
+ }
+
+ /**
+ * Add the interceptor to the given collection.
+ *
+ * @param list the collection to add.
+ * @param interceptor the interceptor to add.
+ */
+ private void add(ArrayList list, Interceptor interceptor)
+ throws DuplicateName
+ {
+ if (interceptor.name().length() > 0)
+ {
+ Iterator iter = list.iterator();
+ Interceptor ic;
+
+ while (iter.hasNext())
+ {
+ ic = (Interceptor) iter.next();
+ if (ic.name().equals(interceptor.name()))
+ {
+ throw new DuplicateName(interceptor.name());
+ }
+ }
+ }
+ list.add(interceptor);
+ }
+
+ /**
+ * Get string array, passed to ORB.init.
+ */
+ public String[] arguments()
+ {
+ return m_args;
+ }
+
+ /**
+ * Get the codec factory.
+ */
+ public CodecFactory codec_factory()
+ {
+ return m_codecFactory;
+ }
+
+ /**
+ * Get the ORB's id, currently using .toString.
+ */
+ public String orb_id()
+ {
+ return "orb_" + orb;
+ }
+
+ /**
+ * Register reference.
+ */
+ public void register_initial_reference(String object_name, Object object)
+ throws InvalidName
+ {
+ if (object_name == null)
+ {
+ throw new InvalidName("null");
+ }
+ else if (object_name.length() == 0)
+ {
+ throw new InvalidName("Empty string");
+ }
+ else if (m_references.containsKey(object_name))
+ {
+ throw new InvalidName(object_name);
+ }
+ else
+ {
+ m_references.put(object_name, object);
+ }
+ }
+
+ /**
+ * Accumulates the policy factory map.
+ */
+ public void register_policy_factory(int policy_type,
+ PolicyFactory policy_factory
+ )
+ {
+ Integer it = new Integer(policy_type);
+ if (m_policyFactories.containsKey(it))
+ {
+ throw new BAD_INV_ORDER(
+ "Repetetive registration of the policy factory for type " +
+ policy_type,
+ 16,
+ CompletionStatus.COMPLETED_NO
+ );
+ }
+ m_policyFactories.put(it, policy_factory);
+ }
+
+ /**
+ * Delegates to ORB.
+ */
+ public org.omg.CORBA.Object resolve_initial_references(String object_name)
+ throws InvalidName
+ {
+ try
+ {
+ return orb.resolve_initial_references(object_name);
+ }
+ catch (org.omg.CORBA.ORBPackage.InvalidName e)
+ {
+ InvalidName in = new InvalidName(e.getMessage());
+ in.initCause(e);
+ throw in;
+ }
+ }
+
+ /**
+ * Check if any interceptors of this type were registered.
+ */
+ public boolean hasClientRequestInterceptors()
+ {
+ return m_client.size() > 0;
+ }
+
+ /**
+ * Check if any interceptors of this type were registered.
+ */
+ public boolean hasServerRequestInterceptors()
+ {
+ return m_server.size() > 0;
+ }
+
+ /**
+ * Check if any interceptors of this type were registered.
+ */
+ public boolean hasIorInterceptors()
+ {
+ return m_ior.size() > 0;
+ }
+}
--- /dev/null
+/* ServerRequestInterceptors.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., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 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.Interceptor;
+
+import org.omg.PortableInterceptor.ForwardRequest;
+import org.omg.PortableInterceptor.ServerRequestInfo;
+import org.omg.PortableInterceptor.ServerRequestInterceptor;
+import org.omg.PortableInterceptor.ServerRequestInterceptorOperations;
+
+/**
+ * A block of the all registered ServerRequest interceptors.
+ *
+ * @author Audrius Meskauskas, Lithuania (AudriusA@Bioinformatics.org)
+ */
+public class ServerRequestInterceptors
+ implements ServerRequestInterceptorOperations
+{
+ /**
+ * The array of all registered ServerRequest interceptors.
+ */
+ private final ServerRequestInterceptor[] interceptors;
+
+ /**
+ * Create the interceptor pack with the registerend interceptor array,
+ * obtained from the registrator.
+ */
+ public ServerRequestInterceptors(Registrator registrator)
+ {
+ interceptors = registrator.getServerRequestInterceptors();
+ }
+
+ /** @inheritDoc */
+ public void receive_request_service_contexts(ServerRequestInfo info)
+ throws ForwardRequest
+ {
+ for (int i = 0; i < interceptors.length; i++)
+ {
+ interceptors [ i ].receive_request_service_contexts(info);
+ }
+ }
+
+ /** @inheritDoc */
+ public void receive_request(ServerRequestInfo info) throws ForwardRequest
+ {
+ for (int i = 0; i < interceptors.length; i++)
+ {
+ interceptors [ i ].receive_request(info);
+ }
+ }
+
+ /** @inheritDoc */
+ public void send_exception(ServerRequestInfo info) throws ForwardRequest
+ {
+ for (int i = 0; i < interceptors.length; i++)
+ {
+ interceptors [ i ].send_exception(info);
+ }
+ }
+
+ /** @inheritDoc */
+ public void send_other(ServerRequestInfo info) throws ForwardRequest
+ {
+ for (int i = 0; i < interceptors.length; i++)
+ {
+ interceptors [ i ].send_other(info);
+ }
+ }
+
+ /** @inheritDoc */
+ public void send_reply(ServerRequestInfo info)
+ {
+ for (int i = 0; i < interceptors.length; i++)
+ {
+ interceptors [ i ].send_reply(info);
+ }
+ }
+
+ /**
+ * Call destroy on all registered interceptors.
+ */
+ public void destroy()
+ {
+ for (int i = 0; i < interceptors.length; i++)
+ {
+ try
+ {
+ interceptors [ i ].destroy();
+ }
+ catch (Exception exc)
+ {
+ // OMG states we should ignore.
+ }
+ }
+ }
+
+ /**
+ * Get the class name.
+ */
+ public String name()
+ {
+ return getClass().getName();
+ }
+}
\ No newline at end of file
--- /dev/null
+/* gnuClientRequestInfo.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., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 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.Interceptor;
+
+import gnu.CORBA.Unexpected;
+import gnu.CORBA.gnuRequest;
+
+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.BAD_PARAM;
+import org.omg.CORBA.Bounds;
+import org.omg.CORBA.ExceptionList;
+import org.omg.CORBA.INV_POLICY;
+import org.omg.CORBA.LocalObject;
+import org.omg.CORBA.NVList;
+import org.omg.CORBA.ORB;
+import org.omg.CORBA.ParameterMode;
+import org.omg.CORBA.Policy;
+import org.omg.CORBA.TCKind;
+import org.omg.CORBA.TypeCode;
+import org.omg.CORBA.TypeCodePackage.BadKind;
+import org.omg.Dynamic.Parameter;
+import org.omg.IOP.ServiceContext;
+import org.omg.IOP.TaggedComponent;
+import org.omg.IOP.TaggedProfile;
+import org.omg.PortableInterceptor.ClientRequestInfo;
+import org.omg.PortableInterceptor.InvalidSlot;
+
+/**
+ * Client request info. All requests on the client side in Classpath
+ * implementations are handled via gnuRequest class. This class holds the
+ * instance of the gnuRequest, accessing the request info this way.
+ *
+ * @author Audrius Meskauskas, Lithuania (AudriusA@Bioinformatics.org)
+ */
+public class gnuClientRequestInfo extends LocalObject
+ implements ClientRequestInfo
+{
+ /**
+ * Use serialVersionUID for interoperability.
+ */
+ private static final long serialVersionUID = 1;
+
+ /**
+ * The request structure, from that some methods take the needed information
+ * directly. The same request structure cannot be reused in parallel threads,
+ * the submission methods are synchronized.
+ */
+ private final gnuRequest request;
+
+ /**
+ * Provides possibility to set the wrapped thrown exception explicitly, where
+ * applicable.
+ */
+ public Any m_wrapped_exception;
+
+ /**
+ * Create the info on the given request.
+ */
+ public gnuClientRequestInfo(gnuRequest a_request)
+ {
+ request = a_request;
+ }
+
+ /** @inheritDoc */
+ public void add_request_service_context(ServiceContext service_context,
+ boolean replace
+ )
+ {
+ request.add_request_service_context(service_context, replace);
+ }
+
+ /** @inheritDoc */
+ public TaggedProfile effective_profile()
+ {
+ return request.effective_profile();
+ }
+
+ /** @inheritDoc */
+ public org.omg.CORBA.Object effective_target()
+ {
+ return request.effective_target();
+ }
+
+ /** @inheritDoc */
+ public TaggedComponent get_effective_component(int id)
+ throws BAD_PARAM
+ {
+ return request.get_effective_component(id);
+ }
+
+ /** @inheritDoc */
+ public TaggedComponent[] get_effective_components(int id)
+ throws BAD_PARAM
+ {
+ return request.get_effective_components(id);
+ }
+
+ /** @inheritDoc */
+ public Policy get_request_policy(int type) throws INV_POLICY
+ {
+ return request.get_request_policy(type);
+ }
+
+ /** @inheritDoc */
+ public String received_exception_id()
+ {
+ try
+ {
+ if (m_wrapped_exception != null)
+ {
+ return m_wrapped_exception.type().id();
+ }
+ else
+ {
+ return request.received_exception_id();
+ }
+ }
+ catch (BadKind e)
+ {
+ throw new Unexpected(e);
+ }
+ }
+
+ /** @inheritDoc */
+ public Any received_exception()
+ {
+ if (m_wrapped_exception != null)
+ {
+ return m_wrapped_exception;
+ }
+ else
+ {
+ return request.received_exception();
+ }
+ }
+
+ /** @inheritDoc */
+ public org.omg.CORBA.Object target()
+ {
+ return request.target();
+ }
+
+ /** @inheritDoc */
+ public Parameter[] arguments()
+ {
+ request.checkDii();
+
+ NVList args = request.arguments();
+ Parameter[] p = new Parameter[ args.count() ];
+ try
+ {
+ for (int i = 0; i < p.length; i++)
+ {
+ ParameterMode mode;
+
+ switch (args.item(i).flags())
+ {
+ case ARG_IN.value :
+ mode = ParameterMode.PARAM_IN;
+ break;
+
+ case ARG_OUT.value :
+ mode = ParameterMode.PARAM_OUT;
+ break;
+
+ case ARG_INOUT.value :
+ mode = ParameterMode.PARAM_INOUT;
+ break;
+
+ default :
+ throw new Unexpected();
+ }
+
+ p [ i ] = new Parameter(args.item(i).value(), mode);
+ }
+ }
+ catch (Bounds e)
+ {
+ throw new Unexpected(e);
+ }
+ return p;
+ }
+
+ /** @inheritDoc */
+ public Any result()
+ {
+ request.checkDii();
+
+ Any rt = request.return_value();
+
+ if (rt == null)
+ {
+ ORB orb = request.orb();
+ rt = orb.create_any();
+ rt.type(orb.get_primitive_tc(TCKind.tk_void));
+ return rt;
+ }
+
+ return request.return_value();
+ }
+
+ /** @inheritDoc */
+ public String[] contexts()
+ {
+ return request.ice_contexts();
+ }
+
+ /** @inheritDoc */
+ public TypeCode[] exceptions()
+ {
+ request.checkDii();
+
+ ExceptionList ex = request.exceptions();
+ TypeCode[] et = new TypeCode[ ex.count() ];
+ try
+ {
+ for (int i = 0; i < et.length; i++)
+ {
+ et [ i ] = ex.item(i);
+ }
+ }
+ catch (Bounds e)
+ {
+ throw new Unexpected(e);
+ }
+ return et;
+ }
+
+ /** @inheritDoc */
+ public org.omg.CORBA.Object forward_reference()
+ {
+ return request.forward_reference();
+ }
+
+ /** @inheritDoc */
+ public String[] operation_context()
+ {
+ return request.operation_context();
+ }
+
+ /** @inheritDoc */
+ public Any get_slot(int id) throws InvalidSlot
+ {
+ return request.get_slot(id);
+ }
+
+ /** @inheritDoc */
+ public String operation()
+ {
+ return request.operation();
+ }
+
+ /** @inheritDoc */
+ public short reply_status()
+ {
+ return request.reply_status();
+ }
+
+ /** @inheritDoc */
+ public int request_id()
+ {
+ return request.request_id();
+ }
+
+ /** @inheritDoc */
+ public boolean response_expected()
+ {
+ return request.response_expected();
+ }
+
+ /**
+ * Determines how far the request shall progress before control is returned to
+ * the client. However up till JDK 1.5 inclusive this method always returns
+ * SYNC_WITH_TRANSPORT.
+ *
+ * @return {@link org.omg.Messaging.SYNC_WITH_TRANSPORT.value (1), always.
+ *
+ * @specnote as defined in the Suns 1.5 JDK API.
+ */
+ public short sync_scope()
+ {
+ return request.sync_scope();
+ }
+
+ /** @inheritDoc */
+ public ServiceContext get_reply_service_context(int ctx_name)
+ throws BAD_PARAM
+ {
+ return request.get_reply_service_context(ctx_name);
+ }
+
+ /** @inheritDoc */
+ public ServiceContext get_request_service_context(int ctx_name)
+ throws BAD_PARAM
+ {
+ return request.get_request_service_context(ctx_name);
+ }
+}
\ No newline at end of file
--- /dev/null
+/* gnuIcCurrent.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., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 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.Interceptor;
+
+import gnu.CORBA.CDR.cdrBufOutput;
+import gnu.CORBA.Poa.ORB_1_4;
+
+import org.omg.CORBA.Any;
+import org.omg.CORBA.BAD_INV_ORDER;
+import org.omg.CORBA.TCKind;
+import org.omg.CORBA.portable.InputStream;
+import org.omg.CORBA.portable.ObjectImpl;
+import org.omg.PortableInterceptor.Current;
+import org.omg.PortableInterceptor.CurrentHelper;
+import org.omg.PortableInterceptor.InvalidSlot;
+
+import java.util.Hashtable;
+import java.util.Iterator;
+import java.util.Map;
+
+/**
+ * Supports the "Interceptor current" concept, providing the slot value
+ * information for the current thread. When making the invocation, this
+ * information is copied to the Current, returned by ClientRequestInfo.
+ *
+ * There is only one instance of this class per ORB. It maintains a thread to
+ * information map.
+ *
+ * @author Audrius Meskauskas, Lithuania (AudriusA@Bioinformatics.org)
+ */
+public class gnuIcCurrent extends ObjectImpl implements Current
+{
+ /**
+ * Use serialVersionUID for interoperability.
+ */
+ private static final long serialVersionUID = 1;
+
+ /**
+ * The ORB, controllin this Current. It provides data about the required size
+ * of the slot array.
+ */
+ final ORB_1_4 orb;
+
+ /**
+ * The table, mapping threads to records.
+ */
+ private Hashtable threads = new Hashtable();
+
+ /**
+ * An empty array when no slots are defined, computed once.
+ */
+ static final Any[] NO_SLOTS = new Any[ 0 ];
+
+ /**
+ * Create the IC current.
+ */
+ public gnuIcCurrent(ORB_1_4 an_orb)
+ {
+ orb = an_orb;
+ }
+
+ /**
+ * Get the array of POA current repository ids.
+ *
+ * @return a single member array, containing value, returned by the
+ * {@link CurrentHelper#id}, normally
+ * "IDL:omg.org/PortableInterceptor/Current:1.0".
+ */
+ public String[] _ids()
+ {
+ return new String[] { CurrentHelper.id() };
+ }
+
+ /**
+ * Add the entry to the map.
+ */
+ public void put(Thread t, Any[] record)
+ {
+ synchronized (threads)
+ {
+ threads.put(t, record);
+
+ // Remove non-running threads, avoiding memory leak.
+ if (threads.size() > 12)
+ {
+ Iterator it = threads.entrySet().iterator();
+ while (it.hasNext())
+ {
+ Map.Entry e = (Map.Entry) it.next();
+ Thread tx = (Thread) e.getKey();
+ if (!tx.isAlive())
+ {
+ it.remove();
+ }
+ }
+ }
+ }
+ }
+
+ /**
+ * Check if this thread is registered.
+ */
+ public boolean has(Thread t)
+ {
+ synchronized (threads)
+ {
+ return threads.containsKey(t);
+ }
+ }
+
+ /**
+ * Remove the entry from the map.
+ */
+ public void remove(Thread t)
+ {
+ synchronized (threads)
+ {
+ threads.remove(t);
+ }
+ }
+
+ /**
+ * Get array of all slots, as it is applicable for the current thread. If the
+ * slots were not previously allocated, they are allocated during this call.
+ */
+ Any[] get_slots()
+ {
+ Any[] r;
+ synchronized (threads)
+ {
+ r = (Any[]) threads.get(Thread.currentThread());
+ if (r == null)
+ {
+ r = new Any[ orb.icSlotSize ];
+
+ for (int i = 0; i < r.length; i++)
+ {
+ Any a = orb.create_any();
+ a.type(orb.get_primitive_tc(TCKind.tk_null));
+ r [ i ] = a;
+ }
+
+ put(Thread.currentThread(), r);
+ }
+ return r;
+ }
+ }
+
+ /**
+ * Get copu array of all slots, as it is applicable for the current thread. If
+ * the slots were not previously allocated, they are allocated during this
+ * call.
+ */
+ public Any[] clone_slots()
+ {
+ if (orb.icSlotSize == 0)
+ {
+ return NO_SLOTS;
+ }
+ else
+ {
+ Any[] r = get_slots();
+ Any[] copy = new Any[ r.length ];
+
+ cdrBufOutput buf = new cdrBufOutput();
+ buf.setOrb(orb);
+
+ for (int i = 0; i < copy.length; i++)
+ {
+ r [ i ].write_value(buf);
+ }
+
+ InputStream input = buf.create_input_stream();
+
+ for (int i = 0; i < copy.length; i++)
+ {
+ copy [ i ] = orb.create_any();
+ copy [ i ].read_value(input, r [ i ].type());
+ }
+
+ return copy;
+ }
+ }
+
+ /**
+ * Get value for the slot with the given id. If the array of Currents has not
+ * been yet allocated for the current thread, it is allocated during the
+ * invocation of this method.
+ */
+ public Any get_slot(int slot_id) throws InvalidSlot, BAD_INV_ORDER
+ {
+ try
+ {
+ return get_slots() [ slot_id ];
+ }
+ catch (ArrayIndexOutOfBoundsException e)
+ {
+ throw new InvalidSlot("Slot " + slot_id);
+ }
+ }
+
+ /**
+ * Set value for the slot with the given id. If the array of Currents has not
+ * been yet allocated for the current thread, it is allocated during the
+ * invocation of this method.
+ */
+ public void set_slot(int slot_id, Any data)
+ throws InvalidSlot, BAD_INV_ORDER
+ {
+ try
+ {
+ get_slots() [ slot_id ] = data;
+ }
+ catch (ArrayIndexOutOfBoundsException e)
+ {
+ throw new InvalidSlot("Slot " + slot_id);
+ }
+ }
+}
\ No newline at end of file
--- /dev/null
+/* gnuIorInfo.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., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 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.Interceptor;
+
+import gnu.CORBA.IOR;
+import gnu.CORBA.Poa.ORB_1_4;
+
+import org.omg.CORBA.LocalObject;
+import org.omg.CORBA.Policy;
+import org.omg.IOP.TaggedComponent;
+import org.omg.PortableInterceptor.IORInfo;
+import org.omg.PortableServer.POA;
+
+/**
+ * Implements IORInfo.
+ *
+ * @author Audrius Meskauskas, Lithuania (AudriusA@Bioinformatics.org)
+ */
+public class gnuIorInfo extends LocalObject implements IORInfo
+{
+ /**
+ * Use serialVersionUID for interoperability.
+ */
+ private static final long serialVersionUID = 1;
+
+ /**
+ * The ORB, to that the IOR is related.
+ */
+ public final ORB_1_4 orb;
+
+ /**
+ * The POA, to that IOR is related.
+ */
+ public final POA poa;
+
+ /**
+ * The IOR itself.
+ */
+ private final IOR ior;
+
+ /**
+ * Create an instance.
+ */
+ public gnuIorInfo(ORB_1_4 an_orb, POA a_poa, IOR an_ior)
+ {
+ orb = an_orb;
+ poa = a_poa;
+ ior = an_ior;
+ }
+
+ /**
+ * Add component to tje specified profile of this IOR.
+ */
+ public void add_ior_component_to_profile(TaggedComponent tagged_component,
+ int profile_id
+ )
+ {
+ ior.add_ior_component_to_profile(tagged_component, profile_id);
+ }
+
+ /**
+ * Add component to all found profiles in this IOR.
+ */
+ public void add_ior_component(TaggedComponent tagged_component)
+ {
+ ior.add_ior_component(tagged_component);
+ }
+
+ /**
+ * Get the POA policy.
+ */
+ public Policy get_effective_policy(int policy_type)
+ {
+ return poa._get_policy(policy_type);
+ }
+
+ /**
+ * Return the state of the object POA.
+ */
+ short state()
+ {
+ return (short) poa.the_POAManager().get_state().value();
+ }
+}
\ No newline at end of file
--- /dev/null
+/* gnuServerRequestInfo.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., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 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.Interceptor;
+
+import gnu.CORBA.GIOP.ReplyHeader;
+import gnu.CORBA.GIOP.RequestHeader;
+import gnu.CORBA.ObjectCreator;
+import gnu.CORBA.Poa.gnuServantObject;
+import gnu.CORBA.Unexpected;
+import gnu.CORBA.gnuRequest;
+
+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.BAD_PARAM;
+import org.omg.CORBA.Bounds;
+import org.omg.CORBA.CompletionStatus;
+import org.omg.CORBA.ExceptionList;
+import org.omg.CORBA.INV_POLICY;
+import org.omg.CORBA.LocalObject;
+import org.omg.CORBA.NO_RESOURCES;
+import org.omg.CORBA.NVList;
+import org.omg.CORBA.Object;
+import org.omg.CORBA.ParameterMode;
+import org.omg.CORBA.Policy;
+import org.omg.CORBA.TCKind;
+import org.omg.CORBA.TypeCode;
+import org.omg.Dynamic.Parameter;
+import org.omg.IOP.ServiceContext;
+import org.omg.Messaging.SYNC_WITH_TRANSPORT;
+import org.omg.PortableInterceptor.InvalidSlot;
+import org.omg.PortableInterceptor.ServerRequestInfo;
+
+/**
+ * Implementation of the ServerRequestInfo, associacted with gnuServantObject.
+ *
+ * @author Audrius Meskauskas, Lithuania (AudriusA@Bioinformatics.org)
+ */
+public class gnuServerRequestInfo extends LocalObject
+ implements ServerRequestInfo
+{
+ /**
+ * Use serialVersionUID for interoperability.
+ */
+ private static final long serialVersionUID = 1;
+
+ /**
+ * A local object that will serve the invocation.
+ */
+ final gnuServantObject m_object;
+
+ /**
+ * A message that the given resource is not available using this metod of
+ * invocation.
+ */
+ static final String not_available =
+ "The used invocation method provides" + "no access to this resource.";
+
+ /**
+ * An array of slots.
+ */
+ Any[] m_slots;
+
+ /**
+ * The request header.
+ */
+ public final RequestHeader m_request_header;
+
+ /**
+ * The reply header.
+ */
+ public final ReplyHeader m_reply_header;
+
+ /**
+ * The forward reference, if applicable.
+ */
+ public Object m_forward_reference;
+
+ /**
+ * The thrown systen exception.
+ */
+ public Exception m_sys_exception;
+
+ /**
+ * The Any, containing the thrown user exception.
+ */
+ public Any m_usr_exception;
+
+ /**
+ * The associated request, if any.
+ */
+ public gnuRequest m_request;
+
+ /**
+ * Create a new instance at the time when it is known which object will serve
+ * the invocation.
+ *
+ * @param an_object a local object, connected to the local servant that will
+ * serve the invocation.
+ */
+ public gnuServerRequestInfo(gnuServantObject an_object,
+ RequestHeader a_request_header, ReplyHeader a_reply_header
+ )
+ {
+ m_object = an_object;
+ m_request_header = a_request_header;
+ m_reply_header = a_reply_header;
+ m_slots = new Any[ m_object.orb.icSlotSize ];
+ reset();
+ }
+
+ /**
+ * Set the give slot.
+ */
+ public void set_slot(int id, Any data) throws InvalidSlot
+ {
+ try
+ {
+ m_slots [ id ] = data;
+ }
+ catch (Exception e)
+ {
+ InvalidSlot ex = new InvalidSlot("Cannot set slot " + id);
+ ex.initCause(e);
+ throw ex;
+ }
+ }
+
+ /**
+ * Get the given slot.
+ */
+ public Any get_slot(int id) throws InvalidSlot
+ {
+ try
+ {
+ return m_slots [ id ];
+ }
+ catch (Exception e)
+ {
+ InvalidSlot ex = new InvalidSlot("Cannot get slot " + id);
+ ex.initCause(e);
+ throw ex;
+ }
+ }
+
+ /**
+ * Reset slot data.
+ */
+ public void reset()
+ {
+ TypeCode tkNull = m_object.orb.get_primitive_tc(TCKind.tk_null);
+ for (int i = 0; i < m_slots.length; i++)
+ {
+ Any a = m_object.orb.create_any();
+ a.type(tkNull);
+ m_slots [ i ] = a;
+ }
+ m_sys_exception = null;
+ m_usr_exception = null;
+ }
+
+ /**
+ * Get the object id (not the object IOR key).
+ */
+ public byte[] object_id()
+ {
+ return m_object.Id;
+ }
+
+ /**
+ * Check if the target is an instance of the type, represented by the given
+ * repository Id.
+ */
+ public boolean target_is_a(String id)
+ {
+ return m_object._is_a(id);
+ }
+
+ /**
+ * Get the POA id.
+ */
+ public byte[] adapter_id()
+ {
+ return m_object.poa.id();
+ }
+
+ /**
+ * Get the POA policy of the given type that applies to the object being
+ * served (request being handled).
+ */
+ public Policy get_server_policy(int type) throws INV_POLICY
+ {
+ return m_object.poa._get_policy(type);
+ }
+
+ /**
+ * Get the first member of the object repository id array.
+ */
+ public String target_most_derived_interface()
+ {
+ return m_object._ids() [ 0 ];
+ }
+
+ /**
+ * Get the name of the operation being performed.
+ */
+ public String operation()
+ {
+ if (m_request != null)
+ {
+ return m_request.operation();
+ }
+ else
+ {
+ return m_request_header.operation;
+ }
+ }
+
+ /**
+ * Not available.
+ */
+ public TypeCode[] exceptions()
+ {
+ if (m_request == null)
+ {
+ throw new NO_RESOURCES(not_available, 1,
+ CompletionStatus.COMPLETED_MAYBE
+ );
+ }
+
+ m_request.checkDii();
+
+ ExceptionList ex = m_request.exceptions();
+ TypeCode[] et = new TypeCode[ ex.count() ];
+ try
+ {
+ for (int i = 0; i < et.length; i++)
+ {
+ et [ i ] = ex.item(i);
+ }
+ }
+ catch (Bounds e)
+ {
+ throw new Unexpected(e);
+ }
+ return et;
+ }
+
+ /**
+ * Get reply status.
+ */
+ public short reply_status()
+ {
+ return (short) m_reply_header.reply_status;
+ }
+
+ /**
+ * Get request id. All local requests have request id = -1.
+ */
+ public int request_id()
+ {
+ return m_request_header.request_id;
+ }
+
+ /**
+ * Check if the client expected any response.
+ */
+ public boolean response_expected()
+ {
+ return m_request_header.isResponseExpected();
+ }
+
+ /** @inheritDoc */
+ public void add_reply_service_context(ServiceContext service_context,
+ boolean replace
+ )
+ {
+ m_reply_header.addContext(service_context, replace);
+ }
+
+ /**
+ * Get an exception, wrapped into Any.
+ */
+ public Any sending_exception()
+ {
+ if (m_usr_exception != null)
+ {
+ return m_usr_exception;
+ }
+ else if (m_sys_exception != null)
+ {
+ Any a = m_object.orb.create_any();
+ ObjectCreator.insertException(a, m_sys_exception);
+ return a;
+ }
+ else
+ {
+ return null;
+ }
+ }
+
+ public org.omg.CORBA.Object forward_reference()
+ {
+ return m_forward_reference;
+ }
+
+ /** @inheritDoc */
+ public ServiceContext get_reply_service_context(int ctx_name)
+ throws BAD_PARAM
+ {
+ return gnu.CORBA.GIOP.ServiceContext.findContext(ctx_name,
+ m_reply_header.service_context
+ );
+ }
+
+ /** @inheritDoc */
+ public ServiceContext get_request_service_context(int ctx_name)
+ throws BAD_PARAM
+ {
+ return gnu.CORBA.GIOP.ServiceContext.findContext(ctx_name,
+ m_request_header.service_context
+ );
+ }
+
+ /**
+ * Not available
+ */
+ public String[] operation_context()
+ {
+ if (m_request == null)
+ {
+ throw new NO_RESOURCES(not_available);
+ }
+ else
+ {
+ return m_request.operation_context();
+ }
+ }
+
+ /** @inheritDoc */
+ public Any result()
+ {
+ if (m_request == null)
+ {
+ throw new NO_RESOURCES(not_available);
+ }
+ else
+ {
+ return m_request.return_value();
+ }
+ }
+
+ /** @inheritDoc */
+ public String[] contexts()
+ {
+ if (m_request == null)
+ {
+ throw new NO_RESOURCES(not_available);
+ }
+ else
+ {
+ return m_request.ice_contexts();
+ }
+ }
+
+ /**
+ * Always returns "with transport".
+ */
+ public short sync_scope()
+ {
+ return SYNC_WITH_TRANSPORT.value;
+ }
+
+ /** @inheritDoc */
+ public Parameter[] arguments()
+ {
+ if (m_request == null)
+ {
+ throw new NO_RESOURCES(not_available);
+ }
+
+ m_request.checkDii();
+
+ NVList args = m_request.arguments();
+ Parameter[] p = new Parameter[ args.count() ];
+ try
+ {
+ for (int i = 0; i < p.length; i++)
+ {
+ ParameterMode mode;
+
+ switch (args.item(i).flags())
+ {
+ case ARG_IN.value :
+ mode = ParameterMode.PARAM_IN;
+ break;
+
+ case ARG_OUT.value :
+ mode = ParameterMode.PARAM_OUT;
+ break;
+
+ case ARG_INOUT.value :
+ mode = ParameterMode.PARAM_INOUT;
+ break;
+
+ default :
+ throw new Unexpected();
+ }
+
+ p [ i ] = new Parameter(args.item(i).value(), mode);
+ }
+ }
+ catch (Bounds e)
+ {
+ throw new Unexpected(e);
+ }
+ return p;
+ }
+}
\ No newline at end of file
--- /dev/null
+/* NameDynAnyPairHolder.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., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 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.portable.InputStream;
+import org.omg.CORBA.portable.OutputStream;
+import org.omg.CORBA.portable.Streamable;
+import org.omg.DynamicAny.NameDynAnyPair;
+import org.omg.DynamicAny.NameDynAnyPairHelper;
+
+/**
+ * A holder for the structure {@link NameDynAnyPair}.
+ *
+ * @author Audrius Meskauskas, Lithuania (AudriusA@Bioinformatics.org)
+ */
+public class NameDynAnyPairHolder
+ implements Streamable
+{
+ /**
+ * The stored NameDynAnyPair value.
+ */
+ public NameDynAnyPair value;
+
+ /**
+ * Create the unitialised instance, leaving the value field
+ * with default <code>null</code> value.
+ */
+ public NameDynAnyPairHolder()
+ {
+ }
+
+ /**
+ * Create the initialised instance.
+ * @param initialValue the value that will be assigned to
+ * the <code>value</code> field.
+ */
+ public NameDynAnyPairHolder(NameDynAnyPair initialValue)
+ {
+ value = initialValue;
+ }
+
+ /**
+ * The method should read this object from the CDR input stream, but
+ * (following the JDK 1.5 API) it does not.
+ *
+ * @param input a org.omg.CORBA.portable stream to read from.
+ *
+ * @specenote Sun throws the same exception.
+ *
+ * @throws MARSHAL always.
+ */
+ public void _read(InputStream input)
+ {
+ value = NameDynAnyPairHelper.read(input);
+ }
+
+ /**
+ * The method should write this object to the CDR input stream, but
+ * (following the JDK 1.5 API) it does not.
+ *
+ * @param input a org.omg.CORBA.portable stream to read from.
+ *
+ * @specenote Sun throws the same exception.
+ *
+ * @throws MARSHAL always.
+ */
+ public void _write(OutputStream output)
+ {
+ NameDynAnyPairHelper.write(output, value);
+ }
+
+ /**
+ * Get the typecode of the NameDynAnyPair.
+ */
+ public org.omg.CORBA.TypeCode _type()
+ {
+ return NameDynAnyPairHelper.type();
+ }
+}
\ No newline at end of file
--- /dev/null
+/* NameDynAnyPairSeqHolder.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., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 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.portable.InputStream;
+import org.omg.CORBA.portable.OutputStream;
+import org.omg.CORBA.portable.Streamable;
+import org.omg.DynamicAny.NameDynAnyPair;
+import org.omg.DynamicAny.NameDynAnyPairSeqHelper;
+
+/**
+ * A holder for the sequence of {@link NameDynAnyPair}.
+ *
+ * @author Audrius Meskauskas, Lithuania (AudriusA@Bioinformatics.org)
+ */
+public class NameDynAnyPairSeqHolder
+ implements Streamable
+{
+ /**
+ * The stored array of <code>NameDynAnyPair</code>.
+ */
+ public NameDynAnyPair[] value;
+
+ /**
+ * Create the unitialised instance, leaving the value array
+ * with default <code>null</code> value.
+ */
+ public NameDynAnyPairSeqHolder()
+ {
+ }
+
+ /**
+ * Create the initialised instance.
+ * @param initialValue the array that will be assigned to
+ * the <code>value</code> array.
+ */
+ public NameDynAnyPairSeqHolder(NameDynAnyPair[] initialValue)
+ {
+ value = initialValue;
+ }
+
+ /**
+ * The method should read this object from the CDR input stream, but
+ * (following the JDK 1.5 API) it does not.
+ *
+ * @param input a org.omg.CORBA.portable stream to read from.
+ *
+ * @specenote Sun throws the same exception.
+ *
+ * @throws MARSHAL always.
+ */
+ public void _read(InputStream input)
+ {
+ value = NameDynAnyPairSeqHelper.read(input);
+ }
+
+ /**
+ * The method should write this object to the CDR input stream, but
+ * (following the JDK 1.5 API) it does not.
+ *
+ * @param input a org.omg.CORBA.portable stream to read from.
+ *
+ * @specenote Sun throws the same exception.
+ *
+ * @throws MARSHAL always.
+ */
+ public void _write(OutputStream output)
+ {
+ NameDynAnyPairSeqHelper.write(output, value);
+ }
+
+ /**
+ * Get the typecode of the NameDynAnyPair.
+ */
+ public org.omg.CORBA.TypeCode _type()
+ {
+ return NameDynAnyPairSeqHelper.type();
+ }
+}
\ No newline at end of file
--- /dev/null
+/* NameValuePairHolder.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., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 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.portable.InputStream;
+import org.omg.CORBA.portable.OutputStream;
+import org.omg.CORBA.portable.Streamable;
+import org.omg.DynamicAny.NameValuePair;
+import org.omg.DynamicAny.NameValuePairHelper;
+
+/**
+ * A holder for the structure {@link NameValuePair}.
+ *
+ * @author Audrius Meskauskas, Lithuania (AudriusA@Bioinformatics.org)
+ */
+public class NameValuePairHolder
+ implements Streamable
+{
+ /**
+ * The stored NameValuePair value.
+ */
+ public NameValuePair value;
+
+ /**
+ * Create the unitialised instance, leaving the value field
+ * with default <code>null</code> value.
+ */
+ public NameValuePairHolder()
+ {
+ }
+
+ /**
+ * Create the initialised instance.
+ * @param initialValue the value that will be assigned to
+ * the <code>value</code> field.
+ */
+ public NameValuePairHolder(NameValuePair initialValue)
+ {
+ value = initialValue;
+ }
+
+ /**
+ * Fill in the {@link value} by data from the CDR stream.
+ *
+ * @param input the org.omg.CORBA.portable stream to read.
+ */
+ public void _read(InputStream input)
+ {
+ value = NameValuePairHelper.read(input);
+ }
+
+ /**
+ * Write the stored value into the CDR stream.
+ *
+ * @param output the org.omg.CORBA.portable stream to write.
+ */
+ public void _write(OutputStream output)
+ {
+ NameValuePairHelper.write(output, value);
+ }
+
+ /**
+ * Get the typecode of the NameValuePair.
+ */
+ public org.omg.CORBA.TypeCode _type()
+ {
+ return NameValuePairHelper.type();
+ }
+}
\ No newline at end of file
--- /dev/null
+/* NameValuePairSeqHolder.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., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 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.portable.InputStream;
+import org.omg.CORBA.portable.OutputStream;
+import org.omg.CORBA.portable.Streamable;
+import org.omg.DynamicAny.NameValuePair;
+import org.omg.DynamicAny.NameValuePairSeqHelper;
+
+/**
+ * A holder for the sequence of {@link NameValuePair}.
+ *
+ * @author Audrius Meskauskas, Lithuania (AudriusA@Bioinformatics.org)
+ */
+public class NameValuePairSeqHolder
+ implements Streamable
+{
+ /**
+ * The stored array of <code>NameValuePair</code>.
+ */
+ public NameValuePair[] value;
+
+ /**
+ * Create the unitialised instance, leaving the value array
+ * with default <code>null</code> value.
+ */
+ public NameValuePairSeqHolder()
+ {
+ }
+
+ /**
+ * Create the initialised instance.
+ * @param initialValue the array that will be assigned to
+ * the <code>value</code> array.
+ */
+ public NameValuePairSeqHolder(NameValuePair[] initialValue)
+ {
+ value = initialValue;
+ }
+
+ /**
+ * Read the {@link value} array from the CDR stream.
+ *
+ * @param input the org.omg.CORBA.portable stream to read.
+ */
+ public void _read(InputStream input)
+ {
+ value = NameValuePairSeqHelper.read(input);
+ }
+
+ /**
+ * Write the stored value into the CDR stream.
+ *
+ * @param output the org.omg.CORBA.portable stream to write.
+ */
+ public void _write(OutputStream output)
+ {
+ NameValuePairSeqHelper.write(output, value);
+ }
+
+ /**
+ * Get the typecode of the NameValuePair.
+ */
+ public org.omg.CORBA.TypeCode _type()
+ {
+ return NameValuePairSeqHelper.type();
+ }
+}
\ No newline at end of file
--- /dev/null
+/* NameParser.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., 51 Franklin Street, Fifth Floor, Boston, MA
+ 02110-1301 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.NamingService;
+
+import gnu.CORBA.Functional_ORB;
+import gnu.CORBA.IOR;
+import gnu.CORBA.Unexpected;
+import gnu.CORBA.Version;
+
+import org.omg.CORBA.BAD_PARAM;
+import org.omg.CORBA.DATA_CONVERSION;
+import org.omg.CORBA.ORB;
+import org.omg.CORBA.Object;
+import org.omg.CORBA.ORBPackage.InvalidName;
+import org.omg.CORBA.portable.Delegate;
+import org.omg.CORBA.portable.ObjectImpl;
+import org.omg.CosNaming.NamingContext;
+import org.omg.CosNaming.NamingContextExtHelper;
+import org.omg.CosNaming.NamingContextHelper;
+import org.omg.CosNaming._NamingContextStub;
+
+import java.io.UnsupportedEncodingException;
+import java.net.URLDecoder;
+import java.util.ArrayList;
+import java.util.StringTokenizer;
+
+/**
+ * Parses the alternative IOR representations into our IOR structure.
+ *
+ * TODO This parser currently supports only one address per target string. A
+ * string with the multiple addresses will be accepted, but only the last
+ * address will be taken into consideration. The fault tolerance is not yet
+ * implemented.
+ *
+ * The key string is filtered using {@link java.net.URLDecoder} that replaces
+ * the agreed escape sequences by the corresponding non alphanumeric characters.
+ *
+ * @author Audrius Meskauskas, Lithuania (AudriusA@Bioinformatics.org)
+ */
+public class NameParser
+ extends snConverter
+{
+ /**
+ * The corbaloc prefix.
+ */
+ public static final String pxCORBALOC = "corbaloc";
+
+ /**
+ * The corbaname prefix.
+ */
+ public static final String pxCORBANAME = "corbaname";
+
+ /**
+ * The IOR prefix.
+ */
+ public static final String pxIOR = "ior";
+
+ /**
+ * Marks iiop protocol.
+ */
+ public static final String IIOP = "iiop";
+
+ /**
+ * Marks rir protocol.
+ */
+ public static final String RIR = "rir";
+
+ /**
+ * The default port value, as specified in OMG documentation.
+ */
+ public static final int DEFAULT_PORT = 2809;
+
+ /**
+ * The default name.
+ */
+ public static final String DEFAULT_NAME = "NameService";
+
+ /**
+ * The string to name converter, initialized on demand.
+ */
+ static snConverter converter;
+
+ /**
+ * The current position.
+ */
+ int p;
+
+ /**
+ * The address being parsed, splitted into tokens.
+ */
+ String[] t;
+
+ /**
+ * Parse CORBALOC.
+ *
+ * The expected format is: <br>
+ * 1. corbaloc:[iiop][version.subversion@]:host[:port]/key <br>
+ * 2. corbaloc:rir:[/key] <br>
+ * 3. corbaname:[iiop][version.subversion@]:host[:port]/key <br>
+ * 4. corbaname:rir:[/key] <br>
+ *
+ * Protocol defaults to IOP, the object key defaults to the NameService.
+ *
+ * @param corbaloc the string to parse.
+ * @param orb the ORB, needed to create IORs and resolve rir references.
+ *
+ * @return the resolved object.
+ */
+ public synchronized org.omg.CORBA.Object corbaloc(String corbaloc,
+ Functional_ORB orb)
+ throws BAD_PARAM
+ {
+ boolean corbaname;
+
+ // The alternative addresses, if given.
+ ArrayList alt_addr = new ArrayList();
+
+ // The version numbers with default values.
+ int major = 1;
+ int minor = 0;
+
+ // The host address.
+ String host;
+
+ // The port.
+ int port = DEFAULT_PORT;
+
+ // The object key as string.
+ String key;
+
+ StringTokenizer st = new StringTokenizer(corbaloc, ":@/.,#", true);
+
+ t = new String[st.countTokens()];
+
+ for (int i = 0; i < t.length; i++)
+ {
+ t[i] = st.nextToken();
+ }
+
+ p = 0;
+
+ if (t[p].startsWith(pxCORBANAME))
+ corbaname = true;
+ else if (t[p].equalsIgnoreCase(pxCORBALOC))
+ corbaname = false;
+ else if (t[p].equalsIgnoreCase(pxIOR))
+ {
+ IOR ior = IOR.parse(corbaloc);
+ return orb.ior_to_object(ior);
+ }
+ else
+ throw new DATA_CONVERSION("Unsupported protocol: '" + t[p] + "'");
+
+ p++;
+
+ if (!t[p++].equals(":"))
+ throw new BAD_PARAM("Syntax (':' expected after name prefix)");
+
+ // Check for rir:
+ if (t[p].equals(RIR))
+ {
+ p++;
+ if (!t[p++].equals(":"))
+ throw new BAD_PARAM("':' expected after 'rir'");
+
+ key = readKey("/");
+
+ Object object;
+ try
+ {
+ object = orb.resolve_initial_references(key);
+ return corbaname ? resolve(object) : object;
+ }
+ catch (InvalidName e)
+ {
+ throw new BAD_PARAM("Unknown initial reference '" + key + "'");
+ }
+ }
+ else
+ // Check for iiop.
+ if (t[p].equals(IIOP) || t[p].equals(":"))
+ {
+ IOR ior = new IOR();
+
+ Addresses: do
+ { // Read addresses.
+ if (t[p].equals(":"))
+ {
+ p++;
+ }
+ else
+ {
+ p++;
+ if (!t[p++].equals(":"))
+ throw new BAD_PARAM("':' expected after 'iiop'");
+ // Check if version is present.
+ if (t[p + 1].equals("."))
+ if (t[p + 3].equals("@"))
+ {
+ // Version info present.
+ try
+ {
+ major = Integer.parseInt(t[p++]);
+ }
+ catch (NumberFormatException e)
+ {
+ throw new BAD_PARAM("Major version number '"
+ + t[p - 1] + "'");
+ }
+ p++; // '.' at this point.
+ try
+ {
+ minor = Integer.parseInt(t[p++]);
+ }
+ catch (NumberFormatException e)
+ {
+ throw new BAD_PARAM("Major version number '"
+ + t[p - 1] + "'");
+ }
+ p++; // '@' at this point.
+ }
+ }
+
+ ior.Internet.version = new Version(major, minor);
+
+ // Then host data goes till '/' or ':'.
+ StringBuffer bhost = new StringBuffer(corbaloc.length());
+ while (!t[p].equals(":") && !t[p].equals("/") && !t[p].equals(","))
+ bhost.append(t[p++]);
+
+ host = bhost.toString();
+
+ ior.Internet.host = host;
+
+ if (t[p].equals(":"))
+ {
+ // Port specified.
+ p++;
+ try
+ {
+ port = Integer.parseInt(t[p++]);
+ }
+ catch (NumberFormatException e)
+ {
+ throw new BAD_PARAM("Invalid port '" + t[p - 1] + "'");
+ }
+ }
+
+ ior.Internet.port = port;
+
+ // Id is not listed.
+ ior.Id = "";
+
+ if (t[p].equals(","))
+ p++;
+ else
+ break Addresses;
+ }
+ while (true);
+
+ key = readKey("/");
+ ior.key = key.getBytes();
+
+ org.omg.CORBA.Object object = orb.ior_to_object(ior);
+ return corbaname ? resolve(object) : object;
+ }
+
+ else
+ throw new DATA_CONVERSION("Unsupported protocol '" + t[p] + "'");
+ }
+
+ private org.omg.CORBA.Object resolve(org.omg.CORBA.Object object)
+ {
+ NamingContext ns;
+ String key = "?";
+ try
+ {
+ if (object instanceof NamingContext)
+ ns = (NamingContext) object;
+ else
+ {
+ Delegate delegate = ((ObjectImpl) object)._get_delegate();
+ ns = new _NamingContextStub(delegate);
+ }
+ }
+ catch (Exception ex)
+ {
+ BAD_PARAM bad = new BAD_PARAM("The CORBANAME target " + object
+ + " is not a NamingContext");
+ bad.minor = 10;
+ bad.initCause(ex);
+ throw bad;
+ }
+
+ if (converter == null)
+ converter = new snConverter();
+
+ try
+ {
+ key = readKey("#");
+ object = ns.resolve(converter.toName(key));
+ return object;
+ }
+ catch (Exception ex)
+ {
+ BAD_PARAM bad = new BAD_PARAM("Wrong CORBANAME '" + key + "'");
+ bad.minor = 10;
+ bad.initCause(ex);
+ throw bad;
+ }
+ }
+
+ private String readKey(String delimiter)
+ throws BAD_PARAM
+ {
+ if (p < t.length)
+ if (!t[p].equals(delimiter))
+ {
+ if (t[p].equals("#"))
+ return DEFAULT_NAME;
+ else
+ throw new BAD_PARAM("'" + delimiter + "String' expected '" + t[p]
+ + "' found");
+ }
+
+ StringBuffer bKey = new StringBuffer();
+ p++;
+
+ while (p < t.length && !t[p].equals("#"))
+ bKey.append(t[p++]);
+
+ if (bKey.length() == 0)
+ return DEFAULT_NAME;
+
+ try
+ {
+ return URLDecoder.decode(bKey.toString(), "UTF-8");
+ }
+ catch (UnsupportedEncodingException e)
+ {
+ throw new Unexpected("URLDecoder does not support UTF-8", e);
+ }
+ }
+
+ static NameParser n = new NameParser();
+
+ static void corbalocT(String ior, Functional_ORB orb)
+ {
+ System.out.println(ior);
+ System.out.println(n.corbaloc(ior, orb));
+ System.out.println();
+ }
+
+ public static void main(String[] args)
+ {
+ try
+ {
+ Functional_ORB orb = (Functional_ORB) ORB.init(args, null);
+ corbalocT("corbaloc:iiop:1.3@155axyz.com/Prod/aTradingService", orb);
+ corbalocT("corbaloc:iiop:2.7@255bxyz.com/Prod/bTradingService", orb);
+ corbalocT("corbaloc:iiop:355cxyz.com/Prod/cTradingService", orb);
+ corbalocT("corbaloc:iiop:2.7@255bxyz.com/Prod/bTradingService", orb);
+ corbalocT("corbaloc:iiop:355cxyz.com:7777/Prod/cTradingService", orb);
+
+ corbalocT("corbaloc::556xyz.com:80/Dev/NameService", orb);
+ corbalocT("corbaloc:iiop:1.2@host1:3076/0", orb);
+
+ corbalocT("corbaloc:rir:/NameService", orb);
+ corbalocT("corbaloc:rir:/", orb);
+ corbalocT("corbaloc:rir:", orb);
+
+ corbalocT("corbaloc:rir:/NameService", orb);
+ corbalocT("corbaloc:rir:/", orb);
+ corbalocT("corbaloc:rir:", orb);
+
+ corbalocT("corbaloc::555xyz.com,:556xyz.com:80/Dev/NameService", orb);
+ }
+ catch (BAD_PARAM e)
+ {
+ e.printStackTrace(System.out);
+ }
+ }
+}
--- /dev/null
+/* ForwardRequestHolder.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., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 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.Poa;
+
+import gnu.CORBA.ForwardRequestHelper;
+
+import org.omg.CORBA.TypeCode;
+import org.omg.CORBA.portable.InputStream;
+import org.omg.CORBA.portable.OutputStream;
+import org.omg.CORBA.portable.Streamable;
+import org.omg.PortableServer.ForwardRequest;
+
+/**
+* A holder for the exception {@link ForwardRequest}.
+
+* @author Audrius Meskauskas, Lithuania (AudriusA@Bioinformatics.org)
+*/
+public class ForwardRequestHolder
+ implements Streamable
+{
+ /**
+ * The stored ForwardRequest value.
+ */
+ public ForwardRequest value;
+
+ /**
+ * Create the unitialised instance, leaving the value field
+ * with default <code>null</code> value.
+ */
+ public ForwardRequestHolder()
+ {
+ }
+
+ /**
+ * Create the initialised instance.
+ * @param initialValue the value that will be assigned to
+ * the <code>value</code> field.
+ */
+ public ForwardRequestHolder(ForwardRequest initialValue)
+ {
+ value = initialValue;
+ }
+
+ /**
+ * Fill in the {@link value} by data from the CDR stream.
+ *
+ * @param input the org.omg.CORBA.portable stream to read.
+ */
+ public void _read(InputStream input)
+ {
+ value = ForwardRequestHelper.read(input);
+ }
+
+ /**
+ * Get the typecode of the ForwardRequest.
+ */
+ public TypeCode _type()
+ {
+ return ForwardRequestHelper.type();
+ }
+
+ /**
+ * Write the stored value into the CDR stream.
+ *
+ * @param output the org.omg.CORBA.portable stream to write.
+ */
+ public void _write(OutputStream output)
+ {
+ ForwardRequestHelper.write(output, value);
+ }
+}
\ No newline at end of file
--- /dev/null
+/* ForwardedServant.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., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 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.Poa;
+
+import gnu.CORBA.IOR;
+import gnu.CORBA.IOR_Delegate;
+import gnu.CORBA.IOR_contructed_object;
+
+import org.omg.CORBA.BAD_PARAM;
+import org.omg.CORBA.CompletionStatus;
+import org.omg.CORBA.MARSHAL;
+import org.omg.CORBA.ORB;
+import org.omg.CORBA.SystemException;
+import org.omg.CORBA.portable.ApplicationException;
+import org.omg.CORBA.portable.Delegate;
+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.RemarshalException;
+import org.omg.CORBA.portable.ResponseHandler;
+import org.omg.PortableServer.POA;
+import org.omg.PortableServer.Servant;
+
+import java.io.IOException;
+
+/**
+ * A "virtual servant", delegating all invocation to the wrapped
+ * object (usually remote). Used in cases when it is necessary to
+ * handle the request forwarding.
+ *
+ * @author Audrius Meskauskas, Lithuania (AudriusA@Bioinformatics.org)
+ */
+public class ForwardedServant
+ extends Servant
+ implements InvokeHandler
+{
+ /**
+ * The reference object, handling requests.
+ */
+ public final ObjectImpl ref;
+
+ /**
+ * Create an instance, forwarding requests to the given object.
+ */
+ ForwardedServant(ObjectImpl a_ref)
+ {
+ ref = a_ref;
+ }
+
+ /**
+ * Create an instance of the forwarded servant.
+ *
+ * @param a_ref a reference where request should be forwarded.
+ *
+ * @return a created forwarded servant or null if the parameter
+ * forwards request to itself. Returning null will force to find
+ * a right servant in one of many possible ways, depending on
+ * policies.
+ */
+ public static Servant create(org.omg.CORBA.Object a_ref)
+ {
+ try
+ {
+ ObjectImpl fto = (ObjectImpl) a_ref;
+
+ // Check maybe the remote side forwarded back to our local object.
+ if (fto instanceof IOR_contructed_object)
+ {
+ IOR_contructed_object iref = (IOR_contructed_object) fto;
+
+ // Check maybe the IOR is local.
+ ORB t_orb = iref._orb();
+ if (t_orb instanceof ORB_1_4)
+ {
+ ORB_1_4 orb = (ORB_1_4) t_orb;
+ Delegate d = iref._get_delegate();
+ if (d instanceof IOR_Delegate)
+ {
+ IOR_Delegate ird = (IOR_Delegate) iref._get_delegate();
+ IOR ior = ird.getIor();
+ if (orb.LOCAL_HOST.equalsIgnoreCase(ior.Internet.host))
+ {
+ activeObjectMap.Obj rx = orb.rootPOA.findIorKey(ior.key);
+ if (rx != null)
+ {
+ if (rx.object == fto ||
+ rx.object._is_equivalent(fto)
+ )
+ return rx.primary_servant;
+ else
+ fto = (ObjectImpl) rx.object;
+ }
+ }
+ }
+ }
+ }
+ return new ForwardedServant(fto);
+ }
+ catch (ClassCastException ex)
+ {
+ throw new BAD_PARAM("ObjectImpl required but " + a_ref + " passed ",
+ 0x5005, CompletionStatus.COMPLETED_NO
+ );
+ }
+ }
+
+ /**
+ * Forward the call to the wrapped object.
+ */
+ public OutputStream _invoke(String method, InputStream input,
+ ResponseHandler handler
+ )
+ throws SystemException
+ {
+ org.omg.CORBA.portable.InputStream in = null;
+ org.omg.CORBA.portable.OutputStream out = null;
+ try
+ {
+ try
+ {
+ out = ref._request(method, true);
+
+ // Transfer request information.
+ int b;
+ while ((b = input.read()) >= 0)
+ {
+ out.write(b);
+ }
+ in = ref._invoke(out);
+
+ // Read the returned data.
+ out = handler.createReply();
+ while ((b = in.read()) >= 0)
+ {
+ out.write(b);
+ }
+ }
+ catch (IOException io_ex)
+ {
+ MARSHAL m = new MARSHAL();
+ m.initCause(io_ex);
+ throw m;
+ }
+ }
+ catch (ApplicationException ex)
+ {
+ in = ex.getInputStream();
+
+ String _id = ex.getId();
+ throw new MARSHAL(_id, 5101, CompletionStatus.COMPLETED_NO);
+ }
+ catch (RemarshalException remarsh)
+ {
+ _invoke(method, input, handler);
+ }
+ finally
+ {
+ ref._releaseReply(in);
+ }
+ return out;
+ }
+
+ /**
+ * Delegates to the wrapped object.
+ */
+ public String[] _all_interfaces(POA poa, byte[] key)
+ {
+ return ref._ids();
+ }
+}
\ No newline at end of file
--- /dev/null
+/* LocalDelegate.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., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 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.Poa;
+
+import gnu.CORBA.CDR.cdrOutput;
+import gnu.CORBA.streamRequest;
+
+import org.omg.CORBA.ARG_INOUT;
+import org.omg.CORBA.Bounds;
+import org.omg.CORBA.Context;
+import org.omg.CORBA.ContextList;
+import org.omg.CORBA.ExceptionList;
+import org.omg.CORBA.NO_IMPLEMENT;
+import org.omg.CORBA.NVList;
+import org.omg.CORBA.NamedValue;
+import org.omg.CORBA.OBJECT_NOT_EXIST;
+import org.omg.CORBA.ORB;
+import org.omg.CORBA.Request;
+import org.omg.CORBA.TypeCodePackage.BadKind;
+import org.omg.CORBA.UnknownUserException;
+import org.omg.CORBA.portable.ApplicationException;
+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.RemarshalException;
+import org.omg.PortableServer.ServantLocatorPackage.CookieHolder;
+
+import java.util.Arrays;
+
+/**
+ * A local delegate, transferring all object requests to the locally available
+ * servant. This class is involved in handling the method invocations on the
+ * local object, obtained by POA.create_reference_with_id.
+ *
+ * @author Audrius Meskauskas, Lithuania (AudriusA@Bioinformatics.org)
+ */
+public class LocalDelegate extends org.omg.CORBA_2_3.portable.Delegate
+{
+ /**
+ * The same servant as an invocation handler.
+ */
+ gnuServantObject object;
+ String operation;
+ final gnuPOA poa;
+ final byte[] Id;
+
+ /**
+ * Create a local delegate, forwarding requests to the servant that must also
+ * be an invocation handler.
+ */
+ public LocalDelegate(gnuServantObject an_object, gnuPOA a_poa, byte[] an_id)
+ {
+ object = an_object;
+ poa = a_poa;
+ Id = an_id;
+ }
+
+ public Request request(org.omg.CORBA.Object target, String method)
+ {
+ operation = method;
+
+ LocalRequest rq = new LocalRequest(object, poa, Id);
+ rq.setOperation(method);
+ rq.setORB(orb(target));
+ return rq;
+ }
+
+ public void release(org.omg.CORBA.Object target)
+ {
+ }
+
+ public boolean is_equivalent(org.omg.CORBA.Object target,
+ org.omg.CORBA.Object other
+ )
+ {
+ if (target == other)
+ return true;
+ else if (target instanceof ObjectImpl && other instanceof ObjectImpl)
+ {
+ org.omg.CORBA.portable.Delegate a = null;
+ org.omg.CORBA.portable.Delegate b = null;
+ try
+ {
+ a = ((ObjectImpl) target)._get_delegate();
+ b = ((ObjectImpl) other)._get_delegate();
+ }
+ catch (Exception ex)
+ {
+ // Unable to get one of the delegates.
+ return false;
+ }
+ if (a instanceof LocalDelegate && b instanceof LocalDelegate)
+ {
+ byte[] k1 = ((LocalDelegate) a).Id;
+ byte[] k2 = ((LocalDelegate) b).Id;
+ return Arrays.equals(k1, k2);
+ }
+ else
+ return false;
+ }
+ else
+ return false;
+ }
+
+ /**
+ * Always return false.
+ */
+ public boolean non_existent(org.omg.CORBA.Object target)
+ {
+ return false;
+ }
+
+ /**
+ * Get hash code.
+ */
+ public int hash(org.omg.CORBA.Object target, int maximum)
+ {
+ return hashCode() % maximum;
+ }
+
+ /**
+ * Check if this object could be named by the given repository id.
+ *
+ * @param idl_id the repository id to check.
+ *
+ * @return true if it is one of the possible repository ids of this object.
+ */
+ public boolean is_a(org.omg.CORBA.Object a_servant, String idl_id)
+ {
+ String[] maybe = object._ids();
+ for (int i = 0; i < maybe.length; i++)
+ {
+ if (maybe [ i ].equals(idl_id))
+ return true;
+ }
+ return false;
+ }
+
+ /**
+ * Return <code>this</code>.
+ */
+ public org.omg.CORBA.Object duplicate(org.omg.CORBA.Object target)
+ {
+ return target;
+ }
+
+ /**
+ * Create request for using with DII.
+ */
+ public Request create_request(org.omg.CORBA.Object target, Context context,
+ String method, NVList parameters, NamedValue returns,
+ ExceptionList exceptions, ContextList ctx_list
+ )
+ {
+ operation = method;
+
+ LocalRequest rq = new LocalRequest(object, poa, Id);
+ rq.setOperation(method);
+ rq.set_args(parameters);
+ rq.set_result(returns);
+ rq.set_exceptions(exceptions);
+ rq.set_context_list(ctx_list);
+ return rq;
+ }
+
+ /**
+ * Create request for using with DII.
+ */
+ public Request create_request(org.omg.CORBA.Object target, Context context,
+ String method, NVList parameters, NamedValue returns
+ )
+ {
+ operation = method;
+
+ LocalRequest rq = new LocalRequest(object, poa, Id);
+ rq.setOperation(method);
+ rq.set_args(parameters);
+ rq.set_result(returns);
+ return rq;
+ }
+
+ /**
+ * Not in use.
+ */
+ public org.omg.CORBA.Object get_interface_def(org.omg.CORBA.Object target)
+ {
+ throw new NO_IMPLEMENT();
+ }
+
+ /**
+ * Create a request to invoke the method of this CORBA object.
+ *
+ * @param operation the name of the method to invoke.
+ * @param response_expected specifies if this is one way message or the
+ * response to the message is expected.
+ *
+ * @return the stream where the method arguments should be written.
+ */
+ public org.omg.CORBA.portable.OutputStream request(
+ org.omg.CORBA.Object target,
+ String method,
+ boolean response_expected
+ )
+ {
+ operation = method;
+
+ // Check if the object is not explicitly deactivated.
+ activeObjectMap.Obj e = poa.aom.get(Id);
+ if (e != null && e.isDeactiveted())
+ {
+ if (poa.servant_activator != null || poa.servant_locator != null)
+ {
+ // This will force the subsequent activation.
+ object.setServant(null);
+ e.setServant(null);
+ e.setDeactivated(false);
+ }
+ else
+ throw new OBJECT_NOT_EXIST("Deactivated");
+ }
+
+ LocalRequest rq = new LocalRequest(object, poa, Id);
+ rq.setOperation(method);
+ rq.setORB(orb(target));
+ return rq.getParameterStream();
+ }
+
+ /**
+ * Return the associated invocation handler.
+ */
+ public InvokeHandler getHandler(String method, CookieHolder cookie)
+ {
+ return object.getHandler(method, cookie, false);
+ }
+
+ /**
+ * Return the ORB of the associated POA. The parameter is not in use.
+ */
+ public ORB orb(org.omg.CORBA.Object target)
+ {
+ return poa.orb();
+ }
+
+ /**
+ * Make an invocation.
+ *
+ * @param target not in use.
+ * @param output the stream request that should be returned by
+ * {@link #m_request} in this method.
+ * @throws ApplicationException if the use exception is thrown by the servant
+ * method.
+ */
+ public InputStream invoke(org.omg.CORBA.Object target, OutputStream output)
+ throws ApplicationException
+ {
+ try
+ {
+ streamRequest sr = (streamRequest) output;
+
+ LocalRequest lr = (LocalRequest) sr.request;
+ InvokeHandler handler =
+ lr.object.getHandler(lr.operation(), lr.cookie, false);
+
+ if (handler instanceof dynImpHandler)
+ {
+ // The local request known how to handle it, but the different
+ // method must be called.
+ lr.invoke();
+
+ // The encapsulation will inherit orb, endian, charsets, etc.
+ cdrOutput buf = sr.createEncapsulation();
+
+ // Write all request parameters to the buffer stream.
+ if (lr.env().exception() != null)
+ {
+ try
+ {
+ UnknownUserException uex =
+ (UnknownUserException) lr.env().exception();
+ throw new ApplicationException(uex.except.type().id(),
+ uex.except.create_input_stream()
+ );
+ }
+ catch (BadKind ex)
+ {
+ InternalError ierr = new InternalError();
+ ierr.initCause(ex);
+ throw ierr;
+ }
+ }
+ if (lr.return_value() != null)
+ lr.return_value().write_value(buf);
+
+ NamedValue a;
+ try
+ {
+ for (int i = 0; i < lr.arguments().count(); i++)
+ {
+ a = lr.arguments().item(i);
+ if (a.flags() == ARG_INOUT.value ||
+ a.flags() == ARG_INOUT.value
+ )
+ {
+ a.value().write_value(buf);
+ }
+ }
+ }
+ catch (Bounds ex)
+ {
+ InternalError ierr = new InternalError();
+ ierr.initCause(ex);
+ throw ierr;
+ }
+
+ return buf.create_input_stream();
+ }
+ else
+ {
+ LocalRequest lrq = (LocalRequest) sr.request;
+ return lrq.s_invoke(handler);
+ }
+ }
+ catch (gnuForwardRequest f)
+ {
+ try
+ {
+ return ((ObjectImpl) f.forward_reference)._invoke(f.forward_reference._request(
+ operation,
+ true
+ )
+ );
+ }
+ catch (RemarshalException e)
+ {
+ // Never thrown in this place by Classpath implementation.
+ throw new NO_IMPLEMENT();
+ }
+ }
+ }
+
+ public void releaseReply(org.omg.CORBA.Object target, InputStream input)
+ {
+ release(target);
+ }
+}
\ No newline at end of file
--- /dev/null
+/* LocalRequest.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., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 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.Poa;
+
+import gnu.CORBA.CDR.cdrBufOutput;
+import gnu.CORBA.GIOP.MessageHeader;
+import gnu.CORBA.GIOP.v1_2.ReplyHeader;
+import gnu.CORBA.GIOP.v1_2.RequestHeader;
+import gnu.CORBA.Interceptor.gnuClientRequestInfo;
+import gnu.CORBA.Interceptor.gnuServerRequestInfo;
+import gnu.CORBA.ObjectCreator;
+import gnu.CORBA.Unexpected;
+import gnu.CORBA.gnuAny;
+import gnu.CORBA.gnuRequest;
+import gnu.CORBA.recordTypeCode;
+import gnu.CORBA.streamReadyHolder;
+import gnu.CORBA.streamRequest;
+
+import org.omg.CORBA.ARG_OUT;
+import org.omg.CORBA.Any;
+import org.omg.CORBA.BAD_INV_ORDER;
+import org.omg.CORBA.BAD_OPERATION;
+import org.omg.CORBA.Bounds;
+import org.omg.CORBA.NamedValue;
+import org.omg.CORBA.ORB;
+import org.omg.CORBA.SystemException;
+import org.omg.CORBA.TCKind;
+import org.omg.CORBA.UnknownUserException;
+import org.omg.CORBA.UserException;
+import org.omg.CORBA.portable.ApplicationException;
+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.PortableInterceptor.ClientRequestInterceptorOperations;
+import org.omg.PortableInterceptor.ForwardRequest;
+import org.omg.PortableInterceptor.ServerRequestInterceptorOperations;
+import org.omg.PortableServer.CurrentOperations;
+import org.omg.PortableServer.CurrentPackage.NoContext;
+import org.omg.PortableServer.DynamicImplementation;
+import org.omg.PortableServer.POA;
+import org.omg.PortableServer.Servant;
+import org.omg.PortableServer.ServantLocatorPackage.CookieHolder;
+import org.omg.PortableServer.portable.Delegate;
+
+import java.io.IOException;
+
+/**
+ * Directs the invocation to the locally available servant. The POA servant does
+ * not longer implement the CORBA object and cannot be substituted directly.
+ *
+ * @author Audrius Meskauskas, Lithuania (AudriusA@Bioinformatics.org)
+ */
+public class LocalRequest extends gnuRequest implements ResponseHandler,
+ CurrentOperations
+{
+ /**
+ * Used by servant locator, if involved.
+ */
+ CookieHolder cookie;
+
+ /**
+ * The object Id.
+ */
+ final byte[] Id;
+
+ /**
+ * The message header (singleton is sufficient).
+ */
+ private static final MessageHeader header = new MessageHeader();
+
+ /**
+ * True if the stream was obtained by invoking {@link #createExceptionReply()},
+ * false otherwise.
+ */
+ boolean exceptionReply;
+
+ /**
+ * The buffer to write into.
+ */
+ cdrBufOutput buffer;
+
+ /**
+ * The responsible POA.
+ */
+ final gnuPOA poa;
+
+ /**
+ * The servant delegate to obtain the handler.
+ */
+ gnuServantObject object;
+
+ /**
+ * Used (reused) with dynamic implementation.
+ */
+ LocalServerRequest serverRequest;
+
+ /**
+ * Create an instance of the local request.
+ */
+ public LocalRequest(gnuServantObject local_object, gnuPOA a_poa, byte[] an_id)
+ {
+ Id = an_id;
+ poa = a_poa;
+
+ // Instantiate the cookie holder only if required.
+ if (poa.servant_locator != null)
+ {
+ cookie = new CookieHolder();
+ }
+ object = local_object;
+ prepareStream();
+ }
+
+ /**
+ * Make an invocation and return a stream from where the results can be read
+ * and throw ApplicationException, where applicable.
+ */
+ org.omg.CORBA.portable.InputStream s_invoke(InvokeHandler handler)
+ throws ApplicationException
+ {
+ try
+ {
+ poa.m_orb.currents.put(Thread.currentThread(), this);
+
+ org.omg.CORBA.portable.InputStream input = v_invoke(handler);
+
+ if (!exceptionReply)
+ {
+ return input;
+ }
+ else
+ {
+ input.mark(500);
+
+ String id = input.read_string();
+ try
+ {
+ input.reset();
+ }
+ catch (IOException ex)
+ {
+ InternalError ierr = new InternalError();
+ ierr.initCause(ex);
+ throw ierr;
+ }
+ throw new ApplicationException(id, input);
+ }
+ }
+ finally
+ {
+ poa.m_orb.currents.remove(Thread.currentThread());
+ }
+ }
+
+ /**
+ * Make an invocation and return a stream from where the results can be read.
+ *
+ * @param the invoke handler (can be null, then it is obtained self
+ * dependently).
+ */
+ public org.omg.CORBA.portable.InputStream v_invoke(InvokeHandler handler)
+ {
+ // Local request must be intercepted both by server and request
+ // interceptors.
+ boolean s_intercept = false;
+ ServerRequestInterceptorOperations s_interceptor = null;
+ gnuServerRequestInfo s_info = null;
+
+ boolean c_intercept = false;
+ ClientRequestInterceptorOperations c_interceptor = null;
+ gnuClientRequestInfo c_info = null;
+
+ try
+ {
+ if (poa.m_orb.iServer != null || poa.m_orb.iClient != null)
+ {
+ setORB(poa.m_orb);
+
+ // These two are only needed with interceptors.
+ m_rqh = new RequestHeader();
+ m_rqh.operation = m_operation;
+ m_rph = new ReplyHeader();
+
+ m_rqh.object_key = object.Id;
+ m_rph.request_id = m_rqh.request_id;
+ }
+
+ if (poa.m_orb.iClient != null)
+ {
+ c_interceptor = poa.m_orb.iClient;
+
+ c_info = new gnuClientRequestInfo(this);
+ c_intercept = true;
+
+ c_interceptor.send_request(c_info);
+
+ m_target = object;
+ }
+
+ if (poa.m_orb.iServer != null)
+ {
+ s_interceptor = poa.m_orb.iServer;
+
+ s_info = new gnuServerRequestInfo(object, m_rqh, m_rph);
+ s_info.m_request = this;
+
+ s_intercept = true;
+
+ s_interceptor.receive_request_service_contexts(s_info);
+ }
+
+ if (handler == null)
+ {
+ handler = object.getHandler(operation(), cookie, false);
+ }
+
+ cdrBufOutput request_part = new cdrBufOutput();
+
+ request_part.setOrb(orb());
+
+ if (m_args != null && m_args.count() > 0)
+ {
+ write_parameters(header, request_part);
+
+ if (m_parameter_buffer != null)
+ {
+ throw new BAD_INV_ORDER("Please either add parameters or " +
+ "write them into stream, but not both " + "at once."
+ );
+ }
+ }
+
+ if (m_parameter_buffer != null)
+ {
+ write_parameter_buffer(header, request_part);
+ }
+
+ Servant servant;
+
+ if (handler instanceof Servant)
+ {
+ servant = (Servant) handler;
+ }
+ else
+ {
+ throw new BAD_OPERATION("Unexpected handler type " + handler);
+ }
+
+ org.omg.CORBA.portable.InputStream input =
+ request_part.create_input_stream();
+
+ // Ensure the servant (handler) has a delegate set.
+ servantDelegate sd = null;
+
+ Delegate d = null;
+
+ try
+ {
+ d = servant._get_delegate();
+ }
+ catch (Exception ex)
+ {
+ // In some cases exception is thrown if the delegate is not set.
+ }
+ if (d instanceof servantDelegate)
+ {
+ // If the delegate is already set, try to reuse the existing
+ // instance.
+ sd = (servantDelegate) d;
+ if (sd.object != object)
+ {
+ sd = new servantDelegate(servant, poa, Id);
+ }
+ }
+ else
+ {
+ sd = new servantDelegate(servant, poa, Id);
+ }
+ servant._set_delegate(sd);
+
+ try
+ {
+ ORB o = orb();
+ if (o instanceof ORB_1_4)
+ {
+ ((ORB_1_4) o).currents.put(Thread.currentThread(), this);
+ }
+
+ try
+ {
+ if (s_intercept)
+ {
+ s_interceptor.receive_request(s_info);
+ }
+ handler._invoke(m_operation, input, this);
+
+ // Handler is casted into i_handler.
+ if ((s_intercept || c_intercept) && isExceptionReply())
+ {
+ s_info.m_reply_header.reply_status =
+ ReplyHeader.USER_EXCEPTION;
+ m_rph.reply_status = ReplyHeader.USER_EXCEPTION;
+
+ // Make Any, holding the user exception.
+ Any a = new gnuAny();
+ OutputStream buf = getBuffer();
+ InputStream in = buf.create_input_stream();
+ String uex_idl = "unknown";
+ try
+ {
+ in.mark(Integer.MAX_VALUE);
+ uex_idl = in.read_string();
+ m_exception_id = uex_idl;
+ in.reset();
+ }
+ catch (IOException e)
+ {
+ throw new Unexpected(e);
+ }
+
+ try
+ {
+ UserException exception =
+ ObjectCreator.readUserException(uex_idl, in);
+
+ m_environment.exception(exception);
+ ObjectCreator.insertWithHelper(a, exception);
+ }
+ catch (Exception e)
+ {
+ // Failed due any reason, insert without
+ // helper.
+ a.insert_Streamable(new streamReadyHolder(
+ buf.create_input_stream()
+ )
+ );
+
+ recordTypeCode r =
+ new recordTypeCode(TCKind.tk_except);
+ r.setId(uex_idl);
+ r.setName(ObjectCreator.getDefaultName(uex_idl));
+ }
+
+ s_info.m_usr_exception = a;
+ c_info.m_wrapped_exception = a;
+ s_interceptor.send_exception(s_info);
+ c_interceptor.receive_exception(c_info);
+ }
+ else
+ {
+ if (s_intercept)
+ {
+ s_info.m_reply_header.reply_status =
+ ReplyHeader.NO_EXCEPTION;
+ s_interceptor.send_reply(s_info);
+ }
+ if (c_intercept)
+ {
+ m_rph.reply_status = ReplyHeader.NO_EXCEPTION;
+ c_interceptor.receive_reply(c_info);
+ }
+ }
+ }
+ catch (SystemException sys_ex)
+ {
+ if (s_intercept)
+ {
+ s_info.m_reply_header.reply_status =
+ ReplyHeader.SYSTEM_EXCEPTION;
+ s_info.m_sys_exception = sys_ex;
+ s_interceptor.send_exception(s_info);
+ }
+
+ if (c_intercept)
+ {
+ m_rph.reply_status = ReplyHeader.SYSTEM_EXCEPTION;
+
+ Any a = new gnuAny();
+ if (ObjectCreator.insertSysException(a, sys_ex))
+ {
+ c_info.m_wrapped_exception = a;
+ }
+ c_interceptor.receive_exception(c_info);
+ }
+
+ throw sys_ex;
+ }
+ }
+ finally
+ {
+ ORB o = orb();
+ if (o instanceof ORB_1_4)
+ {
+ ((ORB_1_4) o).currents.remove(Thread.currentThread());
+ }
+ }
+
+ if (poa.servant_locator != null)
+ {
+ poa.servant_locator.postinvoke(object.Id, poa, operation(),
+ cookie.value, object.getServant()
+ );
+ }
+ return buffer.create_input_stream();
+ }
+
+ catch (ForwardRequest fex)
+ {
+ // May be thrown by interceptor.
+ if (s_intercept)
+ {
+ Forwarding:
+ while (true)
+ {
+ s_info.m_reply_header.reply_status =
+ ReplyHeader.LOCATION_FORWARD;
+ s_info.m_forward_reference = fex.forward;
+ try
+ {
+ s_interceptor.send_other(s_info);
+ break Forwarding;
+ }
+ catch (ForwardRequest fex2)
+ {
+ s_info.m_forward_reference = fex2.forward;
+ fex.forward = s_info.m_forward_reference;
+ }
+ }
+ }
+
+ if (c_intercept)
+ {
+ this.m_rph.reply_status = ReplyHeader.LOCATION_FORWARD;
+ this.m_forwarding_target = fex.forward;
+ try
+ {
+ c_interceptor.receive_other(c_info);
+ }
+ catch (ForwardRequest fex2)
+ {
+ fex.forward = fex2.forward;
+ }
+ }
+ throw new gnuForwardRequest(fex.forward);
+ }
+ catch (gnuForwardRequest fex)
+ {
+ // May be thrown during activation.
+ // May be thrown during activation.
+ if (s_intercept)
+ {
+ Forwarding:
+ while (true)
+ {
+ s_info.m_reply_header.reply_status =
+ ReplyHeader.LOCATION_FORWARD;
+ s_info.m_forward_reference = fex.forward_reference;
+ try
+ {
+ s_interceptor.send_other(s_info);
+ break Forwarding;
+ }
+ catch (ForwardRequest fex2)
+ {
+ s_info.m_forward_reference = fex2.forward;
+ fex.forward_reference = (ObjectImpl) fex2.forward;
+ }
+ }
+ }
+
+ if (c_intercept)
+ {
+ this.m_rph.reply_status = ReplyHeader.LOCATION_FORWARD;
+ this.m_forwarding_target = fex.forward_reference;
+ try
+ {
+ c_interceptor.receive_other(c_info);
+ }
+ catch (ForwardRequest fex2)
+ {
+ fex.forward_reference = (ObjectImpl) fex2.forward;
+ }
+ }
+ throw fex;
+ }
+ }
+
+ /**
+ * Make an invocation and store the result in the fields of this Request. Used
+ * with DII only.
+ */
+ public void invoke()
+ {
+ InvokeHandler handler = object.getHandler(operation(), cookie, false);
+
+ if (handler instanceof dynImpHandler)
+ {
+ DynamicImplementation dyn = ((dynImpHandler) handler).servant;
+ if (serverRequest == null)
+ {
+ serverRequest = new LocalServerRequest(this);
+ }
+ try
+ {
+ poa.m_orb.currents.put(Thread.currentThread(), this);
+ dyn.invoke(serverRequest);
+ }
+ finally
+ {
+ poa.m_orb.currents.remove(Thread.currentThread());
+ }
+ }
+ else
+ {
+ org.omg.CORBA.portable.InputStream input = v_invoke(handler);
+
+ if (!exceptionReply)
+ {
+ NamedValue arg;
+
+ // Read return value, if set.
+ if (m_result != null)
+ {
+ m_result.value().read_value(input, m_result.value().type());
+ }
+
+ // Read returned parameters, if set.
+ if (m_args != null)
+ {
+ for (int i = 0; i < m_args.count(); i++)
+ {
+ try
+ {
+ arg = m_args.item(i);
+
+ // Both ARG_INOUT and ARG_OUT have this binary flag set.
+ if ((arg.flags() & ARG_OUT.value) != 0)
+ {
+ arg.value().read_value(input, arg.value().type());
+ }
+ }
+ catch (Bounds ex)
+ {
+ Unexpected.error(ex);
+ }
+ }
+ }
+ }
+ else// User exception reply
+ {
+ // Prepare an Any that will hold the exception.
+ gnuAny exc = new gnuAny();
+
+ exc.insert_Streamable(new streamReadyHolder(input));
+
+ UnknownUserException unuex = new UnknownUserException(exc);
+ m_environment.exception(unuex);
+ }
+ }
+ }
+
+ /**
+ * Get an output stream for providing details about the exception. Before
+ * returning the stream, the handler automatically writes the message header
+ * and the reply about exception header, but not the message header.
+ *
+ * @return the stream to write exception details into.
+ */
+ public OutputStream createExceptionReply()
+ {
+ exceptionReply = true;
+ prepareStream();
+ return buffer;
+ }
+
+ /**
+ * Get an output stream for writing a regular reply (not an exception).
+ *
+ * Before returning the stream, the handler automatically writes the regular
+ * reply header, but not the message header.
+ *
+ * @return the output stream for writing a regular reply.
+ */
+ public OutputStream createReply()
+ {
+ exceptionReply = false;
+ prepareStream();
+ return buffer;
+ }
+
+ /**
+ * Get the buffer, normally containing the written reply. The reply includes
+ * the reply header (or the exception header) but does not include the message
+ * header.
+ *
+ * The stream buffer can also be empty if no data have been written into
+ * streams, returned by {@link #createReply()} or
+ * {@link #createExceptionReply()}.
+ *
+ * @return the CDR output stream, containing the written output.
+ */
+ cdrBufOutput getBuffer()
+ {
+ return buffer;
+ }
+
+ /**
+ * True if the stream was obtained by invoking {@link #createExceptionReply()},
+ * false otherwise (usually no-exception reply).
+ */
+ boolean isExceptionReply()
+ {
+ return exceptionReply;
+ }
+
+ /**
+ * Compute the header offset, set the correct version number and codeset.
+ */
+ private void prepareStream()
+ {
+ buffer = new cdrBufOutput();
+ buffer.setOrb(orb());
+ }
+
+ /**
+ * Get the parameter stream, where the invocation arguments should be written
+ * if they are written into the stream directly.
+ */
+ public streamRequest getParameterStream()
+ {
+ m_parameter_buffer = new streamRequest();
+ m_parameter_buffer.request = this;
+ m_parameter_buffer.setOrb(poa.orb());
+ return m_parameter_buffer;
+ }
+
+ public byte[] get_object_id() throws NoContext
+ {
+ return Id;
+ }
+
+ public POA get_POA() throws NoContext
+ {
+ return poa;
+ }
+}
\ No newline at end of file
--- /dev/null
+/* LocalServerRequest.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., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 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.Poa;
+
+import gnu.CORBA.gnuNamedValue;
+
+import org.omg.CORBA.ARG_INOUT;
+import org.omg.CORBA.ARG_OUT;
+import org.omg.CORBA.Any;
+import org.omg.CORBA.BAD_PARAM;
+import org.omg.CORBA.Bounds;
+import org.omg.CORBA.Context;
+import org.omg.CORBA.NVList;
+import org.omg.CORBA.NamedValue;
+import org.omg.CORBA.ServerRequest;
+import org.omg.CORBA.UnknownUserException;
+
+/**
+ * Used to make local invocations via LocalRequest.
+ *
+ * @author Audrius Meskauskas, Lithuania (AudriusA@Bioinformatics.org)
+ */
+public class LocalServerRequest
+ extends ServerRequest
+{
+ /**
+ * The local request, on the base of that this instance is created.
+ */
+ final LocalRequest request;
+
+ /**
+ * Create a new instance.
+ */
+ public LocalServerRequest(LocalRequest _request)
+ {
+ request = _request;
+ }
+
+ /**
+ * Get the argument list that can be modified.
+ */
+ public void params(NVList args)
+ {
+ arguments(args);
+ }
+
+ /**
+ * Get contexts.
+ */
+ public Context ctx()
+ {
+ return request.ctx();
+ }
+
+ /**
+ * Get the operatin being performed.
+ */
+ public String operation()
+ {
+ return request.operation();
+ }
+
+ /**
+ * Get the argument list that can be modified.
+ * The direction depends on the size of the passed list.
+ * The empty list is filled with the request arguments.
+ * The non-empty list is used to set the request arguments.
+ */
+ public void arguments(NVList args)
+ {
+ NVList l = request.arguments();
+ NamedValue a;
+
+ try
+ {
+ if (args.count() == 0)
+ {
+ // Transfer to the passed parameter.
+ for (int i = 0; i < l.count(); i++)
+ {
+ a = l.item(i);
+ args.add_value(a.name(), a.value(), a.flags());
+ }
+ }
+ else
+ {
+ // Transfer from the passed parameter.
+ if (l.count() != args.count())
+ throw new BAD_PARAM("Argument number mismatch, current " +
+ l.count() + ", passed " + args.count()
+ );
+ try
+ {
+ for (int i = 0; i < l.count(); i++)
+ {
+ a = l.item(i);
+ if (a.flags() == ARG_INOUT.value ||
+ a.flags() == ARG_OUT.value
+ )
+ {
+ ((gnuNamedValue) a).setValue(args.item(i).value());
+ }
+ }
+ }
+ catch (ClassCastException cex)
+ {
+ InternalError ierr = new InternalError();
+ ierr.initCause(cex);
+ throw ierr;
+ }
+ }
+ }
+ catch (Bounds ex)
+ {
+ InternalError ierr = new InternalError();
+ ierr.initCause(ex);
+ throw ierr;
+ }
+ }
+
+ /**
+ * Set the result.
+ */
+ public void set_result(Any result)
+ {
+ gnuNamedValue g = new gnuNamedValue();
+ g.setValue(result);
+ g.setFlags(ARG_OUT.value);
+ request.set_result(g);
+ }
+
+ /**
+ * Get the name of the method being called.
+ */
+ public String op_name()
+ {
+ return request.operation();
+ }
+
+ /**
+ * Set the exception that has been thrown.
+ */
+ public void set_exception(Any exc)
+ {
+ request.env().exception(new UnknownUserException(exc));
+ }
+
+ /**
+ * Set the result.
+ */
+ public void result(Any r)
+ {
+ set_result(r);
+ }
+
+ /**
+ * Set the exception.
+ */
+ public void except(Any exc)
+ {
+ set_exception(exc);
+ }
+}
\ No newline at end of file
--- /dev/null
+/* ORB_1_4.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., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 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.Poa;
+
+import gnu.CORBA.Functional_ORB;
+import gnu.CORBA.IOR;
+import gnu.CORBA.Connected_objects.cObject;
+import gnu.CORBA.DynAn.gnuDynAnyFactory;
+import gnu.CORBA.Interceptor.ClientRequestInterceptors;
+import gnu.CORBA.Interceptor.IORInterceptors;
+import gnu.CORBA.Interceptor.Registrator;
+import gnu.CORBA.Interceptor.ServerRequestInterceptors;
+import gnu.CORBA.Interceptor.gnuIcCurrent;
+import gnu.CORBA.Interceptor.gnuIorInfo;
+
+import org.omg.CORBA.Any;
+import org.omg.CORBA.BAD_OPERATION;
+import org.omg.CORBA.BAD_PARAM;
+import org.omg.CORBA.OBJECT_NOT_EXIST;
+import org.omg.CORBA.Policy;
+import org.omg.CORBA.PolicyError;
+import org.omg.CORBA.portable.ObjectImpl;
+import org.omg.PortableInterceptor.PolicyFactory;
+import org.omg.PortableServer.POA;
+import org.omg.PortableServer.POAPackage.InvalidPolicy;
+
+import java.applet.Applet;
+import java.util.Properties;
+
+/**
+ * The ORB, supporting POAs that are the feature of jdk 1.4.
+ *
+ * @author Audrius Meskauskas, Lithuania (AudriusA@Bioinformatics.org)
+ */
+public class ORB_1_4
+ extends Functional_ORB
+{
+ /**
+ * The root POA.
+ */
+ public final gnuPOA rootPOA;
+
+ /**
+ * Maps the active threads to the invocation data ("POA Current's").
+ */
+ public gnuPoaCurrent currents = new gnuPoaCurrent();
+
+ /**
+ * Maps the active threads to the interceptor data ("Interceptor Current's").
+ */
+ public gnuIcCurrent ic_current = new gnuIcCurrent(this);
+
+ /**
+ * Creates dynamic anys.
+ */
+ public gnuDynAnyFactory factory = new gnuDynAnyFactory(this);
+
+ /**
+ * Calls the parent constructor and additionally puts the "RootPOA",
+ * "RootPOAManager", "POACurrent" and "DynAnyFactory" into initial references.
+ */
+ public ORB_1_4()
+ {
+ super();
+ try
+ {
+ rootPOA = new gnuPOA(null, "RootPOA", null, policySets.rootPoa(), this);
+ }
+ catch (InvalidPolicy ex)
+ {
+ // Invalid default policy set.
+ InternalError ierr = new InternalError();
+ ierr.initCause(ex);
+ throw ierr;
+ }
+ initial_references.put("RootPOA", rootPOA);
+ initial_references.put("RootPOAManager", rootPOA.the_POAManager());
+ initial_references.put("POACurrent", currents);
+ initial_references.put("DynAnyFactory", factory);
+ initial_references.put("PICurrent", ic_current);
+ }
+
+ /**
+ * If the super method detects that the object is not connected to this ORB,
+ * try to find and activate the object.
+ */
+ public String object_to_string(org.omg.CORBA.Object forObject)
+ {
+ try
+ {
+ return super.object_to_string(forObject);
+ }
+ catch (Exception ex)
+ {
+ try
+ {
+ activeObjectMap.Obj exists = rootPOA.findObject(forObject);
+ if (exists == null)
+ throw new OBJECT_NOT_EXIST(forObject == null ? "null"
+ : forObject.toString());
+ else if (exists.poa instanceof gnuPOA)
+ ((gnuPOA) exists.poa).connect_to_orb(exists.key, forObject);
+ else
+ exists.poa.create_reference_with_id(exists.key,
+ ((ObjectImpl) exists.object)._ids()[0]);
+ }
+ catch (Exception bex)
+ {
+ BAD_PARAM bad = new BAD_PARAM("Unable to activate " + forObject);
+ bad.initCause(bex);
+ throw bad;
+ }
+
+ return super.object_to_string(forObject);
+ }
+ }
+
+ /**
+ * Destroy all poas and then call the superclass method.
+ */
+ public void destroy()
+ {
+ // This will propagate through the whole POA tree.
+ rootPOA.destroy(true, false);
+
+ super.destroy();
+ }
+
+ /**
+ * Do interceptor registration.
+ *
+ * @param properties the properties, between those names the agreed prefix
+ * "org.omg.PortableInterceptor.ORBInitializerClass." is searched.
+ *
+ * @param args the string array, passed to the ORB.init
+ */
+ protected void registerInterceptors(Properties properties, String[] args)
+ {
+ Registrator registrator = new Registrator(this, properties, args);
+
+ policyFactories = registrator.m_policyFactories;
+
+ registrator.pre_init();
+ initial_references.putAll(registrator.getRegisteredReferences());
+ registrator.post_init();
+
+ if (registrator.hasIorInterceptors())
+ iIor = new IORInterceptors(registrator);
+
+ if (registrator.hasServerRequestInterceptors())
+ iServer = new ServerRequestInterceptors(registrator);
+
+ if (registrator.hasClientRequestInterceptors())
+ iClient = new ClientRequestInterceptors(registrator);
+
+ policyFactories = registrator.m_policyFactories;
+ }
+
+ /**
+ * Create IOR and allow registered interceptors to add additional components.
+ */
+ protected IOR createIOR(cObject ref)
+ throws BAD_OPERATION
+ {
+ IOR ior = super.createIOR(ref);
+ if (iIor != null)
+ {
+ activeObjectMap.Obj obj = rootPOA.findIorKey(ior.key);
+
+ POA poa;
+
+ // Null means that the object was connected to the ORB directly.
+ if (obj == null)
+ poa = rootPOA;
+ else
+ poa = obj.poa;
+
+ gnuIorInfo info = new gnuIorInfo(this, poa, ior);
+
+ // This may modify the ior.
+ iIor.establish_components(info);
+ }
+ return ior;
+ }
+
+ /**
+ * Create policy using the previously registered factory.
+ */
+ public Policy create_policy(int type, Any value)
+ throws PolicyError
+ {
+ Integer policy = new Integer(type);
+
+ PolicyFactory forge = (PolicyFactory) policyFactories.get(policy);
+ if (forge == null)
+ throw new PolicyError("No factory registered for policy " + type,
+ (short) type);
+ else
+ return forge.create_policy(type, value);
+ }
+
+ /**
+ * Set the parameters and then register interceptors.
+ */
+ protected void set_parameters(Applet app, Properties props)
+ {
+ super.set_parameters(app, props);
+ registerInterceptors(props, new String[0]);
+ }
+
+ /**
+ * Set the parameters and then register interceptors.
+ */
+ protected void set_parameters(String[] para, Properties props)
+ {
+ super.set_parameters(para, props);
+ registerInterceptors(props, para);
+ }
+
+}
\ No newline at end of file
--- /dev/null
+/* activeObjectMap.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., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 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.Poa;
+
+import gnu.CORBA.ByteArrayComparator;
+
+import org.omg.PortableServer.POA;
+import org.omg.PortableServer.Servant;
+
+import java.util.Iterator;
+import java.util.Map;
+import java.util.Set;
+import java.util.TreeMap;
+
+/**
+ * Implements the conception of the Active Object Map.
+ * If the POA supports the RETAIN policy, it maintains an Active
+ * Object Map, that associates Object Ids with active servants.
+ * Each association constitutes an active object. We use a single map
+ * for all POAs on the given orb.
+ *
+ * @author Audrius Meskauskas, Lithuania (AudriusA@Bioinformatics.org)
+ */
+public class activeObjectMap
+{
+ /**
+ * The reference data about the object, placed on the AOM.
+ */
+ public class Obj
+ {
+ /**
+ * Create an initialised instance.
+ */
+ Obj(org.omg.CORBA.Object _object, byte[] _key, Servant _servant, POA _poa)
+ {
+ object = _object;
+ key = _key;
+ servant = _servant;
+ poa = _poa;
+ }
+
+ /**
+ * The object.
+ */
+ public final org.omg.CORBA.Object object;
+
+ /**
+ * The servant, serving the given object.
+ */
+ public Servant servant;
+
+ /**
+ * The local servant that once served this object.
+ * This field is used by {@link ForwardedServant} when it discovers that
+ * the forwarding chaing returns back to the original location.
+ * It should not be used anywhere else.
+ */
+ Servant primary_servant;
+
+ /**
+ * The POA, where the object is connected.
+ */
+ public final POA poa;
+
+ /**
+ * The object key.
+ */
+ public final byte[] key;
+
+ /**
+ * If true, this entry is deactivated.
+ */
+ public boolean deactivated;
+
+ /**
+ * Set the servant value, preserving any non null
+ * value as the primary servant.
+ */
+ public void setServant(Servant s)
+ {
+ if (primary_servant == null)
+ primary_servant = s;
+ servant = s;
+ }
+
+ /**
+ * Get the servant.
+ */
+ public Servant getServant()
+ {
+ return servant;
+ }
+
+ /**
+ * Get the deactivation state.
+ */
+ public boolean isDeactiveted()
+ {
+ return deactivated;
+ }
+
+ /**
+ * Set the deactivation state.
+ */
+ public void setDeactivated(boolean state)
+ {
+ deactivated = state;
+ }
+
+ public boolean equals(java.lang.Object other)
+ {
+ if (other instanceof Obj)
+ {
+ Obj o = (Obj) other;
+ return o.object.equals(object);
+ }
+ else
+ return false;
+ }
+ }
+
+ /**
+ * The free number to give for the next instance.
+ * This field is incremented each time the
+ * new collection of the connected objects is created.
+ * Each collection has its own unique instance number.
+ */
+ private static long free_id;
+
+ /**
+ * The map of the all connected objects, maps the object key to the
+ * object.
+ */
+ Map objects = new TreeMap(new ByteArrayComparator());
+
+ /**
+ * Get the record of the stored object. If the object is mapped
+ * several times under the different keys, one of the mappings
+ * is used.
+ *
+ * @param object the stored object
+ *
+ * @return the record about the stored object, null if
+ * this object is not stored here.
+ */
+ public Obj findObject(org.omg.CORBA.Object stored_object)
+ {
+ if (stored_object == null)
+ return null;
+
+ Map.Entry item;
+ Iterator iter = objects.entrySet().iterator();
+ Obj ref;
+
+ while (iter.hasNext())
+ {
+ item = (Map.Entry) iter.next();
+ ref = (Obj) item.getValue();
+ if (stored_object.equals(ref.object))
+ return ref;
+ }
+ return null;
+ }
+
+ /**
+ * Find the reference info for the given servant.
+ * If the servant is mapped to several objects, this
+ * returns the first found occurence.
+ *
+ * @param servant a servant to find.
+ *
+ * @return the servant/object/POA binding or null if no such found.
+ */
+ public Obj findServant(Servant servant)
+ {
+ if (servant == null)
+ return null;
+
+ Map.Entry item;
+ Iterator iter = objects.entrySet().iterator();
+ Obj ref;
+
+ while (iter.hasNext())
+ {
+ item = (Map.Entry) iter.next();
+ ref = (Obj) item.getValue();
+ if (servant.equals(ref.servant))
+ return ref;
+ }
+ return null;
+ }
+
+ /**
+ * Find the reference info for the given servant.
+ * If the servant is mapped to several objects, this
+ * returns the first found occurence.
+ *
+ * @param servant a servant to find.
+ * @param speficies if to search for the inactive (true) or active
+ * (false) servant. A servant with unmatching activity is ignored
+ * by this method.
+ *
+ * @return the servant/object/POA binding or null if no such found.
+ */
+ public Obj findServant(Servant servant, boolean inactive)
+ {
+ if (servant == null)
+ return null;
+
+ Map.Entry item;
+ Iterator iter = objects.entrySet().iterator();
+ Obj ref;
+
+ while (iter.hasNext())
+ {
+ item = (Map.Entry) iter.next();
+ ref = (Obj) item.getValue();
+ if (ref.deactivated == inactive)
+ if (ref.servant != null)
+ if (servant.equals(ref.servant))
+ return ref;
+ }
+ return null;
+ }
+
+ /**
+ * Add the new object to the repository. The object key is
+ * generated automatically.
+ *
+ * @param object the object to add.
+ * @param servant a servant, serving the given object.
+ * @param poa the poa, where the object is connected.
+ *
+ * @return the newly created object record.
+ */
+ public Obj add(org.omg.CORBA.Object object, Servant servant, POA poa)
+ {
+ return add(generateObjectKey(object), object, servant, poa);
+ }
+
+ /**
+ * Add the new object to the repository.
+ *
+ * @param key the object key.
+ * @param object the object to add.
+ * @param servant a servant, serving the given object.
+ * @param poa the POA, where the object is connected.
+ */
+ public Obj add(byte[] key, org.omg.CORBA.Object object, Servant servant,
+ POA poa
+ )
+ {
+ Obj rec = new Obj(object, key, servant, poa);
+ objects.put(key, rec);
+ return rec;
+ }
+
+ /**
+ * Add the new object to the repository.
+ *
+ * @param delegate the delegate, providing data about the servant, key, POA
+ * and object.
+ * @param port the port that this object would take.
+ */
+ public Obj add(servantDelegate delegate)
+ {
+ Obj rec =
+ new Obj(delegate.object, delegate.servant_id, delegate.servant,
+ delegate.poa
+ );
+ objects.put(delegate.servant_id, rec);
+ return rec;
+ }
+
+ /**
+ * Put back the definition structure that has probably been removed earlier.
+ */
+ public void put(Obj obj)
+ {
+ objects.put(obj.key, obj);
+ }
+
+ /**
+ * Get the stored object.
+ *
+ * @param key the key (in the byte array form).
+ *
+ * @return the matching object, null if none is matching.
+ */
+ public Obj get(byte[] key)
+ {
+ return (Obj) objects.get(key);
+ }
+
+ /**
+ * Get the map key set.
+ */
+ public Set keySet()
+ {
+ return objects.keySet();
+ }
+
+ /**
+ * Remove the given object, indiciating it by the key.
+ *
+ * @param object the object to remove.
+ */
+ public void remove(byte[] key)
+ {
+ objects.remove(key);
+ }
+
+ /**
+ * Generate the object key, unique in the currently
+ * running java virtual machine. The passed object
+ * parameter is currently not in use.
+ *
+ * @return the generated key.
+ */
+ protected byte[] generateObjectKey(org.omg.CORBA.Object object)
+ {
+ byte[] key;
+
+ // The repetetive keys cannot be generated, but theoretically
+ // the same keys can be passed when calling add(byte[]...).
+ // Hence we check if the key is not already in the map and,
+ // if it is, use the subsequent value.
+ do
+ {
+ key = getFreeId();
+ }
+ while (objects.containsKey(key));
+ return key;
+ }
+
+ /**
+ * Get the next free 8 byte id, surely unique between calls of this
+ * method for the currently running virtual machine.
+ */
+ public static synchronized byte[] getFreeId()
+ {
+ byte[] r = new byte[ 8 ];
+
+ // Start from the faster-changing.
+ r [ 0 ] = ((byte) (0xff & free_id));
+ r [ 1 ] = ((byte) (0xff & (free_id >> 8)));
+ r [ 2 ] = ((byte) (0xff & (free_id >> 16)));
+ r [ 3 ] = ((byte) (0xff & (free_id >> 24)));
+ r [ 4 ] = ((byte) (0xff & (free_id >> 32)));
+ r [ 5 ] = ((byte) (0xff & (free_id >> 40)));
+ r [ 6 ] = ((byte) (0xff & (free_id >> 48)));
+ r [ 7 ] = ((byte) (0xff & (free_id >> 56)));
+
+ free_id++;
+
+ return r;
+ }
+}
\ No newline at end of file
--- /dev/null
+/* dynImpHandler.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., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 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.Poa;
+
+import org.omg.CORBA.BAD_OPERATION;
+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.PortableServer.DynamicImplementation;
+
+/**
+ * The InvokeHandler, indicating, that the target is a dynamic
+ * implementation rather than an invoke handler. These two
+ * types are not substitutable, but in some methods have possibility
+ * just to handle them differently.
+ *
+ * @author Audrius Meskauskas, Lithuania (AudriusA@Bioinformatics.org)
+ */
+public class dynImpHandler
+ implements InvokeHandler
+{
+ /**
+ * The servant that is a dynamic implementation rather than
+ * invoke handler.
+ */
+ public final DynamicImplementation servant;
+
+ /**
+ * Create a new instance, wrapping some dyn implementation.
+ * @param _servant
+ */
+ public dynImpHandler(DynamicImplementation _servant)
+ {
+ servant = _servant;
+ }
+
+ /**
+ * We cannot invoke properly without having parameter info.
+ *
+ * @throws BAD_OPERATION, always.
+ */
+ public OutputStream _invoke(String method, InputStream input,
+ ResponseHandler handler
+ )
+ {
+ throw new BAD_OPERATION(servant + " is not an InvokeHandler.");
+ }
+}
\ No newline at end of file
--- /dev/null
+/* gnuAdapterActivator.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., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 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.Poa;
+
+import org.omg.CORBA.LocalObject;
+import org.omg.PortableServer.AdapterActivator;
+import org.omg.PortableServer.POA;
+
+/**
+ * Defines a simple adapter activator.
+ *
+ * @author Audrius Meskauskas, Lithuania (AudriusA@Bioinformatics.org)
+ */
+public class gnuAdapterActivator
+ extends LocalObject
+ implements AdapterActivator
+{
+ /**
+ * Create a new POA on the parent, using the parent policy set
+ * from the suitable parent of grandparend and with independent
+ * POA manager (passing null to the createPOA).
+ *
+ * @param parent a parent. Either this parent or one of its
+ * grandparents must be gnuAbstractPOA, able to provide a
+ * policy set.
+ *
+ * @param child_name the name of the child being created.
+ *
+ * @return true on success or false if no gnuAbstractPOA
+ * found till the root poa.
+ */
+ public boolean unknown_adapter(POA parent, String child_name)
+ {
+ try
+ {
+ POA n = parent.create_POA(child_name, null, policySets.rootPoa());
+ n.the_POAManager().activate();
+ }
+ catch (Exception ex)
+ {
+ return false;
+ }
+ return true;
+ }
+}
\ No newline at end of file
--- /dev/null
+/* gnuForwardRequest.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., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 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.Poa;
+
+import gnu.CORBA.GIOP.ReplyHeader;
+
+import org.omg.CORBA.BAD_PARAM;
+import org.omg.CORBA.portable.ObjectImpl;
+
+/**
+ * The class, indicating that the request should be forwarded to another
+ * target. We cannot use ForwardRequest because the exception is throws
+ * from methods that does not declare throwing it. Hence must be
+ * RuntimeException.
+ *
+ * @author Audrius Meskauskas, Lithuania (AudriusA@Bioinformatics.org)
+ */
+public class gnuForwardRequest
+ extends RuntimeException
+{
+ /**
+ * Use serialVersionUID (v1.4) for interoperability.
+ */
+ private static final long serialVersionUID = -1L;
+
+ /**
+ * The object reference, indicating the new location of the invocation target.
+ */
+ public ObjectImpl forward_reference;
+
+ /**
+ * This information shows if we use LOCATION_FORWARD or
+ * LOCATION_FORWARD_PERM in request. By defalult, LOCATION_FORWARD
+ * is always used. To use LOCATION_FORWARD_PERM, this exception should
+ * be thrown from the servant manager instead of ForwardRequest,
+ * with this field set to ReplyHeader.LOCATION_FORWARD_PERM.
+ */
+ public byte forwarding_code = ReplyHeader.LOCATION_FORWARD;
+
+ /**
+ * Create the ForwardRequest with explaining message and
+ * initialising the object reference to the given value.
+ *
+ * @param why a string, explaining, why this exception has been thrown.
+ * @param a_forward_reference a value for forward_reference.
+ */
+ public gnuForwardRequest(org.omg.CORBA.Object a_forward_reference)
+ {
+ if (a_forward_reference instanceof ObjectImpl)
+ this.forward_reference = (ObjectImpl) a_forward_reference;
+ else
+ throw new BAD_PARAM("ObjectImpl expected");
+ }
+}
\ No newline at end of file
--- /dev/null
+/* gnuIdAssignmentPolicy.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., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 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.Poa;
+
+import gnu.CORBA._PolicyImplBase;
+
+import org.omg.PortableServer.ID_ASSIGNMENT_POLICY_ID;
+import org.omg.PortableServer.IdAssignmentPolicy;
+import org.omg.PortableServer.IdAssignmentPolicyValue;
+
+/**
+ * Implementation of the id assignment policy.
+ *
+ * @author Audrius Meskauskas, Lithuania (AudriusA@Bioinformatics.org)
+ */
+public class gnuIdAssignmentPolicy
+ extends _PolicyImplBase
+ implements IdAssignmentPolicy, vPolicy
+{
+ /**
+ * Use serialVersionUID for interoperability.
+ */
+ private static final long serialVersionUID = 1L;
+
+ /**
+ * Create the policy.
+ *
+ * @param v a value for the policy.
+ */
+ public gnuIdAssignmentPolicy(IdAssignmentPolicyValue v)
+ {
+ super(ID_ASSIGNMENT_POLICY_ID.value, v, v.value(),
+ "IDL:org.omg/PortableServer/IdAssignmentPolicy:1.0"
+ );
+ }
+
+ /**
+ * Get the value for the policy that was passed in a constructor.
+ */
+ public IdAssignmentPolicyValue value()
+ {
+ return (IdAssignmentPolicyValue) getValue();
+ }
+}
\ No newline at end of file
--- /dev/null
+/* gnuIdUniquenessPolicy.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., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 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.Poa;
+
+import gnu.CORBA._PolicyImplBase;
+
+import org.omg.PortableServer.ID_UNIQUENESS_POLICY_ID;
+import org.omg.PortableServer.IdUniquenessPolicy;
+import org.omg.PortableServer.IdUniquenessPolicyValue;
+
+/**
+ * Implementation of the id uniqueness policy.
+ *
+ * @author Audrius Meskauskas, Lithuania (AudriusA@Bioinformatics.org)
+ */
+public class gnuIdUniquenessPolicy
+ extends _PolicyImplBase
+ implements IdUniquenessPolicy, vPolicy
+{
+ /**
+ * Use serialVersionUID for interoperability.
+ */
+ private static final long serialVersionUID = 1L;
+
+ /**
+ * Create the policy.
+ *
+ * @param v a value for the policy.
+ */
+ public gnuIdUniquenessPolicy(IdUniquenessPolicyValue v)
+ {
+ super(ID_UNIQUENESS_POLICY_ID.value, v, v.value(),
+ "IDL:org.omg/PortableServer/IdUniquenessPolicy:1.0"
+ );
+ }
+
+ /**
+ * Get the value for the policy that was passed in a constructor.
+ */
+ public IdUniquenessPolicyValue value()
+ {
+ return (IdUniquenessPolicyValue) getValue();
+ }
+}
\ No newline at end of file
--- /dev/null
+/* gnuImplicitActivationPolicy.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., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 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.Poa;
+
+import gnu.CORBA._PolicyImplBase;
+
+import org.omg.PortableServer.IMPLICIT_ACTIVATION_POLICY_ID;
+import org.omg.PortableServer.ImplicitActivationPolicy;
+import org.omg.PortableServer.ImplicitActivationPolicyValue;
+
+/**
+ * Implementation of the implicit activation policy.
+ *
+ * @author Audrius Meskauskas, Lithuania (AudriusA@Bioinformatics.org)
+ */
+public class gnuImplicitActivationPolicy
+ extends _PolicyImplBase
+ implements ImplicitActivationPolicy, vPolicy
+{
+ /**
+ * Use serialVersionUID for interoperability.
+ */
+ private static final long serialVersionUID = 1L;
+
+ /**
+ * Create the policy.
+ *
+ * @param v a value for the policy.
+ */
+ public gnuImplicitActivationPolicy(ImplicitActivationPolicyValue v)
+ {
+ super(IMPLICIT_ACTIVATION_POLICY_ID.value, v, v.value(),
+ "IDL:org.omg/PortableServer/ImplicitActivationPolicy:1.0"
+ );
+ }
+
+ /**
+ * Get the value for the policy that was passed in a constructor.
+ */
+ public ImplicitActivationPolicyValue value()
+ {
+ return (ImplicitActivationPolicyValue) getValue();
+ }
+}
\ No newline at end of file
--- /dev/null
+/* gnuLifespanPolicy.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., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 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.Poa;
+
+import gnu.CORBA._PolicyImplBase;
+
+import org.omg.PortableServer.LIFESPAN_POLICY_ID;
+import org.omg.PortableServer.LifespanPolicy;
+import org.omg.PortableServer.LifespanPolicyValue;
+
+/**
+ * The implementation of the life span policy.
+ *
+ * @author Audrius Meskauskas, Lithuania (AudriusA@Bioinformatics.org)
+ */
+public class gnuLifespanPolicy
+ extends _PolicyImplBase
+ implements LifespanPolicy, vPolicy
+{
+ /**
+ * Use serialVersionUID for interoperability.
+ */
+ private static final long serialVersionUID = 1L;
+
+ /**
+ * Create the policy.
+ *
+ * @param v a value for the policy.
+ */
+ public gnuLifespanPolicy(LifespanPolicyValue v)
+ {
+ super(LIFESPAN_POLICY_ID.value, v, v.value(),
+ "IDL:org.omg/PortableServer/LifespanPolicy:1.0"
+ );
+ }
+
+ /**
+ * Get the value for the policy that was passed in a constructor.
+ */
+ public LifespanPolicyValue value()
+ {
+ return (LifespanPolicyValue) getValue();
+ }
+}
\ No newline at end of file
--- /dev/null
+/* gnuAbstractPOA.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., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 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.Poa;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.HashSet;
+
+import org.omg.CORBA.BAD_INV_ORDER;
+import org.omg.CORBA.BAD_PARAM;
+import org.omg.CORBA.CompletionStatus;
+import org.omg.CORBA.LocalObject;
+import org.omg.CORBA.NO_IMPLEMENT;
+import org.omg.CORBA.OBJ_ADAPTER;
+import org.omg.CORBA.ORB;
+import org.omg.CORBA.Policy;
+import org.omg.CORBA.SetOverrideType;
+import org.omg.CORBA.TRANSIENT;
+import org.omg.CORBA.portable.ObjectImpl;
+import org.omg.PortableServer.AdapterActivator;
+import org.omg.PortableServer.ForwardRequest;
+import org.omg.PortableServer.IdAssignmentPolicy;
+import org.omg.PortableServer.IdAssignmentPolicyValue;
+import org.omg.PortableServer.IdUniquenessPolicy;
+import org.omg.PortableServer.IdUniquenessPolicyValue;
+import org.omg.PortableServer.ImplicitActivationPolicy;
+import org.omg.PortableServer.ImplicitActivationPolicyValue;
+import org.omg.PortableServer.LifespanPolicy;
+import org.omg.PortableServer.LifespanPolicyValue;
+import org.omg.PortableServer.POA;
+import org.omg.PortableServer.POAManager;
+import org.omg.PortableServer.RequestProcessingPolicy;
+import org.omg.PortableServer.RequestProcessingPolicyValue;
+import org.omg.PortableServer.SERVANT_RETENTION_POLICY_ID;
+import org.omg.PortableServer.Servant;
+import org.omg.PortableServer.ServantActivator;
+import org.omg.PortableServer.ServantLocator;
+import org.omg.PortableServer.ServantManager;
+import org.omg.PortableServer.ServantRetentionPolicy;
+import org.omg.PortableServer.ServantRetentionPolicyValue;
+import org.omg.PortableServer.ThreadPolicy;
+import org.omg.PortableServer.ThreadPolicyValue;
+import org.omg.PortableServer.POAManagerPackage.State;
+import org.omg.PortableServer.POAPackage.AdapterAlreadyExists;
+import org.omg.PortableServer.POAPackage.AdapterNonExistent;
+import org.omg.PortableServer.POAPackage.InvalidPolicy;
+import org.omg.PortableServer.POAPackage.NoServant;
+import org.omg.PortableServer.POAPackage.ObjectAlreadyActive;
+import org.omg.PortableServer.POAPackage.ObjectNotActive;
+import org.omg.PortableServer.POAPackage.ServantAlreadyActive;
+import org.omg.PortableServer.POAPackage.ServantNotActive;
+import org.omg.PortableServer.POAPackage.WrongAdapter;
+import org.omg.PortableServer.POAPackage.WrongPolicy;
+import gnu.CORBA.CDR.cdrBufInput;
+import gnu.CORBA.CDR.cdrBufOutput;
+
+/**
+ * Our POA implementation.
+ *
+ * @author Audrius Meskauskas, Lithuania (AudriusA@Bioinformatics.org)
+ */
+public class gnuPOA
+ extends LocalObject
+ implements POA
+{
+ /**
+ * The active object map, mapping between object keys, objects and servants.
+ */
+ public final activeObjectMap aom = new activeObjectMap();
+
+ /**
+ * The children of this POA.
+ */
+ final ArrayList children = new ArrayList();
+
+ /**
+ * The name of this POA.
+ */
+ final String name;
+
+ /**
+ * The parent of this POA (null for the root POA).
+ */
+ final POA parent;
+
+ /**
+ * The ior key signature, indicating, that the ior key is encoded using
+ * internal agreements of this implementation (0x'free').
+ */
+ static final int SIGNATURE = 0x66726565;
+
+ /**
+ * The adapter activator for this POA, null if no activator is set.
+ */
+ AdapterActivator m_activator;
+
+ /**
+ * The POA manager for this POA.
+ */
+ POAManager m_manager;
+
+ /**
+ * The servant manager (servant activator) for this POA.
+ */
+ ServantActivator servant_activator;
+
+ /**
+ * The servant manager (servant locator) for this POA.
+ */
+ ServantLocator servant_locator;
+
+ /**
+ * The default servant, if on is in use.
+ */
+ Servant default_servant;
+
+ /**
+ * The cached poa id value, computed once.
+ */
+ private byte[] m_poa_id;
+
+ /**
+ * The all policy values that apply to this POA.
+ * The used policy values are singletons, unique between policies.
+ */
+ private final HashSet m_policies;
+
+ /**
+ * An array of the set policies.
+ */
+ Policy[] s_policies;
+
+ /**
+ * The ORB, where the POA is connected.
+ */
+ final ORB_1_4 m_orb;
+
+ /**
+ * When true, the POA is being destroyed or is destroyed.
+ */
+ boolean m_inDestruction;
+
+ /**
+ * True if the active object map is used by this POA.
+ * The value is moved into separate boolean value due
+ * necessity of the frequent checks.
+ */
+ public final boolean retain_servant;
+
+ /**
+ * Create a new abstract POA.
+ *
+ * @param a_parent the parent of this POA.
+ * @param a_name a name for this POA.
+ * @param a_manager a manager for this POA. If null, a new
+ * {@link gnuPOAManager} will be instantiated.
+ * @param a_policies an array of policies that apply to this POA.
+ * @param an_orb an ORB for this POA.
+ */
+ public gnuPOA(gnuPOA a_parent, String a_name, POAManager a_manager,
+ Policy[] a_policies, ORB_1_4 an_orb
+ )
+ throws InvalidPolicy
+ {
+ // Add default policies.
+ Policy[] all_policies = policySets.withDefault(a_policies);
+
+ name = a_name;
+ parent = a_parent;
+ m_orb = an_orb;
+
+ if (a_manager != null)
+ m_manager = a_manager;
+ else
+ m_manager = new gnuPOAManager();
+
+ if (m_manager instanceof gnuPOAManager)
+ {
+ gnuPOAManager g = (gnuPOAManager) m_manager;
+ g.addPoa(this);
+ }
+
+ m_policies = new HashSet(all_policies.length);
+
+ s_policies = new Policy[ all_policies.length ];
+ for (int i = 0; i < s_policies.length; i++)
+ {
+ s_policies [ i ] = all_policies [ i ].copy();
+ m_policies.add(((vPolicy) s_policies [ i ]).getValue());
+ }
+
+ retain_servant = applies(ServantRetentionPolicyValue.RETAIN);
+
+ validatePolicies(a_policies);
+ }
+
+ /**
+ * Wait while at least one of the threads in this POA is actively
+ * processing one of requests.
+ */
+ public void waitWhileRunning()
+ {
+ // First pause.
+ long time = 1;
+
+ // Maximal duration between checks.
+ long max = 500;
+
+ boolean runs;
+
+ do
+ {
+ runs = m_orb.currents.has(this);
+
+ if (runs)
+ {
+ // Avoid taking CPU resources
+ // from the thread that is running.
+ try
+ {
+ Thread.sleep(time);
+ time = time * 2;
+ if (time > max)
+ time = max;
+ }
+ catch (InterruptedException ex)
+ {
+ }
+ }
+ }
+ while (runs);
+ }
+
+ /**
+ * Etherealize all objects, associated with this POA. Invoked from the
+ * {@link gnuPOAManager} only if it is known that the servant_activator
+ * holds non-null value.
+ */
+ protected void etherealizeAll()
+ {
+ if (servant_activator == null)
+ return;
+
+ ArrayList keys = new ArrayList();
+ keys.addAll(aom.keySet());
+
+ byte[] key;
+ activeObjectMap.Obj obj;
+ boolean last;
+ for (int i = 0; i < keys.size(); i++)
+ {
+ key = (byte[]) keys.get(i);
+ obj = aom.get(key);
+
+ if (obj.poa == this)
+ {
+ aom.remove(key);
+
+ if (!obj.isDeactiveted())
+ {
+ // Check if the servant still stays under the other key.
+ last = aom.findServant(obj.servant) == null;
+ servant_activator.etherealize(obj.key, this, obj.servant, true,
+ last
+ );
+ }
+ }
+ }
+ }
+
+ /**
+ * Create an instance of the POA with the given features.
+ * This method is not responsible for duplicate checking
+ * or adding the returned instance to any possible table.
+ *
+ * @param child_name the name of the poa being created.
+ * @param manager the poa manager (never null).
+ * @param policies the array of policies.
+ * @param an_orb the ORB for this POA.
+ *
+ * @return the created POA.
+ *
+ * @throws InvalidPolicy for conflicting or otherwise invalid policies.|
+ */
+ protected POA createPoaInstance(String child_name, POAManager a_manager,
+ Policy[] policies, ORB_1_4 an_orb
+ )
+ throws InvalidPolicy
+ {
+ POAManager some_manager =
+ a_manager == null ? new gnuPOAManager() : a_manager;
+
+ if (some_manager instanceof gnuPOAManager)
+ {
+ ((gnuPOAManager) some_manager).addPoa(this);
+ }
+
+ return new gnuPOA(this, child_name, some_manager, policies, an_orb);
+ }
+
+ /**
+ * Check if the given policy value applies to this POA.
+ *
+ * @param policy_value a policy value to check. The policy values are
+ * singletons and unique between the different policies, so the policy
+ * type is not passed.
+ *
+ * @return true if the policy value applies, false otherwise.
+ */
+ public final boolean applies(java.lang.Object policy_value)
+ {
+ return m_policies.contains(policy_value);
+ }
+
+ /**
+ * Check for the presence of the required policy.
+ *
+ * @param policy_value a policy value to check.
+ *
+ * @throws WrongPolicy if the required policy value is not applicable.
+ */
+ public final void required(java.lang.Object policy_value)
+ throws WrongPolicy
+ {
+ if (!applies(policy_value))
+ throw new WrongPolicy(policy_value + " policy required.");
+ }
+
+ /**
+ * Check for the absence of the given policy.
+ *
+ * @param policy_value a policy value to check.
+ *
+ * @throws WrongPolicy if the passed policy value is applicable.
+ */
+ public final void excluding(java.lang.Object policy_value)
+ throws WrongPolicy
+ {
+ if (applies(policy_value))
+ throw new WrongPolicy(policy_value + " policy applies.");
+ }
+
+ /**
+ * Find and optionally activate the child POA with the given name.
+ *
+ * @param poa_name the name of the POA to find.
+ * @param activate_it if the child with the specified name is not found
+ * or inactive and this parameter is true, the target POA activator is
+ * invoked to activate that child. If this succeeds, that child POA
+ * is returned.
+ *
+ * @throws AdapterNonExistent if no active child with the given name
+ * is found and one of the following is true:
+ * a) the target POA has no associated
+ * {@link AdapterActivator}. b) that activator fails to activate the
+ * child POA. c) <code>activate_id</code> = false.
+ */
+ public POA find_POA(String poa_name, boolean activate_it)
+ throws AdapterNonExistent
+ {
+ POA child;
+ for (int i = 0; i < children.size(); i++)
+ {
+ child = (POA) children.get(i);
+ if (child.the_name().equals(poa_name))
+ return child;
+ }
+
+ if (activate_it && m_activator != null)
+ {
+ boolean activated = m_activator.unknown_adapter(this, poa_name);
+ if (!activated)
+ throw new AdapterNonExistent(poa_name + " activation failed.");
+
+ // Tha activator should add the child to the childrent table.
+ for (int i = 0; i < children.size(); i++)
+ {
+ child = (POA) children.get(i);
+ if (child.the_name().equals(poa_name))
+ return child;
+ }
+ throw new AdapterNonExistent(poa_name + " not created. ");
+ }
+ else
+ throw new AdapterNonExistent(poa_name);
+ }
+
+ /**
+ * Generate the Object Id for the given servant and add the servant to
+ * the Active Object Map using this Id a a key. If the servant
+ * activator is set, its incarnate method will be called.
+ *
+ * @param a_servant a servant that would serve the object with the
+ * returned Object Id. If null is passed, under apporoprate policies the
+ * servant activator is invoked.
+ *
+ * @return the generated objert Id for the given servant.
+ *
+ * @throws ServantAlreadyActive if this servant is already in the
+ * Active Object Map and the UNIQUE_ID policy applies.
+ *
+ * @throws WrongPolicy if the required policies SYSTEM_ID and RETAIN
+ * do not apply to this POA.
+ */
+ public byte[] activate_object(Servant a_servant)
+ throws ServantAlreadyActive, WrongPolicy
+ {
+ checkDiscarding();
+ required(ServantRetentionPolicyValue.RETAIN);
+ required(IdAssignmentPolicyValue.SYSTEM_ID);
+
+ activeObjectMap.Obj exists = aom.findServant(a_servant);
+
+ if (exists != null)
+ {
+ if (exists.isDeactiveted())
+ {
+ // If exists but deactivated, activate and return
+ // the existing key.
+ exists.setDeactivated(false);
+ incarnate(exists, exists.key, a_servant, false);
+ return exists.key;
+ }
+ else if (applies(IdUniquenessPolicyValue.UNIQUE_ID))
+ throw new ServantAlreadyActive();
+
+ // It multiple ids are allowed, exit block allowing repetetive
+ // activations.
+ }
+
+ byte[] object_key = activeObjectMap.getFreeId();
+ servantDelegate delegate = new servantDelegate(a_servant, this, object_key);
+ connectDelegate(object_key, delegate);
+ return object_key;
+ }
+
+ /**
+ * Add the given servant to the Active Object Map as a servant for the
+ * object with the provided Object Id. If the servant activator is
+ * set, its incarnate method will be called.
+ *
+ * @param an_Object_Id an object id for the given object.
+ * @param a_servant a servant that will serve the object with the given
+ * Object Id. If null is passed, under apporoprate policies the
+ * servant activator is invoked.
+ *
+ * @throws ObjectAlreadyActive if the given object id is already in the
+ * Active Object Map.
+ * @throws ServantAlreadyActive if the UNIQUE_ID policy applies and
+ * this servant is already in use.
+ * @throws WrongPolicy if the required RETAIN policy does not apply to
+ * this POA.
+ * @throws BAD_PARAM if the passed object id is invalid due any reason.
+ */
+ public void activate_object_with_id(byte[] an_Object_Id, Servant a_servant)
+ throws ServantAlreadyActive, ObjectAlreadyActive,
+ WrongPolicy
+ {
+ activate_object_with_id(an_Object_Id, a_servant, false);
+ }
+
+ /**
+ * Same as activate_object_with_id, but permits gnuForwardRequest
+ * forwarding exception. This is used when the activation is called
+ * from the remote invocation context and we have possibility
+ * to return the forwarding message.
+ */
+ public void activate_object_with_id(byte[] an_Object_Id, Servant a_servant,
+ boolean use_forwarding
+ )
+ throws ServantAlreadyActive, ObjectAlreadyActive,
+ WrongPolicy
+ {
+ checkDiscarding();
+ required(ServantRetentionPolicyValue.RETAIN);
+
+ // If the UNIQUE_ID applies, the servant being passed must not be
+ // already active.
+ if (applies(IdUniquenessPolicyValue.UNIQUE_ID))
+ {
+ activeObjectMap.Obj sx = aom.findServant(a_servant, false);
+ if (sx != null)
+ throw new ServantAlreadyActive();
+ }
+
+ activeObjectMap.Obj exists = aom.get(an_Object_Id);
+ if (exists != null)
+ {
+ if (exists.servant == null)
+ {
+ locateServant(an_Object_Id, a_servant, exists, use_forwarding);
+ exists.setDeactivated(false);
+ }
+ else if (exists.isDeactiveted())
+ {
+ exists.setDeactivated(false);
+ incarnate(exists, an_Object_Id, a_servant, use_forwarding);
+ }
+ else
+ throw new ObjectAlreadyActive();
+ }
+ else
+ {
+ servantDelegate delegate =
+ new servantDelegate(a_servant, this, an_Object_Id);
+ connectDelegate(an_Object_Id, delegate);
+ }
+ }
+
+ /**
+ * Locate the servant for this object Id and connect it to ORB.
+ *
+ * @param an_Object_Id the object id.
+ * @param a_servant the servant (may be null).
+ * @param exists an existing active object map entry.
+ * @param use_forwarding allow to throw the gnuForwardRequest
+ * if the activator throws ForwardRequest.
+ *
+ * @throws OBJ_ADAPTER minor 4 if the servant cannot be located
+ * (the required servant manager may be missing).
+ */
+ private void locateServant(byte[] an_Object_Id, Servant a_servant,
+ activeObjectMap.Obj exists, boolean use_forwarding
+ )
+ throws InternalError
+ {
+ // An object was created with create_reference.
+ gnuServantObject object = (gnuServantObject) exists.object;
+ if (servant_activator != null)
+ {
+ exists.setServant(incarnate(exists, an_Object_Id, a_servant,
+ use_forwarding
+ )
+ );
+ }
+ else if (default_servant != null)
+ {
+ exists.setServant(default_servant);
+ }
+ if (exists.servant == null)
+ {
+ exists.setServant(a_servant);
+ }
+ if (exists.servant == null)
+ {
+ throw new OBJ_ADAPTER("no servant", 4, CompletionStatus.COMPLETED_NO);
+ }
+
+ servantDelegate delegate =
+ new servantDelegate(exists.servant, this, an_Object_Id);
+ exists.servant._set_delegate(delegate);
+ object.setServant(exists.servant);
+ connect_to_orb(an_Object_Id, delegate.object);
+ }
+
+ /**
+ * Deactivate object with the given id.
+ *
+ * The deactivated object will continue to process requests that arrived
+ * before decativation. If this POA has the associated
+ * servant manager, a {@link ServantActivatorOperations#etherealize} is
+ * immediately invoked on the passed id.
+ *
+ * @throws WrongPolicy if the required RETAIN policy does not apply to
+ * this POA.
+ */
+ public void deactivate_object(byte[] the_Object_Id)
+ throws ObjectNotActive, WrongPolicy
+ {
+ required(ServantRetentionPolicyValue.RETAIN);
+
+ activeObjectMap.Obj exists = aom.get(the_Object_Id);
+
+ if (exists == null || exists.isDeactiveted())
+ throw new ObjectNotActive();
+
+ exists.setDeactivated(true);
+
+ // Check if this servant is serving something else.
+ aom.remove(the_Object_Id);
+
+ activeObjectMap.Obj other = aom.findServant(exists.servant, false);
+
+ boolean remaining = other != null;
+
+ aom.put(exists);
+
+ if (servant_activator != null)
+ servant_activator.etherealize(the_Object_Id, this, exists.servant, false,
+ remaining
+ );
+ }
+
+ /**
+ * Create the object reference, encapsulating the given repository Id and
+ * the Object Id, generated by this POA. The returned object will not be
+ * activated by default and may be activated on the first invocation by
+ * the servant manager (if it is set and if policies are applicable).
+ *
+ * @param a_repository_id the repository id for the given object, can
+ * be null if to be requested from the servant later.
+ *
+ * @throws WrongPolicy if the required SYSTEM_ID policy does not apply to
+ * this POA.
+ */
+ public org.omg.CORBA.Object create_reference(String a_repository_id)
+ throws WrongPolicy
+ {
+ required(IdAssignmentPolicyValue.SYSTEM_ID);
+ return create_reference_with_id(activeObjectMap.getFreeId(), a_repository_id);
+ }
+
+ /**
+ * <p>
+ * Create the object reference, encapsulating the given repository Id and
+ * the given Object Id. The returned object will <i>not</i> be
+ * activated by default and may be activated on the first invocation by
+ * the servant manager (if the IMPLICIT_ACTIVATION policy applies).
+ *
+ * @param an_object_id the object id for the object being created. If this
+ * POA uses the SYSTEM_ID policy, the portable application should only
+ * pass the ids, generated by this POA.
+ *
+ * @param a_repository_id the repository id for the object being created,
+ * can be null if this information should be later requested from the
+ * servant.
+ */
+ public org.omg.CORBA.Object create_reference_with_id(byte[] an_object_id,
+ String a_repository_id
+ )
+ {
+ String[] ids;
+ if (a_repository_id == null)
+ ids = null;
+ else
+ ids = new String[] { a_repository_id };
+
+ // Check maybe such object is already activated.
+ activeObjectMap.Obj e = aom.get(an_object_id);
+
+ Servant servant;
+ if (e == null)
+ {
+ servant = null;
+ }
+ else
+ {
+ servant = e.servant;
+ e.setDeactivated(false);
+ }
+
+ gnuServantObject object =
+ new gnuServantObject(ids, an_object_id, this, m_orb);
+ object._set_delegate(new LocalDelegate(object, this, an_object_id));
+ aom.add(object.Id, object, servant, this);
+ connect_to_orb(an_object_id, object);
+
+ return object;
+ }
+
+ /**
+ * Creates a new POA as a child of the target POA.
+ *
+ * @param child_name the name of the child POA being created.
+ * @param manager the manager that will control the new POA. If this parameter
+ * is null, a new POA manager is created and associated with the new POA.
+ *
+ * @param policies the policies, applicable for the parent POA. Policies
+ * are <i>not</i> inherited from the parent POA.
+ *
+ * @return an newly created POA. The POA will be intially in the holding
+ * state and must be activated to start processing requests.
+ *
+ * @throws AdapterAlreadyExists if the child with the given child_name
+ * already exists for the current POA.
+ * @throws InvalidPolicy if the policies conflict with each other or are
+ * otherwise inappropriate.
+ *
+ * @see #the_children()
+ */
+ public POA create_POA(String child_name, POAManager manager, Policy[] policies)
+ throws AdapterAlreadyExists, InvalidPolicy
+ {
+ POA child;
+ for (int i = 0; i < children.size(); i++)
+ {
+ child = (POA) children.get(i);
+ if (child.the_name().equals(child_name))
+ throw new AdapterAlreadyExists(name + "/" + child_name);
+ }
+
+ POA poa = createPoaInstance(child_name, manager, policies, m_orb);
+ children.add(poa);
+ return poa;
+ }
+
+ /**
+ * Returns a default servant for this POA.
+ *
+ * @return a servant that will be used for requests for
+ * which no servant is found in the Active Object Map.
+ *
+ * @throws NoServant if there is no default servant associated with this POA.
+ * @throws WrongPolicy if the USE_DEFAULT_SERVANT policy is not active.
+ */
+ public Servant get_servant()
+ throws NoServant, WrongPolicy
+ {
+ required(RequestProcessingPolicyValue.USE_DEFAULT_SERVANT);
+ if (default_servant == null)
+ throw new NoServant();
+ return default_servant;
+ }
+
+ /**
+ * Sets the default servant for this POA.
+ *
+ * @param a_servant a servant that will be used for requests for
+ * which no servant is found in the Active Object Map.
+ *
+ * @throws WrongPolicy if the USE_DEFAULT_SERVANT policy is not active.
+ */
+ public void set_servant(Servant a_servant)
+ throws WrongPolicy
+ {
+ required(RequestProcessingPolicyValue.USE_DEFAULT_SERVANT);
+ default_servant = a_servant;
+ }
+
+ /**
+ * Set a servant manager for this POA.
+ *
+ * @param a servant manager being set. If the RETAIN policy applies, the
+ * manager must implement a {@link ServantActivator}. If the NON_RETAIN
+ * policy applies, the manager must implement a {@link ServantLocator}.
+ *
+ * @throws WrongPolicy if the required USE_SERVANT_MANAGER policy does not
+ * apply to this POA.
+ *
+ * @throws OBJ_ADAPTER minor code 4 if the passed manager does not
+ * implement the required interface ({@link ServantActivator},
+ * {@link ServantLocator}). The POA, that has the RETAIN policy uses
+ * servant managers that are ServantActivators. When the POA has the
+ * NON_RETAIN policy it uses servant managers that are ServantLoacators.
+ *
+ * @throws BAD_INV_ORDER minor code 6 if the method is called more than once
+ * on the same POA. The manager can be set only once.
+ */
+ public void set_servant_manager(ServantManager a_manager)
+ throws WrongPolicy
+ {
+ required(RequestProcessingPolicyValue.USE_SERVANT_MANAGER);
+ if (servant_activator != null || servant_locator != null)
+ throw new BAD_INV_ORDER("Setting manager twice for " + name, 6,
+ CompletionStatus.COMPLETED_NO
+ );
+
+ if (applies(ServantRetentionPolicyValue.RETAIN))
+ {
+ if (a_manager instanceof ServantActivator)
+ servant_activator = (ServantActivator) a_manager;
+ else
+ throw new OBJ_ADAPTER("RETAIN requires ServantActivator", 4,
+ CompletionStatus.COMPLETED_NO
+ );
+ }
+ else if (applies(ServantRetentionPolicyValue.NON_RETAIN))
+ {
+ if (a_manager instanceof ServantLocator)
+ servant_locator = (ServantLocator) a_manager;
+ else
+ throw new OBJ_ADAPTER("NON_RETAIN requires ServantLocator", 4,
+ CompletionStatus.COMPLETED_NO
+ );
+ }
+ else
+ throw new WrongPolicy("No servant retention policy is specified.");
+ }
+
+ /**
+ * Get the servant manager, associated with this POA.
+ *
+ * @return the associated servant manager or null if it has
+ * been previously set.
+ *
+ * @throws WrongPolicy if the required USE_SERVANT_MANAGER policy does not
+ * apply to this POA.
+ */
+ public ServantManager get_servant_manager()
+ throws WrongPolicy
+ {
+ required(RequestProcessingPolicyValue.USE_SERVANT_MANAGER);
+
+ if (servant_activator != null)
+ return servant_activator;
+ else
+ return servant_locator;
+ }
+
+ /**
+ * Get the unique Id of the POA in the process in which it is created.
+ * This Id is needed by portable interceptors. The id is unique
+ * for the life span of the POA in the process. For persistent
+ * POAs, if a POA is created in the same path with the same name as
+ * another POA, these POAs are identical have the same id. All transient
+ * POAs are assumed unique.
+ */
+ public byte[] id()
+ {
+ if (m_poa_id != null)
+ return m_poa_id;
+ else
+ {
+ cdrBufOutput buffer = new cdrBufOutput();
+ POA p = this;
+ while (p != null)
+ {
+ buffer.write_string(p.the_name());
+ p = p.the_parent();
+ }
+ m_poa_id = buffer.buffer.toByteArray();
+ return m_poa_id;
+ }
+ }
+
+ /**
+ * Returns the reference to the active object with the given Id.
+ *
+ * @param the_Object_Id the object id.
+ *
+ * @throws ObjectNotActive if there is no active object with such Id
+ * in the scope of this POA.
+ * @throws WrongPolicy if the required RETAIN policy does not apply to
+ * this POA.
+ */
+ public org.omg.CORBA.Object id_to_reference(byte[] the_Object_Id)
+ throws ObjectNotActive, WrongPolicy
+ {
+ required(ServantRetentionPolicyValue.RETAIN);
+
+ activeObjectMap.Obj ref = aom.get(the_Object_Id);
+ if (ref == null)
+ throw new ObjectNotActive();
+ else
+ return ref.object;
+ }
+
+ /**
+ * Returns the servant that serves the active object with the given Id.
+ *
+ * @param the_Object_Id the object id.
+ *
+ * @throws ObjectNotActive if there is no active object with such Id or
+ * it is not currently active.
+ * @throws WrongPolicy. This method requires either RETAIN or
+ * USE_DEFAULT_SERVANT policies and reaises the WrongPolicy if none of them
+ * apply to this POA.
+ */
+ public Servant id_to_servant(byte[] the_Object_Id)
+ throws ObjectNotActive, WrongPolicy
+ {
+ if (applies(ServantRetentionPolicyValue.RETAIN))
+ {
+ activeObjectMap.Obj ref = aom.get(the_Object_Id);
+ if (ref == null || ref.isDeactiveted())
+ {
+ if (default_servant != null)
+ return default_servant;
+ else
+ throw new ObjectNotActive();
+ }
+ else if (ref.servant != null)
+ return ref.servant;
+ else if (default_servant != null)
+ return default_servant;
+ else
+ throw new ObjectNotActive();
+ }
+ else if (default_servant != null)
+ {
+ return default_servant;
+ }
+ else
+ throw new WrongPolicy("Either RETAIN or USE_DEFAULT_SERVANT required.");
+ }
+
+ /**
+ * Returns the Object Id, encapsulated in the given object reference.
+ *
+ * @param the_Object the object that has been previously created with this
+ * POA. It need not be active.
+ *
+ * @throws WrongAdapter if the passed object is not known for this POA.
+ * @throws WrongPolicy never (declared for the future extensions only).
+ */
+ public byte[] reference_to_id(org.omg.CORBA.Object the_Object)
+ throws WrongAdapter, WrongPolicy
+ {
+ activeObjectMap.Obj ref = aom.findObject(the_Object);
+ if (ref == null)
+ throw new WrongAdapter();
+ return ref.key;
+ }
+
+ /**
+ * Returns the servant that is serving this object.
+ *
+ * @return if the RETAIN policy applies and the object is in the Active
+ * Object Map, the method returns the servant, associated with this object.
+ * Otherwise, if the USE_DEFAULT_SERVANT policy applies, the method returns
+ * the default servant (if one was set).
+ *
+ * @throws ObjectNotActive if none of the conditions above are satisfied.
+ * @throws WrongAdapter if the object reference was not created with this POA.
+ * @throws WrongPolicy. This method requires either RETAIN or
+ * USE_DEFAULT_SERVANT policies and reaises the WrongPolicy if none of them
+ * apply to this POA.
+ */
+ public Servant reference_to_servant(org.omg.CORBA.Object the_Object)
+ throws ObjectNotActive, WrongPolicy,
+ WrongAdapter
+ {
+ if (applies(ServantRetentionPolicyValue.RETAIN))
+ {
+ activeObjectMap.Obj ref = aom.findObject(the_Object);
+ if (ref == null)
+ throw new WrongAdapter();
+ else if (ref.isDeactiveted() || ref.servant == null)
+ {
+ if (default_servant != null)
+ return default_servant;
+ else
+ throw new ObjectNotActive();
+ }
+ else
+ return ref.servant;
+ }
+ else if (default_servant != null)
+ {
+ return default_servant;
+ }
+ else
+ throw new WrongPolicy("Either RETAIN or USE_DEFAULT_SERVANT required.");
+ }
+
+ /**
+ * Returns the id of the object, served by the given servant
+ * (assuming that the servant serves only one object).
+ * The id is found in one of the following ways.
+ * <ul>
+ * <li>If the POA has both the RETAIN and the UNIQUE_ID policy and
+ * the specified servant is active, the method return the Object Id associated
+ * with that servant.
+ * </li><li>
+ * If the POA has both the RETAIN and the IMPLICIT_ACTIVATION policy and
+ * either the POA has the MULTIPLE_ID policy or the specified servant is
+ * inactive, the method activates the servant using a POA-generated Object Id
+ * and the Interface Id associated with the servant, and returns that
+ * Object Id.
+ * </li>
+ * <li>If the POA has the USE_DEFAULT_SERVANT policy, the servant specified
+ * is the default servant, and the method is being invoked in the context of
+ * executing a request on the default servant, the method returns the
+ * ObjectId associated with the current invocation.
+ * </li>
+ * </ul>
+ * @throws ServantNotActive in all cases, not listed in the list above.
+ * @throws WrongPolicy The method requres USE_DEFAULT_SERVANT policy or
+ * a combination of the RETAIN policy and either the UNIQUE_ID or
+ * IMPLICIT_ACTIVATION policies and throws the WrongPolicy if these conditions
+ * are not satisfied.
+ */
+ public byte[] servant_to_id(Servant the_Servant)
+ throws ServantNotActive, WrongPolicy
+ {
+ if (applies(RequestProcessingPolicyValue.USE_DEFAULT_SERVANT) ||
+ applies(ServantRetentionPolicyValue.RETAIN) &&
+ (
+ applies(IdUniquenessPolicyValue.UNIQUE_ID) ||
+ applies(ImplicitActivationPolicyValue.IMPLICIT_ACTIVATION)
+ )
+ )
+ {
+ activeObjectMap.Obj ref = null;
+ if (!applies(IdUniquenessPolicyValue.MULTIPLE_ID))
+ ref = aom.findServant(the_Servant);
+ if (ref == null &&
+ applies(ImplicitActivationPolicyValue.IMPLICIT_ACTIVATION)
+ )
+ {
+ // Try to activate.
+ try
+ {
+ return activate_object(the_Servant);
+ }
+ catch (ServantAlreadyActive ex)
+ {
+ // Either it shuld not be or the policy allows multiple ids.
+ throw new InternalError();
+ }
+ }
+ if (ref == null)
+ throw new ServantNotActive();
+ else
+ return ref.key;
+ }
+ else
+ throw new WrongPolicy("(RETAIN and UNIQUE ID) " +
+ "or USE_DEFAULT_SERVANT required."
+ );
+ }
+
+ /**
+ * <p>Converts the given servant to the object reference.
+ * The servant will serve all methods, invoked on the returned object.
+ * The returned object reference can be passed to the remote client,
+ * enabling remote invocations.
+ * </p><p>
+ * If the specified servant is active, it is returned. Otherwise,
+ * if the POA has the IMPLICIT_ACTIVATION policy the method activates
+ * the servant. In this case, if the servant activator is set,
+ * the {@link ServantActivatorOperations#incarnate} method will be called.
+ * </p>
+ *
+ * @throws ServantNotActive if the servant is inactive and no
+ * IMPLICIT_ACTIVATION policy applies.
+ * @throws WrongPolicy This method needs the RETAIN policy and either the
+ * UNIQUE_ID or IMPLICIT_ACTIVATION policies.
+ *
+ * @return the object, exposing the given servant in the context of this POA.
+ */
+ public org.omg.CORBA.Object servant_to_reference(Servant the_Servant)
+ throws ServantNotActive,
+ WrongPolicy
+ {
+ required(ServantRetentionPolicyValue.RETAIN);
+
+ activeObjectMap.Obj exists = null;
+
+ if (!applies(IdUniquenessPolicyValue.MULTIPLE_ID))
+ exists = aom.findServant(the_Servant);
+
+ if (exists != null)
+ {
+ if (exists.isDeactiveted())
+ {
+ if (applies(ImplicitActivationPolicyValue.IMPLICIT_ACTIVATION))
+ {
+ checkDiscarding();
+ exists.setDeactivated(false);
+ incarnate(exists, exists.key, the_Servant, false);
+ }
+ else
+ throw new ServantNotActive();
+ }
+ else
+ return exists.object;
+ }
+ if (exists == null &&
+ applies(ImplicitActivationPolicyValue.IMPLICIT_ACTIVATION)
+ )
+ {
+ checkDiscarding();
+
+ byte[] object_key = activeObjectMap.getFreeId();
+
+ servantDelegate delegate =
+ new servantDelegate(the_Servant, this, object_key);
+ connectDelegate(object_key, delegate);
+
+ return delegate.object;
+ }
+ else
+ throw new ServantNotActive();
+ }
+
+ /**
+ * Incarnate in cases when request forwarding is not expected
+ * because the servant must be provided by the servant activator.
+ *
+ * @param x the aom entry, where the object is replaced by
+ * value, returned by servant activator (if not null).
+ *
+ * @param key the object key.
+ *
+ * @param a_servant the servant that was passed as a parameter in the
+ * activation method.
+ *
+ * @param use_forwarding if true, the gnuForwardRequest is throw
+ * under the forwarding exception (for remote client). Otherwise, the
+ * request is internally redirected (for local invocation).
+ */
+ private Servant incarnate(activeObjectMap.Obj x, byte[] object_key,
+ Servant a_servant, boolean use_forwarding
+ )
+ {
+ if (servant_activator != null)
+ {
+ Servant servant;
+ try
+ {
+ servant = servant_activator.incarnate(object_key, this);
+ }
+ catch (ForwardRequest ex)
+ {
+ if (use_forwarding)
+ throw new gnuForwardRequest(ex.forward_reference);
+ else
+ servant =
+ ForwardedServant.create((ObjectImpl) ex.forward_reference);
+ }
+ if (servant != null && x != null)
+ x.setServant(servant);
+ if (servant == null && x != null)
+ servant = x.servant;
+ return servant;
+ }
+ else if (a_servant != null)
+ {
+ x.setServant(a_servant);
+ return a_servant;
+ }
+ else if (x.servant != null)
+ {
+ return x.servant;
+ }
+ else if (default_servant != null)
+ {
+ x.setServant(default_servant);
+ return x.servant;
+ }
+ else
+ throw new BAD_INV_ORDER("No servant given and the servant activator not set");
+ }
+
+ /**
+ * Return the POA manager, associated with this POA.
+ *
+ * @return the associated POA manager (always available).
+ */
+ public POAManager the_POAManager()
+ {
+ return m_manager;
+ }
+
+ /**
+ * Returns the adapter activator, associated with this POA.
+ * The newly created POA has no activator (null would be
+ * returned). The ORB root POA also initially has no activator.
+ *
+ * @return tha adapter activator or null if this POA has no
+ * associated adapter activator.
+ */
+ public AdapterActivator the_activator()
+ {
+ return m_activator;
+ }
+
+ /**
+ * Set the adapter activator for this POA.
+ *
+ * @param the activator being set.
+ */
+ public void the_activator(AdapterActivator an_activator)
+ {
+ m_activator = an_activator;
+ }
+
+ /**
+ * The children of this POA.
+ *
+ * @return the array of all childs for this POA.
+ */
+ public POA[] the_children()
+ {
+ POA[] poas = new POA[ children.size() ];
+ for (int i = 0; i < poas.length; i++)
+ {
+ poas [ i ] = (POA) children.get(i);
+ }
+ return poas;
+ }
+
+ /**
+ * Return the name of this POA.
+ *
+ * @return the name of POA, relative to its parent.
+ */
+ public String the_name()
+ {
+ return name;
+ }
+ ;
+
+ /**
+ * Return the parent of this POA.
+ *
+ * @return the parent POA or <code>null</code> if this is a root POA.
+ */
+ public POA the_parent()
+ {
+ return parent;
+ }
+
+ /** {@inheritDoc} */
+ public IdAssignmentPolicy create_id_assignment_policy(IdAssignmentPolicyValue a_value)
+ {
+ return new gnuIdAssignmentPolicy(a_value);
+ }
+
+ /** {@inheritDoc} */
+ public IdUniquenessPolicy create_id_uniqueness_policy(IdUniquenessPolicyValue a_value)
+ {
+ return new gnuIdUniquenessPolicy(a_value);
+ }
+
+ /** {@inheritDoc} */
+ public ImplicitActivationPolicy create_implicit_activation_policy(ImplicitActivationPolicyValue a_value)
+ {
+ return new gnuImplicitActivationPolicy(a_value);
+ }
+
+ /** {@inheritDoc} */
+ public LifespanPolicy create_lifespan_policy(LifespanPolicyValue a_value)
+ {
+ return new gnuLifespanPolicy(a_value);
+ }
+
+ /** {@inheritDoc} */
+ public RequestProcessingPolicy create_request_processing_policy(RequestProcessingPolicyValue a_value)
+ {
+ return new gnuRequestProcessingPolicy(a_value);
+ }
+
+ /** {@inheritDoc} */
+ public ServantRetentionPolicy create_servant_retention_policy(ServantRetentionPolicyValue a_value)
+ {
+ return new gnuServantRetentionPolicy(a_value);
+ }
+
+ /** {@inheritDoc} */
+ public ThreadPolicy create_thread_policy(ThreadPolicyValue a_value)
+ {
+ return new gnuThreadPolicy(a_value);
+ }
+
+ /**
+ * <p> Destroy this POA and all descendant POAs. The destroyed POAs can be
+ * later re-created via {@link AdapterActivator} or by invoking
+ * {@link #create_POA}.
+ * This differs from {@link PoaManagerOperations#deactivate} that does
+ * not allow recreation of the deactivated POAs. After deactivation,
+ * recreation is only possible if the POAs were later destroyed.
+ * </p><p>
+ * The remote invocation on the target, belonging to the POA that is
+ * currently destroyed return the remote exception ({@link TRANSIENT},
+ * minor code 4).
+ * </p>
+ * @param etherealize_objects if true, and POA has RETAIN policy, and the
+ * servant manager is available, the servant manager method
+ * {@link ServantActivatorOperations#etherealize} is called for each
+ * <i>active</i> object in the Active Object Map. This method should not
+ * try to access POA being destroyed. If <code>destroy</code> is called
+ * multiple times before the destruction completes,
+ * the etherialization should be invoked only once.
+ *
+ * @param wait_for_completion if true, the method waits till the POA being
+ * destroyed completes all current requests and etherialization. If false,
+ * the method returns immediately.
+ */
+ public void destroy(boolean etherealize_objects, boolean wait_for_completion)
+ {
+ if (wait_for_completion)
+ waitWhileRunning();
+
+ // Put the brake instead of manager, preventing the subsequent
+ // requests.
+ gnuPOAManager g = new gnuPOAManager();
+ g.state = State.INACTIVE;
+ m_manager = g;
+
+ // Disconnect from parent.
+ if (parent instanceof gnuPOA)
+ {
+ ((gnuPOA) parent).children.remove(this);
+ }
+
+ unregisterFromManager();
+
+ // Disconnect from the ORB all objects, registered with this POA.
+ ArrayList keys = new ArrayList();
+ keys.addAll(aom.keySet());
+
+ byte[] key;
+ activeObjectMap.Obj obj;
+ for (int i = 0; i < keys.size(); i++)
+ {
+ key = (byte[]) keys.get(i);
+ obj = aom.get(key);
+ if (obj.poa == this)
+ m_orb.disconnect(obj.object);
+ }
+
+ m_orb.identityDestroyed(this);
+
+ if (etherealize_objects && servant_activator != null && !m_inDestruction)
+ {
+ etherealizeAll();
+ }
+ m_inDestruction = true;
+
+ POA[] ch = the_children();
+ for (int i = 0; i < ch.length; i++)
+ {
+ ch [ i ].destroy(etherealize_objects, wait_for_completion);
+ }
+ }
+
+ /**
+ * Destroy this POA if it has not been destroyed, destroys it.
+ */
+ protected void finalize()
+ throws java.lang.Throwable
+ {
+ if (!m_inDestruction)
+ destroy(false, false);
+ }
+
+ /**
+ * Remove self from the manager list.
+ */
+ private void unregisterFromManager()
+ {
+ if (m_manager instanceof gnuPOAManager)
+ {
+ gnuPOAManager p = (gnuPOAManager) m_manager;
+ p.removePOA(this);
+ }
+ }
+
+ /**
+ * Get the policy of the given type, associated with this POA.
+ *
+ * @param a_policy_type a type of the requested policy.
+ * @return a policy of the given type, applyting to this POA.
+ *
+ * @throws org.omg.CORBA.BAD_PARAM if the policy of this type has not
+ * been specified for this POA.
+ */
+ public Policy _get_policy(int a_policy_type)
+ throws org.omg.CORBA.BAD_PARAM
+ {
+ for (int i = 0; i < s_policies.length; i++)
+ {
+ if (s_policies [ i ].policy_type() == a_policy_type)
+ return s_policies [ i ].copy();
+ }
+ throw new BAD_PARAM("No policy type " + a_policy_type);
+ }
+
+ /**
+ * Get the copy of the policy array.
+ */
+ public Policy[] getPolicyArray()
+ {
+ Policy[] r = new Policy[ s_policies.length ];
+ for (int i = 0; i < s_policies.length; i++)
+ {
+ r [ i ] = s_policies [ i ].copy();
+ }
+ return r;
+ }
+
+ /**
+ * The POAs cannot be created by this method.
+ *
+ * @specnote this is also not possible in Suns jdk at least till 1.4.
+ *
+ * @throws NO_IMPLEMENT always.
+ */
+ public org.omg.CORBA.Object _set_policy_override(Policy[] policies,
+ SetOverrideType how
+ )
+ {
+ throw new NO_IMPLEMENT("Use createPOA instead.");
+ }
+
+ /**
+ * Get the ORB, where this POA is connected.
+ */
+ public ORB orb()
+ {
+ return m_orb;
+ }
+
+ /**
+ * Connect the given delegate under the given key, also calling
+ * incarnate.
+ */
+ private void connectDelegate(byte[] object_key, servantDelegate delegate)
+ {
+ aom.add(delegate);
+ connect_to_orb(object_key, delegate.object);
+ if (servant_activator != null)
+ incarnate(null, object_key, delegate.servant, false);
+ }
+
+ /**
+ * Check if the POA is not in a discarding mode. The activation
+ * operations are forbidded in discarding mode.
+ *
+ * @throws TRANSIENT if the POA is in discarding mode.
+ */
+ private void checkDiscarding()
+ throws TRANSIENT
+ {
+ if (m_manager.get_state() == State.DISCARDING)
+ throw new TRANSIENT("Discarding mode", 1, CompletionStatus.COMPLETED_MAYBE);
+ }
+
+ /**
+ * Connect the given delegate object to orb.
+ */
+ protected void connect_to_orb(byte[] an_Object_Id, org.omg.CORBA.Object object)
+ {
+ if (applies(ThreadPolicyValue.SINGLE_THREAD_MODEL))
+ m_orb.connect_1_thread(object, toIORKey(an_Object_Id), this);
+ else
+ m_orb.connect(object, toIORKey(an_Object_Id));
+ }
+
+ /**
+ * Returns the representation of this POA tree.
+ */
+ public String toString()
+ {
+ StringBuffer b = new StringBuffer(name);
+
+ if (children.size() != 0)
+ {
+ b.append(" (");
+
+ for (int i = 0; i < children.size(); i++)
+ {
+ b.append(children.get(i));
+ if (i < children.size() - 2)
+ b.append(", ");
+ }
+ b.append(")");
+ }
+ return b.toString();
+ }
+
+ /**
+ * Check if the policy set is valid.
+ */
+ protected boolean validatePolicies(Policy[] a)
+ throws InvalidPolicy
+ {
+ if (applies(ServantRetentionPolicyValue.NON_RETAIN))
+ {
+ if (!applies(RequestProcessingPolicyValue.USE_DEFAULT_SERVANT) &&
+ !applies(RequestProcessingPolicyValue.USE_SERVANT_MANAGER)
+ )
+ {
+ short p = 0;
+ for (short i = 0; i < a.length; i++)
+ {
+ if (a [ i ].policy_type() == SERVANT_RETENTION_POLICY_ID.value)
+ p = i;
+ }
+ throw new InvalidPolicy("NON_RETAIN requires either " +
+ "USE_DEFAULT_SERVANT or USE_SERVANT_MANAGER",
+ p
+ );
+ }
+ }
+ return true;
+ }
+
+ /**
+ * Recursively searches for the given object in the POA tree.
+ */
+ public activeObjectMap.Obj findObject(org.omg.CORBA.Object object)
+ {
+ activeObjectMap.Obj h = aom.findObject(object);
+ if (h != null)
+ return h;
+ else
+ {
+ for (int i = 0; i < children.size(); i++)
+ {
+ h = ((gnuPOA) children.get(i)).findObject(object);
+ if (h != null)
+ return h;
+ }
+ }
+ return h;
+ }
+
+ /**
+ * Recursively searches for the given key in the POA tree.
+ * @param ior_key the key, ecapsulating both object
+ * and poa ids.
+ * @return
+ */
+ public activeObjectMap.Obj findKey(byte[] object_id, byte[] poa_id)
+ {
+ activeObjectMap.Obj h = null;
+ if (Arrays.equals(poa_id, id()))
+ h = aom.get(object_id);
+ if (h != null)
+ return h;
+ else
+ {
+ for (int i = 0; i < children.size(); i++)
+ {
+ h = ((gnuPOA) children.get(i)).findKey(object_id, poa_id);
+ if (h != null)
+ return h;
+ }
+ }
+ return h;
+ }
+
+ /**
+ * Parses the given key, extracts poa and object id and searches
+ * for such reference.
+ */
+ public activeObjectMap.Obj findIorKey(byte[] ior_key)
+ {
+ cdrBufInput in = new cdrBufInput(ior_key);
+ int signature = in.read_long();
+ if (signature != SIGNATURE)
+ return null;
+
+ byte[] id = in.read_sequence();
+ byte[] poa = in.read_sequence();
+ return findKey(id, poa);
+ }
+
+ /**
+ * Converts the object Id into the IOR key. IOR key must be
+ * unique in the scope of the ORB, and Ids only in the scope of POA.
+ * Hence the IOR key includes the POA identifiers.
+ */
+ public byte[] toIORKey(byte[] object_id)
+ {
+ cdrBufOutput buffer = new cdrBufOutput();
+ buffer.write_long(SIGNATURE);
+ buffer.write_sequence(object_id);
+ buffer.write_sequence(id());
+ return buffer.buffer.toByteArray();
+ }
+
+ /**
+ * Extracts the object id from the ior key.
+ *
+ * @param ior_key
+ *
+ * @return the encapsulated object ior key or null if
+ * this ior key either refers a different POA or encoding signature
+ * mismatch.
+ */
+ public byte[] idFormIor(byte[] ior_key)
+ {
+ cdrBufInput in = new cdrBufInput(ior_key);
+ int signature = in.read_long();
+ if (signature != SIGNATURE)
+ return null;
+
+ byte[] object_id = in.read_sequence();
+ byte[] poa_id = in.read_sequence();
+ if (Arrays.equals(poa_id, id()))
+ return object_id;
+ else
+ return null;
+ }
+}
\ No newline at end of file
--- /dev/null
+/* gnuPOAManager.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., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 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.Poa;
+
+import org.omg.CORBA.BAD_INV_ORDER;
+import org.omg.CORBA.LocalObject;
+import org.omg.PortableServer.POAManager;
+import org.omg.PortableServer.POAManagerPackage.AdapterInactive;
+import org.omg.PortableServer.POAManagerPackage.State;
+
+import java.util.HashSet;
+import java.util.Iterator;
+
+/**
+ * The implementation of the POA manager. The manager is a controlled
+ * switch that can change its states in response to the method calls
+ * and throw exceptions if the requested change is invalid. It is possible
+ * to check the state this switch. It does not do anything else.
+ *
+ * @author Audrius Meskauskas, Lithuania (AudriusA@Bioinformatics.org)
+ */
+public class gnuPOAManager
+ extends LocalObject
+ implements POAManager
+{
+ /**
+ * The POAs, controlled by this manager. The members must be instances of
+ * the gnuAbstractPOA.
+ */
+ HashSet POAs = new HashSet();
+
+ /**
+ * The state of the manager. The newly created manager is always
+ * in the holding state.
+ */
+ State state = State.HOLDING;
+
+ /**
+ * Get the state of the POA manager.
+ */
+ public State get_state()
+ {
+ return state;
+ }
+
+ /**
+ * Turns the associated POAs into active state, allowing them to receive
+ * and process requests.
+ *
+ * @throws if the POAs are in the inactive state. If once inactivated,
+ * the POA cannot be activated again. This method can only be called
+ * to leave the holding or discarding state.
+ */
+ public void activate()
+ throws AdapterInactive
+ {
+ if (state != State.INACTIVE)
+ state = State.ACTIVE;
+ else
+ throw new AdapterInactive();
+ }
+
+ /**
+ * Turns the associated POAs into holding state. In this state, the POAs
+ * queue incoming requests but do not process them.
+ *
+ * @param wait_for_completion if true, the method call suspends the current
+ * thread till POAs complete the requests they are currently processing. If
+ * false, the method returns immediately.
+
+ * @throws AdapterInactive if the POAs are in the inactive state.
+ */
+ public void hold_requests(boolean wait_for_completion)
+ throws AdapterInactive
+ {
+ if (state != State.INACTIVE)
+ state = State.HOLDING;
+ else
+ throw new AdapterInactive();
+ if (wait_for_completion)
+ waitForIdle();
+ }
+
+ /**
+ *
+ * Turns the asociated POAs into inactive state. The POAs in the incative
+ * state will reject new requests. If the POA is once inactivated, it
+ * cannot be activated again. The operation is used when
+ * the associated POAs are to be shut down.
+ *
+ * @param etherealize_objects if true, the servant managers of the
+ * associated POAs, having RETAIN and USE_SERVANT_MANAGER policies,
+ * will receive a call of {@link ServantActivatorOperations#etherealize}.
+ *
+ * @param wait_for_completion if true, the method call suspends the current
+ * thread till POAs complete the requests they are currently processing. If
+ * false, the method returns immediately.
+ *
+ * @throws AdapterInactive if the POAs are already in the inactive state.
+ *
+ * @see POAOperations#destroy
+ */
+ public void deactivate(boolean etherealize_objects,
+ boolean wait_for_completion
+ )
+ throws AdapterInactive
+ {
+ if (state == State.INACTIVE)
+ throw new AdapterInactive("Repetetive inactivation");
+ state = State.INACTIVE;
+ if (wait_for_completion)
+ waitForIdle();
+
+ Iterator iter = POAs.iterator();
+ while (iter.hasNext())
+ {
+ gnuPOA poa = (gnuPOA) iter.next();
+
+ // If the servant activator is non null, this means it has been
+ // set - hence the policies are appropriate.
+ if (poa.servant_activator != null)
+ poa.etherealizeAll();
+ }
+ }
+
+ /**
+ * Turns the associated POAs into discaring state. In this state, the POAs
+ * discard the incoming requests. This mode is used in situations when
+ * the server is flooded with requests. The client receives remote exception
+ * ({@link org.omg.CORBA.TRANSIENT}, minor code 1).
+ *
+ * @param wait_for_completion if true, the method call suspends the current
+ * thread till POAs complete the requests they are currently processing. If
+ * false, the method returns immediately.
+
+ * @throws AdapterInactive if the POAs are in the inactive state.
+ */
+ public void discard_requests(boolean wait_for_completion)
+ throws AdapterInactive
+ {
+ if (state != State.INACTIVE)
+ state = State.DISCARDING;
+ else
+ throw new AdapterInactive();
+ if (wait_for_completion)
+ waitForIdle();
+ }
+
+ /**
+ * Suspend the current thread while at least one of the associated POA is
+ * actively processing some requests. The method assumes that the POAs
+ * are not accepting the <i>new</i> requests due manager state.
+ *
+ * @throws BAD_INV_ORDER if the POAs are in the active state.
+ */
+ public void waitForIdle()
+ {
+ if (state == State.ACTIVE)
+ throw new BAD_INV_ORDER("The state is active");
+
+ Iterator iter = POAs.iterator();
+ while (iter.hasNext())
+ {
+ gnuPOA poa = (gnuPOA) iter.next();
+ poa.waitWhileRunning();
+ }
+ }
+
+ /**
+ * Add the POA that will be controlled by this manager.
+ *
+ * @param poa the POA.
+ */
+ public void addPoa(gnuPOA poa)
+ {
+ POAs.add(poa);
+ }
+
+ /**
+ * Remove the POA, releasing it from the control of this manager.
+ * Called in POA finaliser.
+ *
+ * @param poa the POA to remove.
+ */
+ public void removePOA(gnuPOA poa)
+ {
+ POAs.remove(poa);
+ }
+}
\ No newline at end of file
--- /dev/null
+/* gnuPoaCurrent.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., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 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.Poa;
+
+import org.omg.CORBA.CurrentHelper;
+import org.omg.CORBA.portable.ObjectImpl;
+import org.omg.PortableServer.Current;
+import org.omg.PortableServer.CurrentOperations;
+import org.omg.PortableServer.CurrentPackage.NoContext;
+import org.omg.PortableServer.POA;
+
+import java.util.Iterator;
+import java.util.Map;
+import java.util.TreeMap;
+
+/**
+ * Supports the "Poa current" concept, providing the id and poa of
+ * the object currently being served. There is only one instance
+ * of this class per ORB. It maintains a thread to information map.
+ *
+ * @author Audrius Meskauskas, Lithuania (AudriusA@Bioinformatics.org)
+ */
+public class gnuPoaCurrent
+ extends ObjectImpl
+ implements Current
+{
+ /**
+ * The table, mapping threads to records.
+ */
+ private TreeMap threads = new TreeMap();
+
+ /**
+ * Get the array of POA current repository ids.
+ *
+ * @return a single member array, containing value, returned
+ * by the {@link CurrentHelper#id}, normally
+ * "IDL:omg.org/PortableServer/Current:2.3".
+ */
+ public String[] _ids()
+ {
+ return new String[] { CurrentHelper.id() };
+ }
+
+ /**
+ * Get the object id, associated with the thread currently being served.
+ *
+ * @throws NoContext if the current thread is not associated with any
+ * object.
+ */
+ public byte[] get_object_id()
+ throws NoContext
+ {
+ CurrentOperations r;
+ synchronized (threads)
+ {
+ r = (CurrentOperations) threads.get(Thread.currentThread().getName());
+ }
+ if (r != null)
+ return r.get_object_id();
+ else
+ throw new NoContext(Thread.currentThread().getName());
+ }
+
+ /**
+ * Get the object POA, associated with the thread currently being served.
+ *
+ * @throws NoContext if the current thread is not associated with any
+ * object.
+ */
+ public POA get_POA()
+ throws NoContext
+ {
+ CurrentOperations r;
+ synchronized (threads)
+ {
+ r = (CurrentOperations) threads.get(Thread.currentThread().getName());
+ }
+ if (r != null)
+ return r.get_POA();
+ else
+ throw new NoContext(Thread.currentThread().getName());
+ }
+
+ /**
+ * Add the entry to the map.
+ */
+ public void put(Thread t, CurrentOperations record)
+ {
+ synchronized (threads)
+ {
+ threads.put(t.getName(), record);
+ }
+ }
+
+ /**
+ * Check if this Poa has some running threads.
+ */
+ public boolean has(POA poa)
+ {
+ synchronized (threads)
+ {
+ Iterator iter = threads.entrySet().iterator();
+ while (iter.hasNext())
+ {
+ Map.Entry item = (Map.Entry) iter.next();
+ try
+ {
+ if (((CurrentOperations) item.getValue()).get_POA() == poa)
+ {
+ return true;
+ }
+ }
+ catch (NoContext ex)
+ {
+ throw new InternalError();
+ }
+ }
+ }
+ return false;
+ }
+
+ /**
+ * Check if this thread is registered.
+ */
+ public boolean has(Thread t)
+ {
+ synchronized (threads)
+ {
+ return threads.containsKey(t.getName());
+ }
+ }
+
+ /**
+ * Remove the entry from the map.
+ */
+ public void remove(Thread t)
+ {
+ synchronized (threads)
+ {
+ threads.remove(t.getName());
+ }
+ }
+}
\ No newline at end of file
--- /dev/null
+/* gnuRequestProcessingPolicy.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., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 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.Poa;
+
+import gnu.CORBA._PolicyImplBase;
+
+import org.omg.PortableServer.REQUEST_PROCESSING_POLICY_ID;
+import org.omg.PortableServer.RequestProcessingPolicy;
+import org.omg.PortableServer.RequestProcessingPolicyValue;
+
+/**
+ * The implementation of the request processing policy.
+ *
+ * @author Audrius Meskauskas, Lithuania (AudriusA@Bioinformatics.org)
+ */
+public class gnuRequestProcessingPolicy
+ extends _PolicyImplBase
+ implements RequestProcessingPolicy, vPolicy
+{
+ /**
+ * Use serialVersionUID for interoperability.
+ */
+ private static final long serialVersionUID = 1L;
+
+ /**
+ * Create the policy.
+ *
+ * @param v a value for the policy.
+ */
+ public gnuRequestProcessingPolicy(RequestProcessingPolicyValue v)
+ {
+ super(REQUEST_PROCESSING_POLICY_ID.value, v, v.value(),
+ "IDL:org.omg/PortableServer/RequestProcessingPolicy:1.0"
+ );
+ }
+
+ /**
+ * Get the value for the policy that was passed in a constructor.
+ */
+ public RequestProcessingPolicyValue value()
+ {
+ return (RequestProcessingPolicyValue) getValue();
+ }
+}
\ No newline at end of file
--- /dev/null
+/* gnuServantObject.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., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 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.Poa;
+
+import gnu.CORBA.GIOP.ReplyHeader;
+import gnu.CORBA.IOR_Delegate;
+import gnu.CORBA.IOR_contructed_object;
+import gnu.CORBA.Interceptor.gnuServerRequestInfo;
+import gnu.CORBA.ObjectCreator;
+import gnu.CORBA.Unexpected;
+import gnu.CORBA.bufferedResponseHandler;
+import gnu.CORBA.recordTypeCode;
+import gnu.CORBA.streamReadyHolder;
+
+import org.omg.CORBA.Any;
+import org.omg.CORBA.BAD_OPERATION;
+import org.omg.CORBA.BAD_PARAM;
+import org.omg.CORBA.CompletionStatus;
+import org.omg.CORBA.OBJECT_NOT_EXIST;
+import org.omg.CORBA.OBJ_ADAPTER;
+import org.omg.CORBA.ORB;
+import org.omg.CORBA.SystemException;
+import org.omg.CORBA.TCKind;
+import org.omg.CORBA.TRANSIENT;
+import org.omg.CORBA.UserException;
+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.PortableInterceptor.ForwardRequest;
+import org.omg.PortableInterceptor.ServerRequestInterceptorOperations;
+import org.omg.PortableServer.CurrentOperations;
+import org.omg.PortableServer.DynamicImplementation;
+import org.omg.PortableServer.ImplicitActivationPolicyValue;
+import org.omg.PortableServer.POA;
+import org.omg.PortableServer.POAManager;
+import org.omg.PortableServer.POAManagerPackage.State;
+import org.omg.PortableServer.Servant;
+import org.omg.PortableServer.ServantLocatorPackage.CookieHolder;
+import org.omg.PortableServer.ServantRetentionPolicyValue;
+import org.omg.PortableServer.portable.Delegate;
+
+import java.io.IOException;
+
+import java.util.Arrays;
+
+/**
+ * Represents a CORBA object, being locally served by the associated servant.
+ * The calls to the object are forwarded to the calls to the servant.
+ *
+ * @author Audrius Meskauskas, Lithuania (AudriusA@Bioinformatics.org)
+ */
+public class gnuServantObject extends ObjectImpl
+ implements org.omg.CORBA.Object,
+ InvokeHandler,
+ CurrentOperations
+{
+ /**
+ * The associated servant that must also implement the {@link InvokeHandler}
+ * interface. This value can be temporary null if the object was created using
+ * POA.create_reference or POA.create_reference_with_id, private to force
+ * always to use {@link setServant}.
+ */
+ private Servant servant;
+
+ /**
+ * The Id of this object.
+ */
+ public final byte[] Id;
+
+ /**
+ * The poa that takes care about this object.
+ */
+ public final gnuPOA poa;
+
+ /**
+ * The POA manager, used to control the work of this object.
+ */
+ public final POAManager manager;
+
+ /**
+ * The orb.
+ */
+ public final ORB_1_4 orb;
+
+ /**
+ * The object repository ids, if they were specified separately. Normally, the
+ * ids are requested from the servant.
+ */
+ public final String[] repository_ids;
+
+ /**
+ * Create an object with no connected servant. The servant must be set later.
+ *
+ * @param a_repository_ids an array of repository ids, can be null (then ids
+ * will be requested from the servant).
+ * @param an_id the object id.
+ * @param a_poa the POA.
+ */
+ public gnuServantObject(String[] a_repository_ids, byte[] an_id,
+ gnuPOA a_poa, ORB_1_4 an_orb
+ )
+ {
+ repository_ids = a_repository_ids;
+ Id = an_id;
+ manager = a_poa.the_POAManager();
+ poa = a_poa;
+ orb = an_orb;
+ }
+
+ /**
+ * Create a servant object, associated with the passed servant.
+ *
+ * @param a_servant a servant, serving this object.
+ * @param an_id an Object Id for this object.
+ *
+ * @throws BAD_PARAM if the passed servant is not an {@link InvokeHandler}.
+ */
+ public gnuServantObject(Servant a_servant, byte[] an_id, ORB_1_4 an_orb,
+ gnuPOA a_poa
+ )
+ {
+ Id = an_id;
+ setServant(a_servant);
+ poa = a_poa;
+ if (poa != null)
+ {
+ manager = poa.the_POAManager();
+ }
+ else
+ {
+ manager = null;
+ }
+ repository_ids = null;
+ orb = an_orb;
+ }
+
+ /**
+ * Set a servant, if it has not been previously set.
+ *
+ * @param a_servant a servant to set, can be null to indicate the necessity
+ * for the subsequent activation.
+ *
+ * @throws BAD_PARAM if the passed servant is not an {@link InvokeHandler} or
+ * {@link DynamicImplementation} and also not null.
+ */
+ public void setServant(Servant a_servant)
+ {
+ if (a_servant != null &&
+ !(a_servant instanceof InvokeHandler) &&
+ !(a_servant instanceof DynamicImplementation)
+ )
+ {
+ throw new BAD_PARAM("Must be either InvokeHandler or " +
+ "DynamicImplementation, but is " + a_servant
+ );
+ }
+ servant = a_servant;
+ }
+
+ /**
+ * Returns the associated servant.
+ */
+ public Servant getServant()
+ {
+ return servant;
+ }
+
+ /**
+ * Return the associated invocation handler.
+ */
+ public InvokeHandler getHandler(String operation, CookieHolder cookie,
+ boolean forwarding_allowed
+ ) throws gnuForwardRequest
+ {
+ if (servant != null)
+ {
+ return servantToHandler(servant);
+ }
+ else
+ {
+ // Use servant locator to locate the servant.
+ if (poa.servant_locator != null)
+ {
+ try
+ {
+ servant =
+ poa.servant_locator.preinvoke(Id, poa, operation, cookie);
+ return servantToHandler(servant);
+ }
+ catch (org.omg.PortableServer.ForwardRequest forw_ex)
+ {
+ if (forwarding_allowed)
+ {
+ throw new gnuForwardRequest(forw_ex.forward_reference);
+ }
+ else
+ {
+ servant =
+ ForwardedServant.create(forw_ex.forward_reference);
+ return servantToHandler(servant);
+ }
+ }
+ }
+ else
+ // Use servant activator to locate the servant.
+ if (poa.applies(ImplicitActivationPolicyValue.IMPLICIT_ACTIVATION) &&
+ poa.applies(ServantRetentionPolicyValue.RETAIN)
+ )
+ {
+ try
+ {
+ poa.activate_object_with_id(Id, servant, forwarding_allowed);
+ servant = poa.id_to_servant(Id);
+ return servantToHandler(servant);
+ }
+ catch (gnuForwardRequest forwarded)
+ {
+ throw forwarded;
+ }
+ catch (Exception ex)
+ {
+ ex.printStackTrace();
+
+ BAD_OPERATION bad =
+ new BAD_OPERATION("Unable to activate", 0x5004,
+ CompletionStatus.COMPLETED_NO
+ );
+ bad.initCause(ex);
+ throw bad;
+ }
+ }
+ else if (poa.default_servant != null)
+ {
+ servant = poa.default_servant;
+ return servantToHandler(servant);
+ }
+
+ // No servant and no servant manager - throw exception.
+ else
+ {
+ throw new BAD_OPERATION("Unable to activate", 0x5002,
+ CompletionStatus.COMPLETED_NO
+ );
+ }
+ }
+ }
+
+ /**
+ * Convert the servant to invocation handler.
+ */
+ public InvokeHandler servantToHandler(Servant a_servant)
+ {
+ if (a_servant instanceof InvokeHandler)
+ {
+ return (InvokeHandler) a_servant;
+ }
+ else if (a_servant instanceof DynamicImplementation)
+ {
+ return new dynImpHandler((DynamicImplementation) a_servant);
+ }
+ else
+ {
+ throw new BAD_OPERATION(a_servant +
+ " must be either InvokeHandler or " + "POA DynamicImplementation"
+ );
+ }
+ }
+
+ /**
+ * Create a servant object, associated with the passed servant. Requests the
+ * object id from the servant. Depending on the policies of the servants POA,
+ * the calls are eithe not synchronized or synchronized on POA or ORB.
+ *
+ * @param a_servant a servant, serving this object.
+ * @param an_id an Object Id for this object.
+ */
+ public gnuServantObject(Servant a_servant, gnuPOA a_poa)
+ {
+ this(a_servant, a_servant._object_id(), (ORB_1_4) a_servant._orb(), a_poa);
+ }
+
+ /**
+ * Delegates call to servant, passing the poa and Id.
+ */
+ public String[] _ids()
+ {
+ if (repository_ids == null)
+ {
+ return getServant()._all_interfaces(poa, Id);
+ }
+ else
+ {
+ return repository_ids;
+ }
+ }
+
+ /**
+ * Gets a string representation.
+ */
+ public String toString()
+ {
+ StringBuffer b = new StringBuffer("Servant object (");
+ for (int i = 0; i < Id.length; i++)
+ {
+ b.append(Integer.toHexString(Id [ i ] & 0xFF));
+ b.append(' ');
+ }
+ b.append(')');
+ return b.toString();
+ }
+
+ /**
+ * Always returns true.
+ */
+ public boolean _is_local()
+ {
+ return true;
+ }
+
+ /**
+ * Check if this object could be named by the given repository id.
+ *
+ * @param idl_id the repository id to check.
+ *
+ * @return true if it is one of the possible repository ids of this object.
+ */
+ public boolean _is_a(String idl_id)
+ {
+ String[] maybe = _ids();
+ for (int i = 0; i < maybe.length; i++)
+ {
+ if (maybe [ i ].equals(idl_id))
+ {
+ return true;
+ }
+ }
+ return false;
+ }
+
+ /**
+ * Get an ORB, associated with the servant of this object.
+ *
+ * @return
+ */
+ public ORB _orb()
+ {
+ return getServant()._orb();
+ }
+
+ /**
+ * Handle the invocation (delegates to servant).
+ *
+ * @throws TRANSIENT minor 0x535503e9 if the POA is in discarding mode.
+ * @throws OBJ_ADAPTER minor 0x535503ea if the POA is inactivated.
+ * @throws OBJECT_NOT_EXISTS minor 0x535503ec if this object is inactivated.
+ *
+ * @specnote see {@link POAManagerOperations} for specnotes about the minor
+ * codes.
+ */
+ public OutputStream _invoke(String method, InputStream input,
+ ResponseHandler r_handler
+ ) throws SystemException
+ {
+ boolean intercept = false;
+ ServerRequestInterceptorOperations interceptor = null;
+ gnuServerRequestInfo info = null;
+ bufferedResponseHandler i_handler = null;
+
+ try
+ {
+ if (orb.iServer != null &&
+ r_handler instanceof bufferedResponseHandler
+ )
+ {
+ interceptor = orb.iServer;
+
+ i_handler = (bufferedResponseHandler) r_handler;
+
+ info =
+ new gnuServerRequestInfo(this, i_handler.request_header,
+ i_handler.reply_header
+ );
+ intercept = true;
+
+ interceptor.receive_request_service_contexts(info);
+ }
+
+ try
+ {
+ CookieHolder cookie = null;
+ activeObjectMap.Obj self = poa.aom.get(Id);
+
+ if (poa.servant_locator != null)
+ {
+ // If the servant locator is in use, it is always responsible
+ // for providing the servant.
+ self.servant = servant = null;
+ cookie = new CookieHolder();
+ }
+ else if (self != null && self.isDeactiveted())
+ {
+ if (poa.applies(
+ ImplicitActivationPolicyValue.IMPLICIT_ACTIVATION
+ ) &&
+ poa.servant_activator != null
+ )
+ {
+ // Reset the servant, forcing the subsequent activation.
+ servant = null;
+ }
+ else
+ {
+ throw new OBJECT_NOT_EXIST("Object deactivated",
+ 0x535503ec, CompletionStatus.COMPLETED_NO
+ );
+ }
+ }
+
+ InvokeHandler handler = getHandler(method, cookie, true);
+
+ Delegate d = null;
+
+ try
+ {
+ d = servant._get_delegate();
+ orb.currents.put(Thread.currentThread(), this);
+ }
+ catch (Exception ex)
+ {
+ // In some cases exception is thrown if the delegate is not set.
+ }
+ if (d instanceof servantDelegate)
+ {
+ // If the delegate is already set, check maybe we can
+ // reuse the existing instance.
+ if (((servantDelegate) d).object != this)
+ {
+ servant._set_delegate(new servantDelegate(servant, poa, Id));
+ }
+ }
+ else
+ {
+ servant._set_delegate(new servantDelegate(servant, poa, Id));
+ }
+
+ try
+ {
+ switch (manager.get_state().value())
+ {
+ case State._ACTIVE :
+
+ OutputStream rt;
+ try
+ {
+ if (intercept)
+ {
+ interceptor.receive_request(info);
+ }
+
+ rt = handler._invoke(method, input, r_handler);
+
+ if (intercept)
+ {
+ // Handler is casted into i_handler.
+ if (i_handler.isExceptionReply())
+ {
+ info.m_reply_header.reply_status =
+ ReplyHeader.USER_EXCEPTION;
+
+ // Make Any, holding the user exception.
+ Any a = orb.create_any();
+ OutputStream buf = i_handler.getBuffer();
+ InputStream in = buf.create_input_stream();
+ String uex_idl = "unknown";
+ try
+ {
+ in.mark(Integer.MAX_VALUE);
+ uex_idl = in.read_string();
+ in.reset();
+ }
+ catch (IOException e)
+ {
+ throw new Unexpected(e);
+ }
+
+ try
+ {
+ UserException exception =
+ ObjectCreator.readUserException(uex_idl,
+ in
+ );
+
+ ObjectCreator.insertWithHelper(a,
+ exception
+ );
+ }
+ catch (Exception e)
+ {
+ // Failed due any reason, insert without
+ // helper.
+ a.insert_Streamable(new streamReadyHolder(
+ buf.create_input_stream()
+ )
+ );
+
+ recordTypeCode r =
+ new recordTypeCode(TCKind.tk_except);
+ r.setId(uex_idl);
+ r.setName(ObjectCreator.getDefaultName(
+ uex_idl
+ )
+ );
+ }
+
+ info.m_usr_exception = a;
+ interceptor.send_exception(info);
+ }
+ else
+ {
+ info.m_reply_header.reply_status =
+ ReplyHeader.NO_EXCEPTION;
+ interceptor.send_reply(info);
+ }
+ }
+ }
+ catch (SystemException sys_ex)
+ {
+ if (intercept)
+ {
+ info.m_reply_header.reply_status =
+ ReplyHeader.SYSTEM_EXCEPTION;
+ info.m_sys_exception = sys_ex;
+ interceptor.send_exception(info);
+ }
+ throw sys_ex;
+ }
+
+ return rt;
+
+ case State._HOLDING :
+
+ // The holding mode is implemented
+ // relying on the holding capabilites of the network
+ // support (if any).
+ // TODO FIXME in more recent CORBA applications, the
+ // client
+ // ORB can free the connection and wait for a server side
+ // notification about the completed request. Implement
+ // this
+ // as soon as JDK specification would allow bidirectional
+ // policy.
+ int sleep = 5;
+ int max = 500;
+
+ // Wait till the state will be switched into some other
+ // mode.
+ while (manager.get_state().value() == State._HOLDING)
+ {
+ try
+ {
+ Thread.sleep(sleep);
+ if (sleep < max)
+ {
+ sleep = max;
+ }
+ }
+ catch (InterruptedException ex)
+ {
+ }
+ }
+
+ // Handle another mode.
+ return _invoke(method, input, r_handler);
+
+ case State._DISCARDING :
+ throw new TRANSIENT("Discarding mode", 0x535503e9,
+ CompletionStatus.COMPLETED_NO
+ );
+
+ case State._INACTIVE :
+ throw new OBJ_ADAPTER("POA deactivated", 0x535503ea,
+ CompletionStatus.COMPLETED_NO
+ );
+
+ default :
+ throw new InternalError(); // No more states.
+ }
+ }
+ finally
+ {
+ if (poa.servant_locator != null)
+ {
+ poa.servant_locator.postinvoke(Id, poa, method,
+ cookie.value, servant
+ );
+ servant = null;
+ }
+ }
+ }
+ finally
+ {
+ orb.currents.remove(Thread.currentThread());
+ }
+ }
+ catch (ForwardRequest fex)
+ {
+ // May be thrown by interceptor.
+ if (intercept)
+ {
+ Forwarding:
+ while (true)
+ {
+ info.m_reply_header.reply_status =
+ ReplyHeader.LOCATION_FORWARD;
+ info.m_forward_reference = fex.forward;
+ try
+ {
+ interceptor.send_other(info);
+ break Forwarding;
+ }
+ catch (ForwardRequest fex2)
+ {
+ info.m_forward_reference = fex2.forward;
+ fex.forward = info.m_forward_reference;
+ }
+ }
+ }
+ throw new gnuForwardRequest(fex.forward);
+ }
+ catch (gnuForwardRequest fex)
+ {
+ // May be thrown during activation.
+ if (intercept)
+ {
+ Forwarding:
+ while (true)
+ {
+ info.m_reply_header.reply_status =
+ ReplyHeader.LOCATION_FORWARD;
+ info.m_forward_reference = fex.forward_reference;
+ try
+ {
+ interceptor.send_other(info);
+ break Forwarding;
+ }
+ catch (ForwardRequest fex2)
+ {
+ info.m_forward_reference = fex2.forward;
+ fex.forward_reference = (ObjectImpl) fex2.forward;
+ }
+ }
+ }
+ throw fex;
+ }
+ }
+
+ /**
+ * Compare with another object for equality, comparing the object keys.
+ */
+ public boolean equals(java.lang.Object other)
+ {
+ if (other instanceof gnuServantObject)
+ {
+ gnuServantObject o = (gnuServantObject) other;
+
+ return Arrays.equals(o.Id, Id);
+ }
+ else
+ {
+ return false;
+ }
+ }
+
+ /**
+ * Get the hash code, based on the object key.
+ */
+ public int hashCode()
+ {
+ long s = 0;
+ int v = 1;
+ for (int i = 0; i < Id.length; i++)
+ {
+ s += Id [ i ] * v;
+ if (s > Integer.MAX_VALUE)
+ {
+ s = s % Integer.MAX_VALUE;
+ v = 1;
+ }
+ v = v * 8;
+ }
+ return (int) (s % Integer.MAX_VALUE);
+ }
+
+ /**
+ * Get the object id.
+ */
+ public byte[] get_object_id()
+ {
+ return Id;
+ }
+
+ /**
+ * Get POA.
+ */
+ public POA get_POA()
+ {
+ return poa;
+ }
+
+ /**
+ * Returns without action.
+ */
+ public void _release()
+ {
+ }
+
+ /**
+ * Returns without action.
+ */
+ public void _releaseReply(InputStream stream)
+ {
+ }
+
+ /**
+ * Checks if this object is equivalent to another instance. These objects are
+ * assumed equal if they are connected to the same orb and poa under the same
+ * Id, regardless of they delegates.
+ *
+ * @param another instance to check.
+ * @return
+ */
+ public boolean _is_equivalent(org.omg.CORBA.Object other)
+ {
+ if (other instanceof gnuServantObject)
+ {
+ gnuServantObject g = (gnuServantObject) other;
+ return orb == g.orb && poa == g.poa && Arrays.equals(Id, g.Id);
+ }
+ else if (other instanceof IOR_contructed_object)
+ {
+ IOR_contructed_object ir = ((IOR_contructed_object) other);
+ try
+ {
+ IOR_Delegate ird = (IOR_Delegate) ir._get_delegate();
+ byte[] ior_id = poa.idFormIor(ird.getIor().key);
+ if (ior_id != null && Arrays.equals(ior_id, Id))
+ {
+ return true;
+ }
+ else
+ {
+ return false;
+ }
+ }
+ catch (Exception ex)
+ {
+ // Non - typical delegate or very specific subclass of
+ // IOR_constructed_object.
+ return super._is_equivalent(other);
+ }
+ }
+ return super._is_equivalent(other);
+ }
+}
\ No newline at end of file
--- /dev/null
+/* gnuServantRetentionPolicy.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., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 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.Poa;
+
+import gnu.CORBA._PolicyImplBase;
+
+import org.omg.PortableServer.SERVANT_RETENTION_POLICY_ID;
+import org.omg.PortableServer.ServantRetentionPolicy;
+import org.omg.PortableServer.ServantRetentionPolicyValue;
+
+/**
+ * The implementation of the servant retention policy.
+ *
+ * @author Audrius Meskauskas, Lithuania (AudriusA@Bioinformatics.org)
+ */
+public class gnuServantRetentionPolicy
+ extends _PolicyImplBase
+ implements ServantRetentionPolicy, vPolicy
+{
+ /**
+ * Use serialVersionUID for interoperability.
+ */
+ private static final long serialVersionUID = 1L;
+
+ /**
+ * Create the policy.
+ *
+ * @param v a value for the policy.
+ */
+ public gnuServantRetentionPolicy(ServantRetentionPolicyValue v)
+ {
+ super(SERVANT_RETENTION_POLICY_ID.value, v, v.value(),
+ "IDL:org.omg/PortableServer/ServantRetentionPolicy:1.0"
+ );
+ }
+
+ /**
+ * Get the value for the policy that was passed in a constructor.
+ */
+ public ServantRetentionPolicyValue value()
+ {
+ return (ServantRetentionPolicyValue) getValue();
+ }
+}
\ No newline at end of file
--- /dev/null
+/* gnuThreadPolicy.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., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 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.Poa;
+
+import gnu.CORBA._PolicyImplBase;
+
+import org.omg.PortableServer.THREAD_POLICY_ID;
+import org.omg.PortableServer.ThreadPolicy;
+import org.omg.PortableServer.ThreadPolicyValue;
+
+/**
+ * The implementation of the thread policy.
+ *
+ * @author Audrius Meskauskas, Lithuania (AudriusA@Bioinformatics.org)
+ */
+public class gnuThreadPolicy
+ extends _PolicyImplBase
+ implements ThreadPolicy, vPolicy
+{
+ /**
+ * Use serialVersionUID for interoperability.
+ */
+ private static final long serialVersionUID = 1L;
+
+ /**
+ * Create the policy.
+ *
+ * @param v a value for the policy.
+ */
+ public gnuThreadPolicy(ThreadPolicyValue v)
+ {
+ super(THREAD_POLICY_ID.value, v, v.value(),
+ "IDL:org.omg/PortableServer/ThreadPolicy:1.0"
+ );
+ }
+
+ /**
+ * Get the value for the policy that was passed in a constructor.
+ */
+ public ThreadPolicyValue value()
+ {
+ return (ThreadPolicyValue) getValue();
+ }
+}
\ No newline at end of file
--- /dev/null
+/* policySets.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., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 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.Poa;
+
+import org.omg.CORBA.Policy;
+import org.omg.PortableServer.IdAssignmentPolicyValue;
+import org.omg.PortableServer.IdUniquenessPolicyValue;
+import org.omg.PortableServer.ImplicitActivationPolicyValue;
+import org.omg.PortableServer.LifespanPolicyValue;
+import org.omg.PortableServer.RequestProcessingPolicyValue;
+import org.omg.PortableServer.ServantRetentionPolicyValue;
+import org.omg.PortableServer.ThreadPolicyValue;
+
+import java.util.ArrayList;
+
+/**
+ * Contains the frequently uset POA policy sets. The policy
+ * arrays are package private for security reasons, the cloned
+ * copies are returned.
+ *
+ * @author Audrius Meskauskas, Lithuania (AudriusA@Bioinformatics.org)
+ */
+public class policySets
+{
+ /**
+ * The default policy set, as defined in OMG specs. This is also
+ * the policy set for the root POA.
+ */
+ private static final vPolicy[] rootPOASet =
+ new vPolicy[]
+ {
+ new gnuThreadPolicy(ThreadPolicyValue.ORB_CTRL_MODEL),
+ new gnuLifespanPolicy(LifespanPolicyValue.TRANSIENT),
+ new gnuIdUniquenessPolicy(IdUniquenessPolicyValue.UNIQUE_ID),
+ new gnuIdAssignmentPolicy(IdAssignmentPolicyValue.SYSTEM_ID),
+ new gnuServantRetentionPolicy(ServantRetentionPolicyValue.RETAIN),
+ new gnuRequestProcessingPolicy(RequestProcessingPolicyValue.USE_ACTIVE_OBJECT_MAP_ONLY),
+ new gnuImplicitActivationPolicy(ImplicitActivationPolicyValue.IMPLICIT_ACTIVATION)
+ };
+
+ /**
+ * Return the policy set, applicable for the root POA, as defined
+ * in OMG specs.
+ */
+ public static Policy[] rootPoa()
+ {
+ Policy[] p = new Policy[ rootPOASet.length ];
+ System.arraycopy(rootPOASet, 0, p, 0, p.length);
+ return p;
+ }
+
+ /**
+ * Convert the potentially incomplete policy array into array, containing
+ * the complete policy set.
+ *
+ * @param policies the policy list, may be incomplete (even zero size).
+ *
+ * @return the complete policy array. The missing, but needed policies
+ * are added with they default values.
+ */
+ public static Policy[] withDefault(Policy[] policies)
+ {
+ ArrayList current = new ArrayList(rootPOASet.length);
+ Policy p_default;
+ boolean specified;
+
+ for (int i = 0; i < rootPOASet.length; i++)
+ {
+ p_default = rootPOASet [ i ];
+ specified = false;
+ ForThis:
+ for (int j = 0; j < policies.length; j++)
+ {
+ if (policies [ j ].policy_type() == p_default.policy_type())
+ {
+ specified = true;
+ current.add(policies [ j ]);
+ break ForThis;
+ }
+ }
+ if (!specified)
+ current.add(p_default.copy());
+ }
+
+ Policy[] complete = new Policy[ current.size() ];
+ for (int i = 0; i < complete.length; i++)
+ {
+ complete [ i ] = (Policy) current.get(i);
+ }
+ return complete;
+ }
+}
\ No newline at end of file
--- /dev/null
+/* servantDelegate.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., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 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.Poa;
+
+import gnu.CORBA.Unexpected;
+
+import org.omg.CORBA.NO_IMPLEMENT;
+import org.omg.CORBA.ORB;
+import org.omg.CORBA.ORBPackage.InvalidName;
+import org.omg.CORBA.Object;
+import org.omg.PortableServer.CurrentPackage.NoContext;
+import org.omg.PortableServer.POA;
+import org.omg.PortableServer.POAHelper;
+import org.omg.PortableServer.Servant;
+import org.omg.PortableServer.portable.Delegate;
+
+/**
+ * The implementation of the servant delegate for the locally existing
+ * servant.The associated servant that must also implement the
+ * {@link InvokeHandler} interface. Each servant requires a separate
+ * instance of this delegate and can serve a single object only.
+ * Hence the fields are final, but the delegate is typically reused
+ * unless the same servant is connected to different objects.
+ *
+ * @author Audrius Meskauskas, Lithuania (AudriusA@Bioinformatics.org)
+ */
+public class servantDelegate
+ implements Delegate
+{
+ /**
+ * The servant, associated with this object.
+ */
+ final Servant servant;
+
+ /**
+ * The servant (not object) id.
+ */
+ final byte[] servant_id;
+
+ /**
+ * The POA, where the servant is connected.
+ */
+ final gnuPOA poa;
+
+ /**
+ * The object, exposed as an object, served by this servant.
+ */
+ final gnuServantObject object;
+
+ /**
+ * Create the delegat for the servant that will be connected to the
+ * given poa. The method is normally called from inside of gnuPOA.
+ * The constructor sets the newly created delegate as the delegate to this
+ * servant by calling Servant._set_delegate.
+ *
+ * @param a_poa the poa.
+ * @param a_servant the servant.
+ * @param a_servant_id the servant id.
+ */
+ public servantDelegate(Servant a_servant, gnuPOA a_poa, byte[] a_servant_id)
+ {
+ poa = a_poa;
+ servant = a_servant;
+ servant_id = a_servant_id;
+ servant._set_delegate(this);
+ object =
+ new gnuServantObject(servant, servant_id, (ORB_1_4) servant._orb(), a_poa);
+ object._set_delegate(new LocalDelegate(object, poa, a_servant_id));
+ }
+
+ /**
+ * Check if this object could be named by the given repository id.
+ * @param idl_id the repository id to check.
+ *
+ * @return true if it is one of the possible repository ids of this
+ * object.
+ */
+ public boolean is_a(Servant a_servant, String idl_id)
+ {
+ same(a_servant);
+
+ String[] maybe = object.repository_ids;
+ if (maybe == null)
+ maybe = servant._all_interfaces(poa, object.Id);
+ for (int i = 0; i < maybe.length; i++)
+ {
+ if (maybe [ i ].equals(idl_id))
+ return true;
+ }
+ return false;
+ }
+
+ /**
+ * Return the ORB's default POA.
+ */
+ public POA default_POA(Servant a_servant)
+ {
+ same(a_servant);
+ try
+ {
+ return POAHelper.narrow(orb(a_servant).resolve_initial_references("RootPOA"));
+ }
+ catch (InvalidName ex)
+ {
+ throw new Unexpected(ex);
+ }
+ }
+
+ /**
+ * Get ORB.
+ */
+ public ORB orb(Servant a_servant)
+ {
+ same(a_servant);
+ return poa.orb();
+ }
+
+ /**
+ * Get the object, exposing the servant.
+ */
+ public Object this_object(Servant a_servant)
+ {
+ same(a_servant);
+ try
+ {
+ return poa.aom.get(poa.m_orb.currents.get_object_id()).object;
+ }
+ catch (NoContext ex)
+ {
+ return object;
+ }
+ }
+
+ /**
+ * Not supported.
+ *
+ * @specnote Same as for Sun up till 1.5 inclusive.
+ */
+ public Object get_interface_def(Servant a_servant)
+ {
+ same(a_servant);
+ throw new NO_IMPLEMENT();
+ }
+
+ /**
+ * Get the Id of the object being currently served.
+ */
+ public byte[] object_id(Servant a_servant)
+ {
+ same(a_servant);
+ try
+ {
+ byte[] id = poa.m_orb.currents.get_object_id();
+ return id;
+ }
+ catch (NoContext ex)
+ {
+ return object.Id;
+ }
+ }
+
+ /**
+ * Always returns false;
+ */
+ public boolean non_existent(Servant a_servant)
+ {
+ same(a_servant);
+ return false;
+ }
+
+ /**
+ * Return the associated POA.
+ */
+ public POA poa(Servant a_servant)
+ {
+ same(a_servant);
+ try
+ {
+ return poa.m_orb.currents.get_POA();
+ }
+ catch (NoContext ex)
+ {
+ return poa;
+ }
+ }
+
+ /**
+ * Checks if the passed servant is the same as the servant, associated with
+ * this delegate. This class requires a single servant per delegate.
+ */
+ void same(Servant some_servant)
+ {
+ if (servant != some_servant)
+ throw new InternalError("Only one servant per delegate is supported.");
+ }
+}
\ No newline at end of file
--- /dev/null
+/* vPolicy.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., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 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.Poa;
+
+import org.omg.CORBA.Policy;
+
+/**
+ * The Classpath implementation of the policy, providing the policy
+ * value and the code of the policy type.
+ *
+ * @author Audrius Meskauskas, Lithuania (AudriusA@Bioinformatics.org)
+ */
+public interface vPolicy
+ extends Policy
+{
+ /**
+ * Get the value of this policy
+ */
+ java.lang.Object getValue();
+
+ /**
+ * Get the integer code of this policy value.
+ */
+ int getCode();
+
+}
\ No newline at end of file
--- /dev/null
+/* gnuValueHolder.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., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 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.Vio;
+
+import org.omg.CORBA.TypeCode;
+import org.omg.CORBA.ValueBaseHolder;
+import org.omg.CORBA.portable.BoxedValueHelper;
+import org.omg.CORBA.portable.InputStream;
+import org.omg.CORBA.portable.OutputStream;
+
+import java.io.Serializable;
+
+/**
+ * Boxed value holder that also remembers the value type and the value helper.
+ *
+ * @author Audrius Meskauskas, Lithuania (AudriusA@Bioinformatics.org)
+ */
+public class gnuValueHolder
+ extends ValueBaseHolder
+{
+ /**
+ * The type code of the stored value.
+ */
+ TypeCode type;
+
+ /**
+ * The helper that could read and write fields of the boxed value.
+ */
+ transient BoxedValueHelper helper;
+
+ /**
+ * If true, the helper not available.
+ */
+ transient boolean helper_NA;
+
+ /**
+ * Create a new instance for the given value and given type.
+ */
+ public gnuValueHolder(Serializable value, TypeCode a_type)
+ {
+ super(value);
+ type = a_type;
+ }
+
+ /**
+ * Get the true type, as it was passed in the constructor.
+ */
+ public TypeCode _type()
+ {
+ return type;
+ }
+
+ /**
+ * Write content to the output stream. Tries to locate the
+ * corresponding helper class.
+ */
+ public void _write(OutputStream output)
+ {
+ findHelper();
+ if (helper == null)
+ super._write(output);
+ else
+ Vio.write(output, value, helper);
+ }
+
+ /**
+ * Read, trying to locate helper, if possible.
+ */
+ public void _read(InputStream input)
+ {
+ findHelper();
+ if (helper == null)
+ super._read(input);
+ else
+ value = Vio.read(input, helper);
+ }
+
+ /**
+ * Set the read and write methods.
+ */
+ void findHelper()
+ {
+ if (helper != null || helper_NA)
+ return;
+ try
+ {
+ Class helperClass =
+ Class.forName(ObjectCreator.toHelperName(type.id()));
+
+ helper = (BoxedValueHelper) helperClass.newInstance();
+ }
+ catch (Exception ex)
+ {
+ helper_NA = true;
+ }
+ }
+}
\ No newline at end of file
--- /dev/null
+/* Pointer.java -- Pointer to VM specific data
+ Copyright (C) 1999, 2000, 2004 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., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 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. */
+
+/* This file is originally part of libgcj. */
+
+package gnu.classpath;
+
+/** A type used to indicate special data used by native code that should not
+ be marked by the garbage collector. */
+
+public abstract class Pointer
+{
+}
--- /dev/null
+/* Pointer32.java -- 32 bit Pointer
+ Copyright (C) 2004 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., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+package gnu.classpath;
+
+/**
+ * A type used to indicate special data used by native code that should not
+ * be marked by the garbage collector.
+ */
+public final class Pointer32 extends Pointer
+{
+ final int data;
+
+ public Pointer32(int data)
+ {
+ this.data = data;
+ }
+}
--- /dev/null
+/* Pointer64.java -- 64 bit Pointer
+ Copyright (C) 2004 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., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+package gnu.classpath;
+
+/**
+ * A type used to indicate special data used by native code that should not
+ * be marked by the garbage collector.
+ */
+public final class Pointer64 extends Pointer
+{
+ final long data;
+
+ public Pointer64(long data)
+ {
+ this.data = data;
+ }
+}
--- /dev/null
+/* Jdwp.java -- Virtual machine to JDWP back-end programming interface
+ Copyright (C) 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., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 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
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package gnu.classpath.jdwp;
+
+import gnu.classpath.jdwp.event.Event;
+import gnu.classpath.jdwp.event.EventManager;
+import gnu.classpath.jdwp.event.EventRequest;
+import gnu.classpath.jdwp.id.ThreadId;
+import gnu.classpath.jdwp.processor.PacketProcessor;
+import gnu.classpath.jdwp.transport.ITransport;
+import gnu.classpath.jdwp.transport.JdwpConnection;
+import gnu.classpath.jdwp.transport.TransportException;
+import gnu.classpath.jdwp.transport.TransportFactory;
+
+import java.io.IOException;
+import java.security.AccessController;
+import java.util.HashMap;
+
+/**
+ * Main interface from the virtual machine to the JDWP back-end.
+ *
+ * @author Keith Seitz (keiths@redhat.com)
+ */
+public class Jdwp
+ extends Thread
+{
+ // The single instance of the back-end
+ private static Jdwp _instance = null;
+
+ /**
+ * Are we debugging?
+ */
+ public static boolean isDebugging = false;
+
+ // Packet processor
+ private PacketProcessor _packetProcessor;
+ private Thread _ppThread;
+
+ // JDWP configuration properties
+ private HashMap _properties;
+
+ // The suspend property of the configure string
+ // (-Xrunjdwp:..suspend=<boolean>)
+ private static final String _PROPERTY_SUSPEND = "suspend";
+
+ // User's main application thread
+ private Thread _mainThread;
+
+ // Connection to debugger
+ private JdwpConnection _connection;
+
+ // Are we shutting down the current session?
+ private boolean _shutdown;
+
+ // A thread group for the JDWP threads
+ private ThreadGroup _group;
+
+ /**
+ * constructor
+ */
+ public Jdwp ()
+ {
+ _shutdown = false;
+ isDebugging = true;
+ _instance = this;
+ }
+
+ /**
+ * Returns the JDWP back-end, creating an instance of it
+ * if one does not already exist.
+ */
+ public static Jdwp getDefault ()
+ {
+ return _instance;
+ }
+
+ /**
+ * Should the virtual machine suspend on startup?
+ */
+ public static boolean suspendOnStartup ()
+ {
+ Jdwp jdwp = getDefault ();
+ if (jdwp != null)
+ {
+ String suspend = (String) jdwp._properties.get (_PROPERTY_SUSPEND);
+ if (suspend != null && suspend.equals ("y"))
+ return true;
+ }
+
+ return false;
+ }
+
+ /**
+ * Configures the back-end
+ *
+ * @param configArgs a string of configury options
+ * @param mainThread the main application thread
+ */
+ public void configure (String configArgs, Thread mainThread)
+ {
+ _mainThread = mainThread;
+ _processConfigury (configArgs);
+ }
+
+ // A helper function to initialize the transport layer
+ private void _doInitialization ()
+ throws TransportException
+ {
+ _group = new ThreadGroup ("JDWP threads");
+ // initialize transport
+ ITransport transport = TransportFactory.newInstance (_properties);
+ _connection = new JdwpConnection (_group, transport);
+ _connection.initialize ();
+ _connection.start ();
+
+ // Create processor
+ _packetProcessor = new PacketProcessor (_connection);
+ _ppThread = new Thread (_group, new Runnable ()
+ {
+ public void run ()
+ {
+ AccessController.doPrivileged (_packetProcessor);
+ }
+ });
+ _ppThread.start ();
+ }
+
+ /**
+ * Shutdown the JDWP back-end
+ *
+ * NOTE: This does not quite work properly. See notes in
+ * run() on this subject (catch of InterruptedException).
+ */
+ public void shutdown ()
+ {
+ if (!_shutdown)
+ {
+ _packetProcessor.shutdown ();
+ _ppThread.interrupt ();
+ _connection.shutdown ();
+ _shutdown = true;
+ isDebugging = false;
+
+ /* FIXME: probably need to check state of user's
+ program -- if it is suspended, we need to either
+ resume or kill them. */
+
+ interrupt ();
+ }
+ }
+
+ /**
+ * Notify the debugger of an event. This method should not
+ * be called if debugging is not active (but it would not
+ * cause any harm). Places where event notifications occur
+ * should check isDebugging before doing anything.
+ *
+ * The event is filtered through the event manager before being
+ * sent.
+ *
+ * FIXME: Probably need logic to send multiple events
+ * @param event the event to report
+ */
+ public static void notify (Event event)
+ {
+ Jdwp jdwp = getDefault ();
+ if (jdwp != null)
+ {
+ EventManager em = EventManager.getDefault ();
+ EventRequest request = em.getEventRequest (event);
+ if (request != null)
+ sendEvent (request, event);
+ }
+ }
+
+ /**
+ * Sends the event to the debugger.
+ *
+ * This method bypasses the event manager's filtering.
+ *
+ * @param request the debugger request for the event
+ * @param event the event to send
+ */
+ public static void sendEvent (EventRequest request, Event event)
+ {
+ Jdwp jdwp = getDefault ();
+ if (jdwp != null)
+ {
+ try
+ {
+ // !! May need to implement send queue?
+ synchronized (jdwp._connection)
+ {
+ jdwp._connection.sendEvent (request, event);
+ }
+
+ // Follow suspend policy
+ jdwp._enforceSuspendPolicy (request.getSuspendPolicy ());
+ }
+ catch (IOException ie)
+ {
+ System.out.println ("Jdwp.notify: caught exception: " + ie);
+ }
+ }
+ }
+
+ // Helper function to enforce suspend policies on event notification
+ private void _enforceSuspendPolicy (byte suspendPolicy)
+ {
+ switch (suspendPolicy)
+ {
+ case EventRequest.SUSPEND_NONE:
+ // do nothing
+ break;
+
+ case EventRequest.SUSPEND_THREAD:
+ VMVirtualMachine.suspendThread (this);
+ break;
+
+ case EventRequest.SUSPEND_ALL:
+ VMVirtualMachine.suspendAllThreads ();
+ break;
+ }
+ }
+
+ public void run ()
+ {
+ try
+ {
+ _doInitialization ();
+
+ _mainThread.start ();
+
+ _mainThread.join ();
+ }
+ catch (InterruptedException ie)
+ {
+ /* Shutting down. If we're in server mode, we should
+ prepare for a new connection. Otherwise, we should
+ simply exit. */
+ // FIXME
+ }
+ catch (Throwable t)
+ {
+ System.out.println ("Exception in JDWP back-end: " + t);
+ System.exit (1);
+ }
+ }
+
+ // A helper function to process the configure string "-Xrunjdwp:..."
+ private void _processConfigury (String configString)
+ {
+ // Loop through configuration arguments looking for a
+ // transport name
+ _properties = new HashMap ();
+ String[] options = configString.split (",");
+ for (int i = 0; i < options.length; ++i)
+ {
+ String[] property = options[i].split ("=");
+ if (property.length == 2)
+ _properties.put (property[0], property[1]);
+ // ignore malformed options
+ }
+ }
+}
--- /dev/null
+/* JdwpConstants.java -- Constants defined by JDWP 1.4 specification
+ Copyright (C) 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., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 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
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package gnu.classpath.jdwp;
+
+/**
+ * Constants defined by JDWP specification.
+ *
+ * @author Keith Seitz (keiths@redhat.com)
+ */
+public class JdwpConstants
+{
+ public static final class Version
+ {
+ public static final int MAJOR = 1;
+ public static final int MINOR = 4;
+ }
+
+ ////////////////////////////////////////
+ // Commands/Sets //
+ ////////////////////////////////////////
+
+ public static final class CommandSet
+ {
+ public static final class VirtualMachine
+ {
+ public static final byte CS_VALUE = 1;
+
+ // commands
+ public static final byte VERSION = 1;
+ public static final byte CLASSES_BY_SIGNATURE = 2;
+ public static final byte ALL_CLASSES = 3;
+ public static final byte ALL_THREADS = 4;
+ public static final byte TOP_LEVEL_THREAD_GROUPS = 5;
+ public static final byte DISPOSE = 6;
+ public static final byte IDSIZES = 7;
+ public static final byte SUSPEND = 8;
+ public static final byte RESUME = 9;
+ public static final byte EXIT = 10;
+ public static final byte CREATE_STRING = 11;
+ public static final byte CAPABILITIES = 12;
+ public static final byte CLASS_PATHS = 13;
+ public static final byte DISPOSE_OBJECTS = 14;
+ public static final byte HOLD_EVENTS = 15;
+ public static final byte RELEASE_EVENTS = 16;
+ public static final byte CAPABILITIES_NEW = 17;
+ public static final byte REDEFINE_CLASSES = 18;
+ public static final byte SET_DEFAULT_STRATUM = 19;
+ public static final byte ALL_CLASSES_WITH_GENERIC = 20;
+ }
+
+ public static final class ReferenceType
+ {
+ public static final byte CS_VALUE = 2;
+
+ // commands
+ public static final byte SIGNATURE= 1;
+ public static final byte CLASS_LOADER= 2;
+ public static final byte MODIFIERS = 3;
+ public static final byte FIELDS = 4;
+ public static final byte METHODS = 5;
+ public static final byte GET_VALUES = 6;
+ public static final byte SOURCE_FILE = 7;
+ public static final byte NESTED_TYPES = 8;
+ public static final byte STATUS = 9;
+ public static final byte INTERFACES= 10;
+ public static final byte CLASS_OBJECT = 11;
+ public static final byte SOURCE_DEBUG_EXTENSION = 12;
+ public static final byte SIGNATURE_WITH_GENERIC = 13;
+ public static final byte FIELDS_WITH_GENERIC = 14;
+ public static final byte METHODS_WITH_GENERIC = 15;
+ }
+
+ public static final class ClassType
+ {
+ public static final byte CS_VALUE = 3;
+
+ // commands
+ public static final byte SUPERCLASS = 1;
+ public static final byte SET_VALUES = 2;
+ public static final byte INVOKE_METHOD = 3;
+ public static final byte NEW_INSTANCE = 4;
+ }
+
+ public static final class ArrayType
+ {
+ public static final byte CS_VALUE = 4;
+
+ // commands
+ public static final byte NEW_INSTANCE = 1;
+ }
+
+ public static final class InterfaceType
+ {
+ public static final byte CS_VALUE = 5;
+
+ // commands
+ }
+
+ public static final class Method
+ {
+ public static final byte CS_VALUE = 6;
+
+ // commands
+ public static final byte LINE_TABLE = 1;
+ public static final byte VARIABLE_TABLE = 2;
+ public static final byte BYTE_CODES = 3;
+ public static final byte IS_OBSOLETE = 4;
+ public static final byte VARIABLE_TABLE_WITH_GENERIC = 5;
+ }
+
+ public static final class Field
+ {
+ public static final byte CS_VALUE = 8;
+
+ // commands
+ }
+
+ public static final class ObjectReference
+ {
+ public static final byte CS_VALUE = 9;
+
+ // commands
+ public static final byte REFERENCE_TYPE = 1;
+ public static final byte GET_VALUES = 2;
+ public static final byte SET_VALUES = 3;
+ public static final byte MONITOR_INFO = 5;
+ public static final byte INVOKE_METHOD = 6;
+ public static final byte DISABLE_COLLECTION = 7;
+ public static final byte ENABLE_COLLECTION = 8;
+ public static final byte IS_COLLECTED = 9;
+ }
+
+ public static final class StringReference
+ {
+ public static final byte CS_VALUE = 10;
+
+ // commands
+ public static final byte VALUE = 1;
+ }
+
+ public static final class ThreadReference
+ {
+ public static final byte CS_VALUE = 11;
+
+ // commands
+ public static final byte NAME = 1;
+ public static final byte SUSPEND = 2;
+ public static final byte RESUME = 3;
+ public static final byte STATUS = 4;
+ public static final byte THREAD_GROUP = 5;
+ public static final byte FRAMES = 6;
+ public static final byte FRAME_COUNT = 7;
+ public static final byte OWNED_MONITORS = 8;
+ public static final byte CURRENT_CONTENDED_MONITOR = 9;
+ public static final byte STOP = 10;
+ public static final byte INTERRUPT = 11;
+ public static final byte SUSPEND_COUNT = 12;
+ }
+
+ public static final class ThreadGroupReference
+ {
+ public static final byte CS_VALUE = 12;
+
+ // commands
+ public static final byte NAME = 1;
+ public static final byte PARENT = 2;
+ public static final byte CHILDREN = 3;
+ }
+
+ public static final class ArrayReference
+ {
+ public static final byte CS_VALUE = 13;
+
+ // commands
+ public static final byte LENGTH = 1;
+ public static final byte GET_VALUES = 2;
+ public static final byte SET_VALUES = 3;
+ }
+
+ public static final class ClassLoaderReference
+ {
+ public static final byte CS_VALUE = 14;
+
+ // commands
+ public static final byte VISIBLE_CLASSES = 1;
+ }
+
+ public static final class EventRequest
+ {
+ public static final byte CS_VALUE = 15;
+
+ // commands
+ public static final byte SET = 1;
+ public static final byte CLEAR = 2;
+ public static final byte CLEAR_ALL_BREAKPOINTS = 3;
+ }
+
+ public static final class StackFrame
+ {
+ public static final byte CS_VALUE = 16;
+
+ // commands
+ public static final byte GET_VALUES = 1;
+ public static final byte SET_VALUES = 2;
+ public static final byte THIS_OBJECT = 3;
+ public static final byte POP_FRAMES = 4;
+ }
+
+ public static final class ClassObjectReference
+ {
+ public static final byte CS_VALUE = 17;
+
+ // commands
+ public static final byte REFLECTED_TYPE = 1;
+ }
+
+ public static final int MAXIMUM = ClassObjectReference.CS_VALUE;
+
+ public static final class Event
+ {
+ public static final byte CS_VALUE = 64;
+
+ // commands
+ public static final byte COMPOSITE = 100;
+ }
+ }
+
+ ////////////////////////////////////////
+ // Constants //
+ ////////////////////////////////////////
+
+ /*
+ * Error constants
+ */
+ public static final class Error
+ {
+ /**
+ * No error has occurred
+ */
+ public static final short NONE = 0;
+
+ /**
+ * Passed thread is null, is not a valid thread or has exited
+ */
+ public static final short INVALID_THREAD = 10;
+
+ /**
+ * Thread group invalid
+ */
+ public static final short INVALID_THREAD_GROUP = 11;
+
+ /**
+ * Invalid priority
+ */
+ public static final short INVALID_PRIORITY = 12;
+
+ /**
+ * Specified thread has not been suspended by an event
+ */
+ public static final short THREAD_NOT_SUSPENDED = 13;
+
+ /**
+ * Thread already suspended
+ */
+ public static final short THREAD_SUSPENDED = 14;
+
+ /**
+ * Reference type has been unloaded and garbage collected
+ */
+ public static final short INVALID_OBJECT = 20;
+
+ /**
+ * Invalid class
+ */
+ public static final short INVALID_CLASS = 21;
+
+ /**
+ * Class has been loaded but not yet prepared
+ */
+ public static final short CLASS_NOT_PREPARED = 22;
+
+ /**
+ * Invalid method
+ */
+ public static final short INVALID_METHODID = 23;
+
+ /**
+ * Invalid location
+ */
+ public static final short INVALID_LOCATION = 24;
+
+ /**
+ * Invalid field
+ */
+ public static final short INVALID_FIELDID = 25;
+
+ /**
+ * Invaliid frame
+ */
+ public static final short INVALID_FRAMEID = 30;
+
+ /**
+ * There are no more Java or JNI frames on the call stack
+ */
+ public static final short NO_MORE_FRAMES = 31;
+
+ /**
+ * Information about the frame is not available
+ */
+ public static final short OPAQUE_FRAME = 32;
+
+ /**
+ * Operation can only be performed on current frame
+ */
+ public static final short NOT_CURRENT_FRAME = 33;
+
+ /**
+ * Variable is not an appropriate type for the function used
+ */
+ public static final short TYPE_MISMATCH = 34;
+
+ /**
+ * Invalid slot
+ */
+ public static final short INVALID_SLOT = 35;
+
+ /**
+ * Item already set
+ */
+ public static final short DUPLICATE = 40;
+
+ /**
+ * Desired element not found
+ */
+ public static final short NOT_FOUND = 41;
+
+ /**
+ * Invalid monitor
+ */
+ public static final short INVALID_MONITOR = 50;
+
+ /**
+ * Thread doesn't own the monitor
+ */
+ public static final short NOT_MONITOR_OWNER = 51;
+
+ /**
+ * Call has been interrupted before completion
+ */
+ public static final short INTERRUPT = 52;
+
+ /**
+ * Virtual machine attempted to read a class file and determined that
+ * the file is malformed or otherwise cannot be interpreted as a class
+ * file
+ */
+ public static final short INVALID_CLASS_FORMAT = 60;
+
+ /**
+ * Circularity has been detected while initializing a class
+ */
+ public static final short CIRCULAR_CLASS_DEFINITION = 61;
+
+ /**
+ * Verifier detected that a class file, though well formed, contained
+ * some sort of internal inconsistency or security problem
+ */
+ public static final short FAILS_VERIFICATION = 62;
+
+ /**
+ * Adding methods has not been implemented
+ */
+ public static final short ADD_METHOD_NOT_IMPLEMENTED = 63;
+
+ /**
+ * Schema change has not been implemented
+ */
+ public static final short SCHEMA_CHANGE_NOT_IMPLEMENTED = 64;
+
+ /**
+ * State of the thread has been modified and is now inconsistent
+ */
+ public static final short INVALID_TYPESTATE = 65;
+
+ /**
+ * A direct superclass is different for the new class version, or the set
+ * of directly implemented interfaces is different and
+ * <code>canUnrestrictedlyRedefineClasses</code> is false
+ */
+ public static final short HIERARCHY_CHANGE_NOT_IMPLEMENTED = 66;
+
+ /**
+ * New class version does not declare a method declared in the old
+ * class version and <code>canUnrestrictedlyRedefineClasses</code>
+ * is false
+ */
+ public static final short DELETE_METHOD_NOT_IMPLEMENTED = 67;
+
+ /**
+ * Class file has a version number not supported by this VM
+ */
+ public static final short UNSUPPORTED_VERSION = 68;
+
+ /**
+ * Class name defined in the new class file is different from the name
+ * in the old class object
+ */
+ public static final short NAMES_DONT_MATCH = 69;
+
+ /**
+ * New class version has different modifiers and
+ * <code>canUnrestrictedlyRedefineClasses</code> is false
+ */
+ public static final short CLASS_MODIFIERS_CHANGE_NOT_IMPLEMENTED = 70;
+
+ /**
+ * A method in the new class version has different modifiers than its
+ * counterpart in the old class version and
+ * <code>canUnrestrictedlyRedefineClasses</code> is false.
+ */
+ public static final short METHOD_MODIFIERS_CHANGE_NOT_IMPLEMENTED = 71;
+
+ /**
+ * Functionality is not implemented in this virtual machine
+ */
+ public static final short NOT_IMPLEMENTED = 99;
+
+ /**
+ * Invalid pointer
+ */
+ public static final short NULL_POINTER = 100;
+
+ /**
+ * Desired information is not available
+ */
+ public static final short ABSENT_INFORMATION = 101;
+
+ /**
+ * Specified event type id is not recognized
+ */
+ public static final short INVALID_EVENT_TYPE = 102;
+
+ /**
+ * Illegal argument
+ */
+ public static final short ILLEGAL_ARGUMENT = 103;
+
+ /**
+ * The function needed to allocate memory and no more memory was
+ * available for allocation
+ */
+ public static final short OUT_OF_MEMORY = 110;
+
+ /**
+ * Debugging has not been enabled in this virtual machine. JVMDI cannot
+ * be used
+ */
+ public static final short ACCESS_DENIED = 111;
+
+ /**
+ * The virtual machine is not running
+ */
+ public static final short VM_DEAD = 112;
+
+ /**
+ * An unexpected internal error has occurred
+ */
+ public static final short INTERNAL = 113;
+
+ /**
+ * The thread being used to call this function is not attached to the
+ * virtual machine. Calls must be made from attached threads.
+ */
+ public static final short UNATTACHED_THREAD = 115;
+
+ /**
+ * Invalid object type id or class tag
+ */
+ public static final short INVALID_TAG = 500;
+
+ /**
+ * Previous invoke not complete
+ */
+ public static final short ALREADY_INVOKING = 502;
+
+ /**
+ * Invalid index
+ */
+ public static final short INVALID_INDEX = 503;
+
+ /**
+ * Invalid length
+ */
+ public static final short INVALID_LENGTH = 504;
+
+ /**
+ * Invalid string
+ */
+ public static final short INVALID_STRING = 506;
+
+ /**
+ * Invalid class loader
+ */
+ public static final short INVALID_CLASS_LOADER = 507;
+
+ /**
+ * Invalid array
+ */
+ public static final short INVALID_ARRAY = 508;
+
+ /**
+ * Unable to load the transport
+ */
+ public static final short TRANSPORT_LOAD = 509;
+
+ /**
+ * Unablie to initialize the transport
+ */
+ public static final short TRANSPORT_INIT = 510;
+
+ /**
+ * Method is native
+ */
+ public static final short NATIVE_METHOD = 511;
+
+ /**
+ * Invalid count
+ */
+ public static final short INVALID_COUNT = 512;
+ }
+
+ /*
+ * EventKind constants
+ */
+ public static final class EventKind
+ {
+ public static final byte SINGLE_STEP = 1;
+ public static final byte BREAKPOINT = 2;
+ public static final byte FRAME_POP = 3;
+ public static final byte EXCEPTION = 4;
+ public static final byte USER_DEFINED = 5;
+ public static final byte THREAD_START = 6;
+ public static final byte THREAD_END = 7;
+ public static final byte CLASS_PREPARE = 8;
+ public static final byte CLASS_UNLOAD = 9;
+ public static final byte CLASS_LOAD = 10;
+ public static final byte FIELD_ACCESS = 20;
+ public static final byte FIELD_MODIFICATION = 21;
+ public static final byte EXCEPTION_CATCH = 30;
+ public static final byte METHOD_ENTRY = 40;
+ public static final byte METHOD_EXIT = 41;
+ public static final byte VM_INIT = 90;
+ public static final byte VM_DEATH = 99;
+ public static final byte VM_DISCONNECTED = 100;
+
+ public static final byte VM_START = VM_INIT;
+ public static final byte THREAD_DEATH = THREAD_END;
+ }
+
+ /*
+ * ModKind constants (event filters)
+ */
+ public static final class ModKind
+ {
+ /**
+ * Limit the requested event to be reported at most once after a
+ * given number of occurrences. May be used with any event.
+ */
+ public static final byte COUNT = 1;
+
+ /**
+ * Conditional on expression
+ */
+ public static final byte CONDITIONAL = 2;
+
+ /**
+ * Restricts reported events to those in the given thread.
+ * May be used with any event except for class unload.
+ */
+ public static final byte THREAD_ONLY = 3;
+
+ /**
+ * For class prepare events, restricts generated events
+ * to be the preparation of the given reference type and any
+ * subtypes.
+ *
+ * For other events, restricts the generated events to those where
+ * location is in the given reference type or any of its subtypes.
+ *
+ * An event will be generated for any location in a reference type
+ * that can be safely cast to the given reference type.
+ *
+ * May be used with any event except class unload, thread start,
+ * and thread end.
+ */
+ public static final byte CLASS_ONLY = 4;
+
+ /**
+ * Restricts reported events to those for classes whose name matches
+ * the given restricted regular expression.
+ *
+ * For class prepare events, the prepared class name is matched.
+ * For class unload events, the unloaded class name is matched.
+ * For other events, the class name of the event's location is matched.
+ *
+ * May be used with any event except thread start and thread end.
+ */
+ public static final byte CLASS_MATCH = 5;
+
+ /**
+ * Restricts reported events to those for classes whose name does not
+ * match the given restricted regular expression.
+ *
+ * For class prepare events, the prepared class name is matched.
+ * For class unload events, the unloaded class name is matched.
+ * For other events, the class name of the event's location is matched.
+ *
+ * May be used with any event except thread start and thread end.
+ */
+ public static final byte CLASS_EXCLUDE = 6;
+
+ /**
+ * Restricts reported events to those that occur at the given location.
+ *
+ * May be used with breakpoint, field access, field modification, step,
+ * and exception event kinds.
+ */
+ public static final byte LOCATION_ONLY = 7;
+
+ /**
+ * Restricts reported exceptions by their class and whether they are
+ * caught or uncaught.
+ *
+ * May be used with exception event kinds only.
+ */
+ public static final byte EXCEPTION_ONLY = 8;
+
+ /**
+ * Restricts reported events to those that occur for a given field.
+ *
+ * May be used with field access and field modification event kinds only.
+ */
+ public static final byte FIELD_ONLY = 9;
+
+ /**
+ * Restricts reported step events to those which satisfy depth and
+ * size constraints.
+ *
+ * May be used with step event kinds only.
+ */
+ public static final byte STEP = 10;
+
+ /**
+ * Restricts reported events to those whose active 'this' object is
+ * the given object. Match value is the null object for static methods.
+ *
+ * May be used with any event except class prepare, class unload,
+ * thread start, and thread end.
+ */
+ public static final byte INSTANCE_ONLY = 11;
+ }
+
+ /*
+ * ThreadStatus constants
+ */
+ public static final class ThreadStatus
+ {
+ public static final int ZOMBIE = 0;
+ public static final int RUNNING = 1;
+ public static final int SLEEPING = 2;
+ public static final int MONITOR = 3;
+ public static final int WAIT = 4;
+ }
+
+ /*
+ * SuspendStatus constants
+ */
+ public static final class SuspendStatus
+ {
+ public static final byte SUSPENDED = 1;
+ }
+
+ /*
+ * ClassStatus constants
+ */
+ public static final class ClassStatus
+ {
+ public static final int VERIFIED = 1;
+ public static final int PREPARED = 2;
+ public static final int INITIALIZED = 4;
+ public static final int ERROR = 8;
+ }
+
+ /*
+ * TypeTag constants
+ */
+ public static final class TypeTag
+ {
+ public static final byte CLASS = 1;
+ public static final byte INTERFACE = 2;
+ public static final byte ARRAY = 3;
+ }
+
+ /*
+ * Tag constants
+ */
+ public static final class Tag
+ {
+ /**
+ * Array object (objectID size)
+ */
+ public static final byte ARRAY = '[';
+
+ /**
+ * Byte value (1 byte)
+ */
+ public static final byte BYTE = 'B';
+
+ /**
+ * Character value (2 bytes)
+ */
+ public static final byte CHAR = 'C';
+
+ /**
+ * Object (objectID size)
+ */
+ public static final byte OBJECT = 'L';
+
+ /**
+ * Float value (4 bytes)
+ */
+ public static final byte FLOAT = 'F';
+
+ /**
+ * Double value (8 bytes)
+ */
+ public static final byte DOUBLE = 'D';
+
+ /**
+ * Int value (4 bytes)
+ */
+ public static final byte INT = 'I';
+
+ /**
+ * Long value (8 bytes)
+ */
+ public static final byte LONG = 'J';
+
+ /**
+ * Short value (2 bytes)
+ */
+ public static final byte SHORT = 'S';
+
+ /**
+ * Void value (no bytes)
+ */
+ public static final byte VOID = 'V';
+
+ /**
+ * Boolean value (1 byte)
+ */
+ public static final byte BOOLEAN = 'Z';
+
+ /**
+ * String object (objectID size)
+ */
+ public static final byte STRING = 's';
+
+ /**
+ * Thread object (objectID size)
+ */
+ public static final byte THREAD = 't';
+
+ /**
+ * ThreadGroup object (objectID size)
+ */
+ public static final byte THREAD_GROUP = 'g';
+
+ /**
+ * ClassLoader object (objectID size)
+ */
+ public static final byte CLASS_LOADER = 'l';
+
+ /**
+ * Class object object (objectID size)
+ */
+ public static final byte CLASS_OBJECT = 'c';
+ }
+
+ /*
+ * StepDepth constants
+ */
+ public static final class StepDepth
+ {
+ /**
+ * Step into any method calls that occur before the end of the step
+ */
+ public static final int INTO = 0;
+
+ /**
+ * Step over any method calls that occur before the end of the step
+ */
+ public static final int OVER = 1;
+
+ /**
+ * Step out of the current method
+ */
+ public static final int OUT = 2;
+ }
+
+ /*
+ * StepSize constants
+ */
+ public static final class StepSize
+ {
+ /**
+ * Step by the minimum possible amount (often a bytecode instruction)
+ */
+ public static final int MIN = 0;
+
+ /**
+ * Step to the next source line unless there is no line number information,
+ * in which case MIN step is done instead
+ */
+ public static final int LINE = 1;
+ }
+
+ /*
+ * SuspendPolicy constants
+ */
+ public static final class SuspendPolicy
+ {
+ /**
+ * Suspend no threads when this event is encountered
+ */
+ public static final byte NONE = 0;
+
+ /**
+ * Suspend the event thread when this event is encountered
+ */
+ public static final byte EVENT_THREAD = 1;
+
+ /**
+ * Suspend all threads when this event is encountered
+ */
+ public static final byte ALL = 2;
+ }
+
+ /*
+ * InvokeOptions flag constants
+ */
+ public static final class InvokeOptions
+ {
+ /**
+ * otherwise, all threads started
+ */
+ public static final int INVOKE_SINGLE_THREADED = 0x1;
+
+ /**
+ * otherwise, normal virtual invoke (instance methods only)
+ */
+ public static final int INVOKE_NONVIRTUAL = 0x2;
+ }
+}
--- /dev/null
+/* ClassPrepareEvent.java -- An event specifying that a class has been
+ prepared by the virtual machine
+ Copyright (C) 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., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 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
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package gnu.classpath.jdwp.event;
+
+import gnu.classpath.jdwp.JdwpConstants;
+import gnu.classpath.jdwp.VMIdManager;
+import gnu.classpath.jdwp.id.ReferenceTypeId;
+import gnu.classpath.jdwp.id.ThreadId;
+import gnu.classpath.jdwp.util.JdwpString;
+import gnu.classpath.jdwp.util.Signature;
+
+import java.io.DataOutputStream;
+import java.io.IOException;
+
+/**
+ * "Notification of a class prepare in the target VM. See the JVM
+ * specification for a definition of class preparation. Class prepare
+ * events are not generated for primtiive classes (for example,
+ * <code>java.lang.Integer.TYPE</code>)." -- JDWP 1.4.2
+ *
+ * @author Keith Seitz (keiths@redhat.com)
+ */
+public class ClassPrepareEvent
+ extends Event
+{
+ // The thread in which this event occurred
+ private Thread _thread;
+
+ // The class that was prepared
+ private Class _class;
+
+ // Prepare flags
+ private int _status;
+
+ /**
+ * Class has been verified
+ */
+ public static final int STATUS_VERIFIED
+ = JdwpConstants.ClassStatus.VERIFIED;
+
+ /**
+ * Class has been prepared
+ */
+ public static final int STATUS_PREPARED
+ = JdwpConstants.ClassStatus.PREPARED;
+
+ /**
+ * Class has been initialized
+ */
+ public static final int STATUS_INITIALIZED
+ = JdwpConstants.ClassStatus.INITIALIZED;
+
+ /**
+ * Error preparing class
+ */
+ public static final int STATUS_ERROR
+ = JdwpConstants.ClassStatus.ERROR;
+
+ /**
+ * Constructs a new <code>ClassPrepareEvent</code>
+ *
+ * @param thread thread in which event occurred
+ * @param clazz class which was prepared
+ * @param flags prepare status flags
+ */
+ public ClassPrepareEvent (Thread thread, Class clazz, int flags)
+ {
+ super (JdwpConstants.EventKind.CLASS_PREPARE);
+ _thread = thread;
+ _class = clazz;
+ _status = flags;
+ }
+
+ /**
+ * Returns a specific filtering parameter for this event.
+ * Valid types are thread and class.
+ *
+ * @param type the type of parameter desired
+ * @returns the desired parameter or <code>null</code>
+ */
+ public Object getParameter (Class type)
+ {
+ if (type == ThreadId.class)
+ return _thread;
+ else if (type == ReferenceTypeId.class)
+ return _class;
+
+ return null;
+ }
+
+ /**
+ * Writes the event to the given stream
+ *
+ * @param outStream the output stream to write the event to
+ */
+ protected void _writeData (DataOutputStream outStream)
+ throws IOException
+ {
+ VMIdManager idm = VMIdManager.getDefault();
+ ThreadId tid = (ThreadId) idm.getObjectId (_thread);
+ ReferenceTypeId rid = idm.getReferenceTypeId (_class);
+
+ tid.write (outStream);
+ rid.writeTagged (outStream);
+ JdwpString.writeString (outStream,
+ Signature.computeClassSignature (_class));
+ outStream.writeInt (_status);
+ }
+}
--- /dev/null
+/* Event.java -- a base class for all event types
+ Copyright (C) 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., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 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
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package gnu.classpath.jdwp.event;
+
+import gnu.classpath.jdwp.JdwpConstants;
+import gnu.classpath.jdwp.transport.JdwpCommandPacket;
+import gnu.classpath.jdwp.transport.JdwpPacket;
+
+import java.io.DataOutputStream;
+import java.io.IOException;
+
+/**
+ * This class is a base class for all VM->debugger event
+ * notifications.
+ *
+ * @author Keith Seitz (keiths@redhat.com)
+ */
+public abstract class Event
+{
+ // The kind of event represented by this event
+ private byte _eventKind;
+
+ /**
+ * Constructs an <code>Event</code> of the given kind
+ *
+ * @param kind the type of event
+ */
+ public Event (byte kind)
+ {
+ _eventKind = kind;
+ }
+
+ /**
+ * Returns the event type of this event
+ *
+ * @returns the event kind
+ */
+ public byte getEventKind ()
+ {
+ return _eventKind;
+ }
+
+ /**
+ * Abstract function used by implementing classes to fill in the
+ * event-specific data. Note that request ID is automatically added
+ * by this class (since it appears in all event notifications).
+ *
+ * @param outStream the stream to which to write data
+ */
+ protected abstract void _writeData (DataOutputStream outStream)
+ throws IOException;
+
+ /**
+ * Returns a specific filtering parameter for this event. For example,
+ * most events may be filtered by thread. Consequently, a call to this
+ * method with <code>ThreadId.class</code> should return a
+ * <code>Thread</code>.
+ *
+ * @param type the type of parameter to return
+ * @returns the parameter (not the ID) or <code>null</code> if none is
+ * is defined for this event
+ */
+ public abstract Object getParameter (Class type);
+
+ /**
+ * Converts this event into to a JDWP packet
+ *
+ * @param dos the stream to which to write data
+ * @param request the request the wanted this notification
+ * @returns a <code>JdwpPacket</code> of the events
+ */
+ public JdwpPacket toPacket (DataOutputStream dos, EventRequest request)
+ {
+ JdwpPacket pkt;
+ try
+ {
+ dos.writeByte (request.getSuspendPolicy ());
+ dos.writeInt (1);
+ dos.writeByte (_eventKind);
+ dos.writeInt (request.getId ());
+ _writeData (dos);
+
+ pkt = new JdwpCommandPacket (JdwpConstants.CommandSet.Event.CS_VALUE,
+ JdwpConstants.CommandSet.Event.COMPOSITE);
+ }
+ catch (IOException ioe)
+ {
+ pkt = null;
+ }
+
+ return pkt;
+ }
+}
--- /dev/null
+/* EventManager.java -- event management and notification infrastructure
+ Copyright (C) 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., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 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
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package gnu.classpath.jdwp.event;
+
+import gnu.classpath.jdwp.VMVirtualMachine;
+import gnu.classpath.jdwp.exception.InvalidEventTypeException;
+
+import java.util.Collection;
+import java.util.Hashtable;
+import java.util.Iterator;
+
+/**
+ * Manages event requests and filters event notifications.
+ *
+ * The purpose of this class is actually two-fold:
+ *
+ * 1) Maintain a list of event requests from the debugger
+ * 2) Filter event notifications from the VM
+ *
+ * If an event request arrives from the debugger, the back-end will
+ * call {@link #reqestEvent}, which will first check for a valid event.
+ * If it is valid, <code>EventManager</code> will record the request
+ * internally and register the event with the virtual machine, which may
+ * choose to handle the request itself (as is likely the case with
+ * breakpoints and other execution-related events), or it may decide to
+ * allow the <code>EventManager</code> to handle notifications and all
+ * filtering (which is convenient for other events such as class (un)loading).
+ *
+ * @author Keith Seitz (keiths@redhat.com)
+ */
+public class EventManager
+{
+ // Single instance
+ private static EventManager _instance = new EventManager ();
+
+ // maps event (EVENT_*) to lists of EventRequests
+ private Hashtable _requests = null;
+
+ /**
+ * Returns an instance of the event manager
+ *
+ * @return the event manager
+ */
+ public static EventManager getDefault ()
+ {
+ return _instance;
+ }
+
+ // Private constructs a new <code>EventManager</code>
+ private EventManager ()
+ {
+ _requests = new Hashtable ();
+
+ // Add lists for all the event types
+ _requests.put (new Byte (EventRequest.EVENT_SINGLE_STEP),
+ new Hashtable ());
+ _requests.put (new Byte (EventRequest.EVENT_BREAKPOINT),
+ new Hashtable ());
+ _requests.put (new Byte (EventRequest.EVENT_FRAME_POP),
+ new Hashtable ());
+ _requests.put (new Byte (EventRequest.EVENT_EXCEPTION),
+ new Hashtable ());
+ _requests.put (new Byte (EventRequest.EVENT_USER_DEFINED),
+ new Hashtable ());
+ _requests.put (new Byte (EventRequest.EVENT_THREAD_START),
+ new Hashtable ());
+ _requests.put (new Byte (EventRequest.EVENT_THREAD_END),
+ new Hashtable ());
+ _requests.put (new Byte (EventRequest.EVENT_CLASS_PREPARE),
+ new Hashtable ());
+ _requests.put (new Byte (EventRequest.EVENT_CLASS_UNLOAD),
+ new Hashtable ());
+ _requests.put (new Byte (EventRequest.EVENT_CLASS_LOAD),
+ new Hashtable ());
+ _requests.put (new Byte (EventRequest.EVENT_FIELD_ACCESS),
+ new Hashtable ());
+ _requests.put (new Byte (EventRequest.EVENT_FIELD_MODIFY),
+ new Hashtable ());
+ _requests.put (new Byte (EventRequest.EVENT_METHOD_ENTRY),
+ new Hashtable ());
+ _requests.put (new Byte (EventRequest.EVENT_METHOD_EXIT),
+ new Hashtable ());
+ _requests.put (new Byte (EventRequest.EVENT_VM_INIT),
+ new Hashtable ());
+ _requests.put (new Byte (EventRequest.EVENT_VM_DEATH),
+ new Hashtable ());
+
+ // Add auto-generated event notifications
+ // only two: VM_INIT, VM_DEATH
+ try
+ {
+ requestEvent (new EventRequest (0,
+ EventRequest.EVENT_VM_INIT,
+ EventRequest.SUSPEND_NONE));
+ requestEvent (new EventRequest (0,
+ EventRequest.EVENT_VM_DEATH,
+ EventRequest.SUSPEND_NONE));
+ }
+ catch (InvalidEventTypeException e)
+ {
+ // This can't happen
+ }
+ }
+
+ /**
+ * Returns a request for the given event. This method will only
+ * be used if the <code>EventManager</code> is handling event filtering.
+ *
+ * @param event the event
+ * @return request that was interested in this event
+ * or <code>null</code> if none (and event should not be sent)
+ * @throws IllegalArgumentException for invalid event kind
+ */
+ public EventRequest getEventRequest (Event event)
+ {
+ EventRequest interestedRequest = null;
+ Hashtable requests;
+ Byte kind = new Byte (event.getEventKind ());
+ requests = (Hashtable) _requests.get (kind);
+ if (requests == null)
+ {
+ // Did not get a valid event type
+ throw new IllegalArgumentException ("invalid event kind: " + kind);
+ }
+ boolean match = false;
+
+ // Loop through the requests. Must look at ALL requests in order
+ // to evaluate all filters (think count filter).
+ // TODO: What if multiple matches? Spec isn't so clear on this.
+ Iterator rIter = requests.values().iterator ();
+ while (rIter.hasNext ())
+ {
+ EventRequest request = (EventRequest) rIter.next ();
+ if (request.matches (event))
+ interestedRequest = request;
+ }
+
+ return interestedRequest;
+ }
+
+ /**
+ * Requests monitoring of an event.
+ *
+ * The debugger registers for event notification through
+ * an event filter. If no event filter is specified for an event
+ * in the VM, it is assumed that the debugger is not interested in
+ * receiving notifications of this event.
+ *
+ * The virtual machine will be notified of the request.
+ *
+ * @param request the request to monitor
+ * @throws InvalidEventTypeException for invalid event kind
+ */
+ public void requestEvent (EventRequest request)
+ throws InvalidEventTypeException
+ {
+ // Add request to request list
+ Hashtable requests;
+ Byte kind = new Byte (request.getEventKind ());
+ requests = (Hashtable) _requests.get (kind);
+ if (requests == null)
+ {
+ // Did not get a valid event type
+ throw new InvalidEventTypeException (request.getEventKind ());
+ }
+
+ // Register the event with the VM
+ VMVirtualMachine.registerEvent (request);
+ requests.put (new Integer (request.getId ()), request);
+ }
+
+ /**
+ * Deletes the given request from the management table
+ *
+ * @param kind the event kind
+ * @param id the ID of the request to delete
+ * @throws IllegalArgumentException for invalid event kind
+ */
+ public void deleteRequest (byte kind, int id)
+ {
+ Hashtable requests;
+ requests = (Hashtable) _requests.get (new Byte (kind));
+ if (requests == null)
+ {
+ // Did not get a valid event type
+ throw new IllegalArgumentException ("invalid event kind: " + kind);
+ }
+
+ Integer iid = new Integer (id);
+ EventRequest request = (EventRequest) requests.get (iid);
+ if (request != null)
+ {
+ VMVirtualMachine.unregisterEvent (request);
+ requests.remove (iid);
+ }
+ }
+
+ /**
+ * Clears all the requests for a given event
+ *
+ * @param kind the event kind
+ * @throws IllegalArgumentException for invalid event kind
+ */
+ public void clearRequests (byte kind)
+ {
+ Hashtable requests = (Hashtable) _requests.get (new Byte (kind));
+ if (requests == null)
+ {
+ // Did not get a valid event type
+ throw new IllegalArgumentException ("invalid event kind: " + kind);
+ }
+
+ VMVirtualMachine.clearEvents (kind);
+ requests.clear ();
+ }
+
+ /**
+ * Returns a given event request for an event
+ *
+ * @param kind the kind of event for the request
+ * @param id the integer request id to return
+ * @return the request for the given event kind with the given id
+ * (or <code>null</code> if not found)
+ * @throws IllegalArgumentException for invalid event kind
+ */
+ public EventRequest getRequest (byte kind, int id)
+ {
+ Hashtable requests = (Hashtable) _requests.get (new Byte (kind));
+ if (requests == null)
+ {
+ // Did not get a valid event type
+ throw new IllegalArgumentException ("invalid event kind: " + kind);
+ }
+
+ return (EventRequest) requests.get (new Integer (id));
+ }
+
+ /**
+ * Returns all requests of the given event kind
+ *
+ * @param kind the event kind
+ * @returns a <code>Collection</code> of all the registered requests
+ * @throws IllegalArgumentException for invalid event kind
+ */
+ public Collection getRequests (byte kind)
+ {
+ Hashtable requests = (Hashtable) _requests.get (new Byte (kind));
+ if (requests == null)
+ {
+ // Did not get a valid event type
+ throw new IllegalArgumentException ("invalid event kind: " + kind);
+ }
+
+ return requests.values ();
+ }
+}
--- /dev/null
+/* EventRequest.java -- an event request from the debugger
+ Copyright (C) 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., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 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
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package gnu.classpath.jdwp.event;
+
+import gnu.classpath.jdwp.JdwpConstants;
+import gnu.classpath.jdwp.event.filters.*;
+import gnu.classpath.jdwp.exception.JdwpIllegalArgumentException;
+import gnu.classpath.jdwp.id.*;
+
+import java.util.LinkedList;
+import java.util.ListIterator;
+
+/**
+ * A class which represents a request by the debugger for an event
+ * in the VM. <code>EventRequest</code>s usually have event filters
+ * associated with them, which allow the debugger to specify conditions
+ * under which the notification should be sent (specific thread, specific
+ * class, ignore count, etc).
+ *
+ * @author Keith Seitz (keiths@redhat.com)
+ */
+public class EventRequest
+{
+ /*
+ * Event types
+ */
+
+ /**
+ * Single step event
+ */
+ public static final byte EVENT_SINGLE_STEP =
+ JdwpConstants.EventKind.SINGLE_STEP;
+
+ /**
+ * Breakpoint event
+ */
+ public static final byte EVENT_BREAKPOINT =
+ JdwpConstants.EventKind.BREAKPOINT;
+
+ /**
+ * Frame pop event
+ */
+ public static final byte EVENT_FRAME_POP =
+ JdwpConstants.EventKind.FRAME_POP;
+
+ /**
+ * Exception event
+ */
+ public static final byte EVENT_EXCEPTION =
+ JdwpConstants.EventKind.EXCEPTION;
+
+ /**
+ * User-defined event
+ */
+ public static final byte EVENT_USER_DEFINED =
+ JdwpConstants.EventKind.USER_DEFINED;
+
+ /**
+ * Thread start event
+ */
+ public static final byte EVENT_THREAD_START =
+ JdwpConstants.EventKind.THREAD_START;
+
+ /**
+ * Thread end/death event
+ */
+ public static final byte EVENT_THREAD_END =
+ JdwpConstants.EventKind.THREAD_END;
+
+ /**
+ * Class prepare event
+ */
+ public static final byte EVENT_CLASS_PREPARE =
+ JdwpConstants.EventKind.CLASS_PREPARE;
+
+ /**
+ * Class unload event
+ */
+ public static final byte EVENT_CLASS_UNLOAD =
+ JdwpConstants.EventKind.CLASS_UNLOAD;
+
+ /**
+ * Class load event
+ */
+ public static final byte EVENT_CLASS_LOAD =
+ JdwpConstants.EventKind.CLASS_LOAD;
+
+ /**
+ * Field access event
+ */
+ public static final byte EVENT_FIELD_ACCESS =
+ JdwpConstants.EventKind.FIELD_ACCESS;
+
+ /**
+ * Field modify event
+ */
+ public static final byte EVENT_FIELD_MODIFY =
+ JdwpConstants.EventKind.FIELD_MODIFICATION;
+
+ /**
+ * Method entry event
+ */
+ public static final byte EVENT_METHOD_ENTRY =
+ JdwpConstants.EventKind.METHOD_ENTRY;
+
+ /**
+ * Method exit event
+ */
+ public static final byte EVENT_METHOD_EXIT =
+ JdwpConstants.EventKind.METHOD_EXIT;
+
+ /**
+ * Virtual machine initialization/start
+ */
+ public static final byte EVENT_VM_INIT =
+ JdwpConstants.EventKind.VM_INIT;
+
+ /**
+ * Virutal machine death
+ */
+ public static final byte EVENT_VM_DEATH =
+ JdwpConstants.EventKind.VM_DEATH;
+
+
+ /*
+ * Suspend policies
+ */
+
+ /**
+ * Do not suspend any threads
+ */
+ public static final byte SUSPEND_NONE =
+ JdwpConstants.SuspendPolicy.NONE;
+
+ /**
+ * Suspend the thread in which the event occurred
+ */
+ public static final byte SUSPEND_THREAD =
+ JdwpConstants.SuspendPolicy.EVENT_THREAD;
+
+ /**
+ * Suspend all threads
+ */
+ public static final byte SUSPEND_ALL =
+ JdwpConstants.SuspendPolicy.ALL;
+
+ // ID of last EventRequest
+ private static int _last_id = 0;
+ private static Object _idLock = new Object ();
+
+ // A list of filters
+ private LinkedList _filters;
+
+ // The ID of this request
+ private int _id;
+
+ // The suspend policy to enforce when this event occurs
+ private byte _suspendPolicy;
+
+ // Kind of event requested
+ private byte _kind;
+
+ /**
+ * Construct a new <code>EventRequest</code>
+ *
+ * @param kind the kind of event requested
+ * @param suspendPolicy how to suspend threads when event occurs
+ */
+ public EventRequest (byte kind, byte suspendPolicy)
+ {
+ _filters = new LinkedList ();
+ synchronized (_idLock)
+ {
+ _id = ++_last_id;
+ }
+ _kind = kind;
+ _suspendPolicy = suspendPolicy;
+ }
+
+ /**
+ * Construct a new <code>EventRequest</code> with the given ID
+ *
+ * @param id the id of the request to create
+ * @param kind the kind of event requested
+ * @param suspendPolicy how to suspend threads when event occurs
+ */
+ public EventRequest (int id, byte kind, byte suspendPolicy)
+ {
+ _filters = new LinkedList ();
+ _kind = kind;
+ _suspendPolicy = suspendPolicy;
+ }
+
+ /**
+ * Creates a new event filter, adding it to this request
+ *
+ * @param filter the filter to add
+ * @throws JdwpIllegalArgumentException if an invalid or illegal filter
+ * is added to the request
+ */
+ public void addFilter (IEventFilter filter)
+ throws JdwpIllegalArgumentException
+ {
+ // Check validity of filter for this request
+ boolean valid = true;
+
+ Class clazz = filter.getClass ();
+ if (clazz == ClassExcludeFilter.class)
+ {
+ if (_kind == EVENT_THREAD_START
+ || _kind == EVENT_THREAD_END)
+ valid = false;
+ }
+ else if (clazz == ClassMatchFilter.class)
+ {
+ if (_kind == EVENT_THREAD_START
+ || _kind == EVENT_THREAD_END)
+ valid = false;
+ }
+ else if (clazz == ClassOnlyFilter.class)
+ {
+ if (_kind == EVENT_CLASS_UNLOAD
+ || _kind == EVENT_THREAD_START
+ || _kind == EVENT_THREAD_END)
+ valid = false;
+ }
+ else if (clazz == ConditionalFilter.class)
+ {
+ // JDWP 1.4 does not say much about this
+ }
+ else if (clazz == CountFilter.class)
+ {
+ // may be used with any event
+ }
+ else if (clazz == ExceptionOnlyFilter.class)
+ {
+ if (_kind != EVENT_EXCEPTION)
+ valid = false;
+ }
+ else if (clazz == FieldOnlyFilter.class)
+ {
+ if (_kind != EVENT_FIELD_ACCESS
+ && _kind != EVENT_FIELD_MODIFY)
+ valid = false;
+ }
+ else if (clazz == InstanceOnlyFilter.class)
+ {
+ if (_kind == EVENT_CLASS_PREPARE
+ || _kind == EVENT_CLASS_UNLOAD
+ || _kind == EVENT_THREAD_START
+ || _kind == EVENT_THREAD_END)
+ valid = false;
+ }
+ else if (clazz == LocationOnlyFilter.class)
+ {
+ if (_kind != EVENT_BREAKPOINT
+ && _kind != EVENT_FIELD_ACCESS
+ && _kind != EVENT_FIELD_MODIFY
+ && _kind != EVENT_SINGLE_STEP
+ && _kind != EVENT_EXCEPTION)
+ valid = false;
+ }
+ else if (clazz == StepFilter.class)
+ {
+ if (_kind != EVENT_SINGLE_STEP)
+ valid = false;
+ }
+ else if (clazz == ThreadOnlyFilter.class)
+ {
+ if (_kind == EVENT_CLASS_UNLOAD)
+ valid = false;
+ }
+
+ if (!valid)
+ {
+ String msg = ("cannot use " + filter.getClass ().getName ()
+ + " with class unload events");
+ throw new JdwpIllegalArgumentException (msg);
+ }
+
+ // Add filter to list
+ _filters.add (filter);
+ }
+
+ /**
+ * Returns the suspend policy for this request
+ */
+ public byte getSuspendPolicy ()
+ {
+ return _suspendPolicy;
+ }
+
+ /**
+ * Returns the request id of this request
+ */
+ public int getId ()
+ {
+ return _id;
+ }
+
+ /**
+ * Sets the id of the request (used for auto-generated events)
+ */
+ public void setId (int id)
+ {
+ _id = id;
+ }
+
+ /**
+ * Returns the kind of event for this request
+ */
+ public byte getEventKind ()
+ {
+ return _kind;
+ }
+
+ /**
+ * Determines whether the given event matches this request
+ *
+ * @param theEvent the event to compare to
+ */
+ public boolean matches (Event theEvent)
+ {
+ boolean matches = true;
+
+ // Loop through filters; all must match
+ // Note that we must allow EVERY filter to evaluate. This way
+ // things like CountFilter will work.
+ ListIterator iter = _filters.listIterator ();
+ while (iter.hasNext ())
+ {
+ IEventFilter filter = (IEventFilter) iter.next ();
+ if (!filter.matches (theEvent))
+ matches = false;
+ }
+
+ return matches;
+ }
+}
--- /dev/null
+/* ThreadEndEvent.java -- An event specifying that a thread has died
+ Copyright (C) 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., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 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
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package gnu.classpath.jdwp.event;
+
+import gnu.classpath.jdwp.JdwpConstants;
+import gnu.classpath.jdwp.VMIdManager;
+import gnu.classpath.jdwp.id.ThreadId;
+
+import java.io.DataOutputStream;
+import java.io.IOException;
+
+/**
+ * "Notification of a completed thread in the target VM. The notification
+ * is generated by the dying thread before it terminates. Because of this
+ * timing, it is possible for VirtualMachine.allThreads to return this
+ * thread after this event is received.
+ *
+ * <p>Note that this event gives no information about the lifetime of the
+ * thread object. It may or may not be collected soon depending on what
+ * references exist in the target VM." -- JDWP 1.4.2
+ *
+ * @author Keith Seitz (keiths@redhat.com)
+ */
+public class ThreadEndEvent
+ extends Event
+{
+ private Thread _thread;
+
+ /**
+ * Constructs a new <code>ThreadEndEvent</code>
+ *
+ * @param thread the deceased thread
+ */
+ public ThreadEndEvent (Thread thread)
+ {
+ super (JdwpConstants.EventKind.THREAD_END);
+ _thread = thread;
+ }
+
+ /**
+ * Returns a specific filtering parameter for this event.
+ * Valid types are ThreadId.
+ *
+ * @param type the type of parameter desired
+ * @returns the desired parameter or <code>null</code>
+ */
+ public Object getParameter (Class type)
+ {
+ if (type == ThreadId.class)
+ return _thread;
+
+ return null;
+ }
+
+ /**
+ * Writes the event to the given stream
+ *
+ * @param outStream the output stream to write the event to
+ */
+ protected void _writeData (DataOutputStream outStream)
+ throws IOException
+ {
+ VMIdManager idm = VMIdManager.getDefault();
+ ThreadId tid = (ThreadId) idm.getObjectId (_thread);
+ tid.write (outStream);
+ }
+}
+
--- /dev/null
+/* ThreadStartEvent.java -- An event specifying that a new thread
+ has started in the virtual machine
+ Copyright (C) 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., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 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
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package gnu.classpath.jdwp.event;
+
+import gnu.classpath.jdwp.JdwpConstants;
+import gnu.classpath.jdwp.VMIdManager;
+import gnu.classpath.jdwp.id.ThreadId;
+
+import java.io.DataOutputStream;
+import java.io.IOException;
+
+/**
+ * "Notification of a new running thread in the target VM. The new
+ * thread can be the result of a call to {@link java.lang.Thread.start} or
+ * the result of attaching a new thread to the VM though JNI. The
+ * notification is generated by the new thread some time before its
+ * execution starts. Because of this timing, it is possible to receive
+ * other events for the thread before this event is received. (Notably,
+ * Method Entry Events and Method Exit Events might occur during thread
+ * initialization. It is also possible for the VirtualMachine AllThreads
+ * command to return a thread before its thread start event is received.
+ *
+ * <p>Note that this event gives no information about the creation of the
+ * thread object which may have happened much earlier, depending on the
+ * VM being debugged." -- JDWP 1.4.2
+ *
+ * @author Keith Seitz (keiths@redhat.com)
+ */
+public class ThreadStartEvent
+ extends Event
+{
+ private Thread _thread;
+
+ /**
+ * Constructs a new <code>ThreadStartEvent</code>
+ *
+ * @param tid the thread ID in which event occurred
+ */
+ public ThreadStartEvent (Thread thread) {
+ super (JdwpConstants.EventKind.THREAD_END);
+ _thread = thread;
+ }
+
+ /**
+ * Returns a specific filtering parameter for this event.
+ * Valid types are ThreadId.
+ *
+ * @param type the type of parameter desired
+ * @returns the desired parameter or <code>null</code>
+ */
+ public Object getParameter (Class type)
+ {
+ if (type == ThreadId.class)
+ return _thread;
+
+ return null;
+ }
+
+ /**
+ * Writes the event to the given stream
+ *
+ * @param outStream the output stream to write the event to
+ */
+ protected void _writeData (DataOutputStream outStream)
+ throws IOException
+ {
+ VMIdManager idm = VMIdManager.getDefault();
+ ThreadId tid = (ThreadId) idm.getObjectId (_thread);
+ tid.write (outStream);
+ }
+}
--- /dev/null
+/* VmInitEvent.java -- An event specifying that the VM has started
+ Copyright (C) 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., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 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
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package gnu.classpath.jdwp.event;
+
+import gnu.classpath.jdwp.JdwpConstants;
+import gnu.classpath.jdwp.VMIdManager;
+import gnu.classpath.jdwp.id.ThreadId;
+
+import java.io.DataOutputStream;
+import java.io.IOException;
+
+/**
+ * "Notification of initialization of a target VM. This event is
+ * received before the main thread is started and before any application
+ * code has been executed." -- JDWP 1.4.2
+ *
+ * @author Keith Seitz (keiths@redhat.com)
+ */
+public class VmInitEvent
+ extends Event
+{
+ private Thread _initialThread;
+
+ /**
+ * Constructs a <code>VmInitEvent</code> object
+ *
+ * @param thread the initial thread
+ */
+ public VmInitEvent (Thread thread)
+ {
+ super (JdwpConstants.EventKind.VM_INIT);
+ _initialThread = thread;
+ }
+
+ /**
+ * Returns a specific filtering parameter for this event.
+ * This event has no valid types.
+ *
+ * @param type the type of parameter desired
+ * @returns the desired parameter or <code>null</code>
+ */
+ public Object getParameter (Class type)
+ {
+ return null;
+ }
+
+ /**
+ * Writes out event-specific data
+ */
+ protected void _writeData (DataOutputStream outStream)
+ throws IOException
+ {
+ VMIdManager idm = VMIdManager.getDefault();
+ ThreadId tid = (ThreadId) idm.getObjectId (_initialThread);
+ tid.write (outStream);
+ }
+}
--- /dev/null
+/* ClassExcludeFilter.java -- filter on class name (exclusive)
+ Copyright (C) 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., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 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
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package gnu.classpath.jdwp.event.filters;
+
+import gnu.classpath.jdwp.event.Event;
+import gnu.classpath.jdwp.exception.InvalidStringException;
+
+/**
+ * An event filter which excludes events matching a
+ * specified class pattern (exact match or start/end with "*").
+ *
+ * @author Keith Seitz (keiths@redhat.com)
+ */
+public class ClassExcludeFilter
+ extends ClassMatchFilter
+{
+ /**
+ * Constructs a new <code>ClassExcludeFilter</code>
+ *
+ * @param pattern the pattern to use
+ * @throws InvalidStringException if pattern is invalid
+ */
+ public ClassExcludeFilter (String pattern)
+ throws InvalidStringException
+ {
+ super (pattern);
+ }
+
+ /**
+ * Does the given event match the filter?
+ *
+ * @param event the <code>Event</code> to scrutinize
+ */
+ public boolean matches (Event event)
+ {
+ return !super.matches (event);
+ }
+}
--- /dev/null
+/* ClassMatchFilter.java -- filter on class name (inclusive)
+ Copyright (C) 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., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 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
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package gnu.classpath.jdwp.event.filters;
+
+import gnu.classpath.jdwp.event.Event;
+import gnu.classpath.jdwp.exception.InvalidStringException;
+import gnu.classpath.jdwp.exception.InvalidClassException;
+import gnu.classpath.jdwp.id.ReferenceTypeId;
+
+/**
+ * An event filter which includes events matching a
+ * specified class pattern (exact match or start/end with "*").
+ *
+ * @author Keith Seitz (keiths@redhat.com)
+ */
+public class ClassMatchFilter
+ implements IEventFilter
+{
+ // Pattern to match
+ private String _pattern;
+
+ /**
+ * Constructs a new <code>ClassMatchFilter</code>
+ *
+ * @param pattern the pattern to use
+ * @throws InvalidStringException if pattern is invalid
+ */
+ public ClassMatchFilter (String pattern)
+ throws InvalidStringException
+ {
+ int index = pattern.indexOf ('*');
+ if (index != -1 && index != 0 && index != (pattern.length () - 1))
+ {
+ // '*' must be first char or last char
+ throw new InvalidStringException ("pattern may be an exact match or "
+ + "start/end with \"*\"");
+ }
+ _pattern = pattern;
+ }
+
+ /**
+ * Returns the pattern to be matched
+ *
+ * @return the pattern
+ */
+ public String getPattern ()
+ {
+ return _pattern;
+ }
+
+ /**
+ * Does the given event match the filter?
+ *
+ * @param event the <code>Event</code> to scrutinize
+ */
+ public boolean matches (Event event)
+ {
+ Object type = event.getParameter (ReferenceTypeId.class);
+ if (type != null)
+ {
+ Class eventClass = (Class) type;
+ String name = eventClass.getName ();
+
+ if (_pattern.startsWith ("*"))
+ return name.endsWith (_pattern.substring (1));
+ else if (_pattern.endsWith ("*"))
+ {
+ int end = _pattern.length () - 1;
+ return name.startsWith (_pattern.substring (0, end));
+ }
+ else
+ return name.matches (_pattern);
+ }
+
+ return false;
+ }
+}
--- /dev/null
+/* ClassOnlyFilter.java -- filter on specific class
+ Copyright (C) 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., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 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
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package gnu.classpath.jdwp.event.filters;
+
+import gnu.classpath.jdwp.event.Event;
+import gnu.classpath.jdwp.exception.InvalidClassException;
+import gnu.classpath.jdwp.id.ReferenceTypeId;
+
+/**
+ * An event filter which filters out events in uninteresting
+ * classes.
+ *
+ * @author Keith Seitz (keiths@redhat.com)
+ */
+public class ClassOnlyFilter
+ implements IEventFilter
+{
+ // Class ID for which to filter
+ private ReferenceTypeId _id;
+
+ /**
+ * Constructs a new <code>ClassOnlyFilter</code>
+ *
+ * @param refId the reference type id for a class for which events
+ * will be reported
+ * @throws InvalidClassException if the ID is no longer valid
+ */
+ public ClassOnlyFilter (ReferenceTypeId refId)
+ throws InvalidClassException
+ {
+ // validity check
+ refId.getType ();
+ _id = refId;
+ }
+
+ /**
+ * Returns the class to which to restrict events
+ *
+ * @return the class's ID
+ */
+ public ReferenceTypeId getType ()
+ {
+ return _id;
+ }
+
+ /**
+ * Does the given event match the filter?
+ *
+ * @param event the <code>Event</code> to scrutinize
+ */
+ public boolean matches (Event event)
+ {
+ Object type = event.getParameter (ReferenceTypeId.class);
+ if (type != null)
+ {
+ try
+ {
+ Class clazz = _id.getType ();
+ Class eventClass = (Class) type;
+ if (clazz.isAssignableFrom (eventClass))
+ return true;
+ }
+ catch (InvalidClassException ice)
+ {
+ // class is no longer valid
+ return false;
+ }
+ }
+
+ return false;
+ }
+}
--- /dev/null
+/* ConditionalFilter.java -- conditional expression filter
+ Copyright (C) 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., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 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
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package gnu.classpath.jdwp.event.filters;
+
+import gnu.classpath.jdwp.event.Event;
+import gnu.classpath.jdwp.exception.NotImplementedException;
+
+/**
+ * An event filter which allows expression conditionals.
+ * Note that in JDWP 1.4, this class is marked "for the
+ * future".
+ *
+ * @author Keith Seitz (keiths@redhat.com)
+ */
+public class ConditionalFilter
+ implements IEventFilter
+{
+ // private ConditionalId _exprId;
+
+ /**
+ * Constructs a new <code>ConditionalFilter</code> with the
+ * given conditional.
+ *
+ * <p><b>NOTE:</b> This filter is marked "for the future",
+ * i.e, there is no way to actually use this yet.
+ *
+ * @param cond the conditional expression
+ * @throws NotImplementedException if used
+ */
+ public ConditionalFilter (Object conditional)
+ throws NotImplementedException
+ {
+ throw new NotImplementedException ("conditional filters");
+ }
+
+ /**
+ * Does the given event match the filter?
+ *
+ * @param event the <code>Event</code> to scrutinize
+ */
+ public boolean matches (Event event)
+ {
+ return false;
+ }
+}
--- /dev/null
+/* CountFilter.java -- a step filter
+ Copyright (C) 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., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 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
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package gnu.classpath.jdwp.event.filters;
+
+import gnu.classpath.jdwp.event.Event;
+import gnu.classpath.jdwp.exception.InvalidCountException;
+
+/**
+ * An ignore count filter.
+ *
+ * @author Keith Seitz (keiths@redhat.com)
+ */
+public class CountFilter
+ implements IEventFilter
+{
+ // the count
+ private int _count;
+
+ /**
+ * Constructs a new <code>CountFilter</code> with the given count.
+ *
+ * @param count the number of times the event will be ignored
+ * @throws InvalidCountException if count is invalid (< 1)
+ */
+ public CountFilter (int count)
+ throws InvalidCountException
+ {
+ // Check for valid count
+ if (count < 1)
+ throw new InvalidCountException (count);
+
+ _count = count;
+ }
+
+ /**
+ * Returns the ignore count
+ *
+ * @return the number of times the event should be ignored
+ */
+ public int getCount ()
+ {
+ return _count;
+ }
+
+ /**
+ * Does the given event match the filter?
+ *
+ * @param event the <code>Event</code> to scrutinize
+ */
+ public boolean matches (Event event)
+ {
+ // This filter only relies on its count
+ if (--_count == 0)
+ return true;
+
+ return false;
+ }
+}
--- /dev/null
+/* ExceptionOnlyFilter.java --
+ Copyright (C) 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., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 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
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package gnu.classpath.jdwp.event.filters;
+
+import gnu.classpath.jdwp.event.Event;
+import gnu.classpath.jdwp.exception.InvalidClassException;
+import gnu.classpath.jdwp.id.ReferenceTypeId;
+
+/**
+ * Restricts reported exceptions by their class and whether they are caught
+ * or uncaught.
+ *
+ * This modifier can be used with exception event kinds only.
+ *
+ * @author Keith Seitz (keiths@redhat.com)
+ */
+public class ExceptionOnlyFilter
+ implements IEventFilter
+{
+ private ReferenceTypeId _refId;
+ private boolean _caught;
+ private boolean _uncaught;
+
+ /**
+ * Constructs a new <code>ExceptionOnlyFilter</code>
+ *
+ * @param refid
+ * @param caught
+ * @param uncaught
+ * @throws InvalidClassException if refid is invalid
+ */
+ public ExceptionOnlyFilter (ReferenceTypeId refId, boolean caught,
+ boolean uncaught)
+ throws InvalidClassException
+ {
+ if (refId == null || refId.getReference().get () == null)
+ throw new InvalidClassException (refId.getId ());
+
+ _refId = refId;
+ _caught = caught;
+ _uncaught = uncaught;
+ }
+
+ /**
+ * Returns the exception class to report (<code>null</code> for all)
+ *
+ * @return the class's ID
+ */
+ public ReferenceTypeId getType ()
+ {
+ return _refId;
+ }
+
+ /**
+ * Report caught exceptions?
+ *
+ * @return whether to report caught exceptions
+ */
+ public boolean forCaught ()
+ {
+ return _caught;
+ }
+
+ /**
+ * Report uncaught exceptions?
+ *
+ * @return whether to report uncaught exceptions
+ */
+ public boolean forUncaught ()
+ {
+ return _uncaught;
+ }
+
+ /**
+ * Does the given event match the filter?
+ *
+ * @param event the <code>Event</code> to scrutinize
+ */
+ public boolean matches (Event event)
+ {
+ // FIXME
+ throw new RuntimeException ("ExceptionOnlyFilter.matches not implemented");
+ }
+}
--- /dev/null
+/* FieldOnlyFilter.java -- filter on field
+ Copyright (C) 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., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 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
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package gnu.classpath.jdwp.event.filters;
+
+import gnu.classpath.jdwp.event.Event;
+import gnu.classpath.jdwp.exception.InvalidClassException;
+import gnu.classpath.jdwp.exception.InvalidFieldException;
+import gnu.classpath.jdwp.id.ReferenceTypeId;
+
+/**
+ * Restricts reported events to those that occur for a given field.
+ *
+ * This modifier can be used with field access and field modification event
+ * kinds only.
+ *
+ * @author Keith Seitz (keiths@redhat.com)
+ */
+public class FieldOnlyFilter
+ implements IEventFilter
+{
+ private ReferenceTypeId _refId;
+ private ReferenceTypeId _fieldId;
+
+ /**
+ * Constructs a new <code>FieldOnlyFilter</code>.
+ *
+ * @param refId class for field
+ * @param fid field
+ * @throws InvalidClassException if class is invalid
+ * @throws InvalidFieldExcpetion if field is invalid
+ */
+ public FieldOnlyFilter (ReferenceTypeId refId, /*Field*/ReferenceTypeId fid)
+ throws InvalidClassException, InvalidFieldException
+ {
+ if (refId == null || refId.getReference().get () == null)
+ throw new InvalidClassException (refId.getId ());
+
+ if (fid == null)
+ throw new InvalidFieldException (fid.getId ());
+
+ _refId = refId;
+ _fieldId = fid;
+ }
+
+ /**
+ * Returns the class in which the field is declared
+ *
+ * @return the class's id
+ */
+ public ReferenceTypeId getType ()
+ {
+ return _refId;
+ }
+
+ /**
+ * Returns the field for which to restrict events
+ *
+ * @return the field's id
+ */
+ public ReferenceTypeId getField ()
+ {
+ return _fieldId;
+ }
+
+ /**
+ * Does the given event match the filter?
+ *
+ * @param event the <code>Event</code> to scrutinize
+ */
+ public boolean matches (Event event)
+ {
+ // FIXME
+ throw new RuntimeException ("FieldOnlyFilter.matches not implemented");
+ }
+}
--- /dev/null
+/* IEventFilter.java -- an interface for event filters
+ Copyright (C) 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., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 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
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package gnu.classpath.jdwp.event.filters;
+
+import gnu.classpath.jdwp.event.Event;
+
+/**
+ * An interface for event filters. The debugger registers an event
+ * filter for a given event when it is interested in receiving
+ * notifications about that event from the VM.
+ *
+ * <p>Filters are attached to {@link gnu.classpath.jdwp.event.EventRequest}s
+ * in order to allow the debugger to specify that an event should be sent
+ * only when the filters for the event request all match.
+ *
+ * <p>No filters means "send all notifications".
+ *
+ * @author Keith Seitz (keiths@redhat.com)
+ */
+public interface IEventFilter
+{
+ /**
+ * Does the given event match the filter?
+ *
+ * @param event the <code>Event</code> to scrutinize
+ */
+ public boolean matches (Event event);
+}
--- /dev/null
+/* InstanceOnlyFilter.java -- filter on instance
+ Copyright (C) 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., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 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
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package gnu.classpath.jdwp.event.filters;
+
+import gnu.classpath.jdwp.event.Event;
+import gnu.classpath.jdwp.exception.InvalidObjectException;
+import gnu.classpath.jdwp.id.ObjectId;
+
+/**
+ * Restricts reported events to those whose active 'this' object is the
+ * given object. Match value is the null object for static methods.
+ *
+ * This modifier can be used with any event kind except class prepare,
+ * class unload, thread start, and thread end. Introduced in JDWP version 1.4.
+ *
+ * @author Keith Seitz (keiths@redhat.com)
+ */
+public class InstanceOnlyFilter
+ implements IEventFilter
+{
+ private ObjectId _instance;
+
+ /**
+ * Constructs a new <code>InstanceOnlyFilter</code>.
+ *
+ * @param oid the object to which to restrict events (may be null)
+ * @throws InvalidObjectException if Object is invalid
+ */
+ public InstanceOnlyFilter (ObjectId oid)
+ throws InvalidObjectException
+ {
+ if (oid != null && oid.getReference().get () == null)
+ throw new InvalidObjectException (oid.getId ());
+
+ _instance = oid;
+ }
+
+ /**
+ * Returns the instance to which to restrict events
+ *
+ * @return the object's ID
+ */
+ public ObjectId getInstance ()
+ {
+ return _instance;
+ }
+
+ /**
+ * Does the given event match the filter?
+ *
+ * @param event the <code>Event</code> to scrutinize
+ */
+ public boolean matches (Event event)
+ {
+ Object eventInstance = event.getParameter (ObjectId.class);
+ if (eventInstance != null)
+ {
+ Object myInstance = _instance.getReference().get ();
+ return ((myInstance != null) && (myInstance == eventInstance));
+ }
+
+ return false;
+ }
+}
--- /dev/null
+/* LocationOnlyFilter.java -- filter on location
+ Copyright (C) 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., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 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
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package gnu.classpath.jdwp.event.filters;
+
+import gnu.classpath.jdwp.event.Event;
+import gnu.classpath.jdwp.exception.InvalidLocationException;
+import gnu.classpath.jdwp.util.Location;
+
+/**
+ * Restricts reported events to those that occur at the given location.
+ *
+ * May be used with breakpoint, field access, field modification, step,
+ * and exception event kinds.
+ *
+ * @author Keith Seitz (keiths@redhat.com)
+ */
+public class LocationOnlyFilter
+ implements IEventFilter
+{
+ private Location _location;
+
+ /**
+ * Constructs a new <code>LocationOnlyFilter</code>.
+ *
+ * @param loc the location for which to report events
+ * @throws InvalidLocationException if location is invalid
+ */
+ public LocationOnlyFilter (Location loc)
+ throws InvalidLocationException
+ {
+ _location = loc;
+ }
+
+ /**
+ * Returns the location at which to restrict events
+ *
+ * @return the location
+ */
+ public Location getLocation ()
+ {
+ return _location;
+ }
+
+ /**
+ * Does the given event match the filter?
+ *
+ * @param event the <code>Event</code> to scrutinize
+ */
+ public boolean matches (Event event)
+ {
+ // FIXME
+ throw new RuntimeException ("LocationOnlyFilter.matches not implemented");
+ }
+}
--- /dev/null
+/* StepFilter.java -- a step filter
+ Copyright (C) 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., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 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
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package gnu.classpath.jdwp.event.filters;
+
+import gnu.classpath.jdwp.event.Event;
+import gnu.classpath.jdwp.exception.InvalidThreadException;
+import gnu.classpath.jdwp.id.ThreadId;
+
+/**
+ * An event filter which restricts reported step events to those which
+ * satisfy depth and size constraints. This modifier can only be used with
+ * step event kinds.
+ *
+ * @author Keith Seitz (keiths@redhat.com)
+ */
+public class StepFilter
+ implements IEventFilter
+{
+ private ThreadId _tid;
+ private int _size;
+ private int _depth;
+
+ /**
+ * Constructs a new <code>StepFilter</code> with the given count.
+ *
+ * @param count the number of times the event will be ignored
+ * @throws InvalidThreadException if thread is invalid
+ */
+ public StepFilter (ThreadId tid, int size, int depth)
+ throws InvalidThreadException
+ {
+ if (tid == null | tid.getReference().get () == null)
+ throw new InvalidThreadException (tid.getId ());
+
+ _tid = tid;
+ _size = size;
+ _depth = depth;
+ }
+
+ /**
+ * Returns the thread in which to step
+ *
+ * @return the thread's ID
+ */
+ public ThreadId getThread ()
+ {
+ return _tid;
+ }
+
+ /**
+ * Returns the size of each step (insn, line)
+ *
+ * @return the step size
+ * @see JdwpConstants.StepSize
+ */
+ public int getSize ()
+ {
+ return _size;
+ }
+
+ /**
+ * Returns the relative call stack limit (into, over, out)
+ *
+ * @return how to step
+ * @see JdwpConstants.StepDepth
+ */
+ public int getDepth ()
+ {
+ return _depth;
+ }
+
+ /**
+ * Does the given event match the filter?
+ *
+ * @param event the <code>Event</code> to scrutinize
+ */
+ public boolean matches (Event event)
+ {
+ // FIXME
+ throw new RuntimeException ("StepFilter.matches not implemented");
+ }
+}
--- /dev/null
+/* ThreadOnlyFilter.java -- a thread filter
+ Copyright (C) 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., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 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
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package gnu.classpath.jdwp.event.filters;
+
+import gnu.classpath.jdwp.Jdwp;
+import gnu.classpath.jdwp.event.Event;
+import gnu.classpath.jdwp.exception.InvalidThreadException;
+import gnu.classpath.jdwp.id.ThreadId;
+
+/**
+ * An event filter which allows only events within a specific
+ * thread
+ *
+ * @author Keith Seitz (keiths@redhat.com)
+ */
+public class ThreadOnlyFilter
+ implements IEventFilter
+{
+ // the thread
+ private ThreadId _tid;
+
+ /**
+ * Constructs a new <code>ThreadOnlyFilter</code> for the given
+ * thread id
+ *
+ * @param tid ID of the thread on which to filter
+ * @throws InvalidThreadException if the thread is not valid
+ */
+ public ThreadOnlyFilter (ThreadId tid)
+ throws InvalidThreadException
+ {
+ if (tid == null | tid.getReference().get () == null)
+ throw new InvalidThreadException (tid.getId ());
+
+ _tid = tid;
+ }
+
+ /**
+ * Returns the thread in which to restrict events
+ *
+ * @return the thread's ID
+ */
+ public ThreadId getThread ()
+ {
+ return _tid;
+ }
+
+ /**
+ * Does the given event match the filter?
+ *
+ * @param event the <code>Event</code> to scrutinize
+ */
+ public boolean matches (Event event)
+ {
+ Object thread = event.getParameter (ThreadId.class);
+ if (thread != null)
+ {
+ Thread eventThread = (Thread) thread;
+ Thread myThread = (Thread) _tid.getReference().get ();
+ return (eventThread == myThread);
+ }
+
+ return false;
+ }
+}
--- /dev/null
+/* InvalidClassLoaderException.java -- an invalid class loader exception
+ Copyright (C) 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., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 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
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package gnu.classpath.jdwp.exception;
+
+import gnu.classpath.jdwp.JdwpConstants;
+
+/**
+ * An exception thrown when the debugger uses an invalid class loader
+ *
+ * @author Keith Seitz (keiths@redhat.com)
+ */
+public class InvalidClassLoaderException
+ extends JdwpException
+{
+ public InvalidClassLoaderException (long id)
+ {
+ super (JdwpConstants.Error.INVALID_CLASS_LOADER,
+ "invalid class loader (" + id + ")");
+ }
+
+ public InvalidClassLoaderException (Throwable t)
+ {
+ super (JdwpConstants.Error.INVALID_CLASS_LOADER, t);
+ }
+}
--- /dev/null
+/* InvalidFieldException.java -- an invalid field id exception
+ Copyright (C) 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., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 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
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package gnu.classpath.jdwp.exception;
+
+import gnu.classpath.jdwp.JdwpConstants;
+
+/**
+ * An exception thrown when an invalid field id is used by the
+ * debugger
+ *
+ * @author Keith Seitz (keiths@redhat.com)
+ */
+public class InvalidFieldException
+ extends JdwpException
+{
+ public InvalidFieldException (long id)
+ {
+ super (JdwpConstants.Error.INVALID_FIELDID,
+ "invalid field id (" + id + ")");
+ }
+
+ public InvalidFieldException (Throwable t)
+ {
+ super (JdwpConstants.Error.INVALID_FIELDID, t);
+ }
+}
--- /dev/null
+/* InvalidLocationException.java -- an invalid location exception
+ Copyright (C) 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., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 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
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package gnu.classpath.jdwp.exception;
+
+import gnu.classpath.jdwp.JdwpConstants;
+
+/**
+ * An exception thrown when the debugger specifies an invalid location
+ *
+ * @author Keith Seitz (keiths@redhat.com)
+ */
+public class InvalidLocationException
+ extends JdwpException
+{
+ public InvalidLocationException (/*something*/)
+ {
+ super (JdwpConstants.Error.INVALID_LOCATION,
+ "invalid location (" + "something" + ")");
+ }
+
+ public InvalidLocationException (Throwable t)
+ {
+ super (JdwpConstants.Error.INVALID_LOCATION, t);
+ }
+}
--- /dev/null
+/* InvalidMethodException.java -- an invalid method id exception
+ Copyright (C) 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., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 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
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package gnu.classpath.jdwp.exception;
+
+import gnu.classpath.jdwp.JdwpConstants;
+
+/**
+ * An exception thrown when an invalid method id is used
+ * by the debugger
+ *
+ * @author Keith Seitz (keiths@redhat.com)
+ */
+public class InvalidMethodException
+ extends JdwpException
+{
+ public InvalidMethodException (long id)
+ {
+ super (JdwpConstants.Error.INVALID_METHODID,
+ "invalid method id (" + id + ")");
+ }
+
+ public InvalidMethodException (Throwable t)
+ {
+ super (JdwpConstants.Error.INVALID_METHODID, t);
+ }
+}
--- /dev/null
+/* JdwpIllegalArgumentException.java -- an illegal argument exception
+ Copyright (C) 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., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 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
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package gnu.classpath.jdwp.exception;
+
+import gnu.classpath.jdwp.JdwpConstants;
+
+/**
+ * An illegal argument exception for JDWP.
+ *
+ * @author Keith Seitz (keiths@redhat.com)
+ */
+public class JdwpIllegalArgumentException
+ extends JdwpException
+{
+ /**
+ * Constructs a new <code>JdwpIllegalArgumentException</code> with
+ * the given error code and given cause
+ *
+ * @param msg a message explaining the illegal argument
+ */
+ public JdwpIllegalArgumentException (String msg)
+ {
+ super (JdwpConstants.Error.ILLEGAL_ARGUMENT, msg);
+ }
+}
--- /dev/null
+/* ArrayReferenceCommandSet.java -- class to implement the Array
+ Reference Command Set
+ Copyright (C) 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., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 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
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package gnu.classpath.jdwp.processor;
+
+import gnu.classpath.jdwp.JdwpConstants;
+import gnu.classpath.jdwp.exception.InvalidObjectException;
+import gnu.classpath.jdwp.exception.JdwpException;
+import gnu.classpath.jdwp.exception.JdwpInternalErrorException;
+import gnu.classpath.jdwp.exception.NotImplementedException;
+import gnu.classpath.jdwp.id.ObjectId;
+import gnu.classpath.jdwp.util.Value;
+
+import java.io.DataOutputStream;
+import java.io.IOException;
+import java.lang.reflect.Array;
+import java.nio.ByteBuffer;
+
+/**
+ * A class representing the ArrayReference Command Set.
+ *
+ * @author Aaron Luchko <aluchko@redhat.com>
+ */
+public class ArrayReferenceCommandSet
+ extends CommandSet
+{
+ public boolean runCommand(ByteBuffer bb, DataOutputStream os, byte command)
+ throws JdwpException
+ {
+ try
+ {
+ switch (command)
+ {
+ case JdwpConstants.CommandSet.ArrayReference.LENGTH:
+ executeLength(bb, os);
+ break;
+ case JdwpConstants.CommandSet.ArrayReference.GET_VALUES:
+ executeGetValues(bb, os);
+ break;
+ case JdwpConstants.CommandSet.ArrayReference.SET_VALUES:
+ executeSetValues(bb, os);
+ break;
+ default:
+ throw new NotImplementedException("Command " + command +
+ " not found in Array Reference Command Set.");
+ }
+ }
+ catch (IOException ex)
+ {
+ // The DataOutputStream we're using isn't talking to a socket at all
+ // So if we throw an IOException we're in serious trouble
+ throw new JdwpInternalErrorException(ex);
+ }
+ return true;
+ }
+
+ private void executeLength(ByteBuffer bb, DataOutputStream os)
+ throws InvalidObjectException, IOException
+ {
+ ObjectId oid = idMan.readObjectId(bb);
+ Object array = oid.getObject();
+ os.writeInt(Array.getLength(array));
+ }
+
+ private void executeGetValues(ByteBuffer bb, DataOutputStream os)
+ throws JdwpException, IOException
+ {
+ ObjectId oid = idMan.readObjectId(bb);
+ Object array = oid.getObject();
+ int first = bb.getInt();
+ int length = bb.getInt();
+
+ // We need to write out the byte signifying the type of array first
+ Class clazz = array.getClass().getComponentType();
+
+ // Uugh, this is a little ugly but it's the only time we deal with
+ // arrayregions
+ if (clazz == byte.class)
+ os.writeByte(JdwpConstants.Tag.BYTE);
+ else if (clazz == char.class)
+ os.writeByte(JdwpConstants.Tag.CHAR);
+ else if (clazz == float.class)
+ os.writeByte(JdwpConstants.Tag.FLOAT);
+ else if (clazz == double.class)
+ os.writeByte(JdwpConstants.Tag.DOUBLE);
+ else if (clazz == int.class)
+ os.writeByte(JdwpConstants.Tag.BYTE);
+ else if (clazz == long.class)
+ os.writeByte(JdwpConstants.Tag.LONG);
+ else if (clazz == short.class)
+ os.writeByte(JdwpConstants.Tag.SHORT);
+ else if (clazz == void.class)
+ os.writeByte(JdwpConstants.Tag.VOID);
+ else if (clazz == boolean.class)
+ os.writeByte(JdwpConstants.Tag.BOOLEAN);
+ else if (clazz.isArray())
+ os.writeByte(JdwpConstants.Tag.ARRAY);
+ else if (String.class.isAssignableFrom(clazz))
+ os.writeByte(JdwpConstants.Tag.STRING);
+ else if (Thread.class.isAssignableFrom(clazz))
+ os.writeByte(JdwpConstants.Tag.THREAD);
+ else if (ThreadGroup.class.isAssignableFrom(clazz))
+ os.writeByte(JdwpConstants.Tag.THREAD_GROUP);
+ else if (ClassLoader.class.isAssignableFrom(clazz))
+ os.writeByte(JdwpConstants.Tag.CLASS_LOADER);
+ else if (Class.class.isAssignableFrom(clazz))
+ os.writeByte(JdwpConstants.Tag.CLASS_OBJECT);
+ else
+ os.writeByte(JdwpConstants.Tag.OBJECT);
+
+ // Write all the values, primitives should be untagged and Objects must be
+ // tagged
+ for (int i = first; i < first + length; i++)
+ {
+ Object value = Array.get(array, i);
+ if (clazz.isPrimitive())
+ Value.writeUntaggedValue(os, value);
+ else
+ Value.writeTaggedValue(os, value);
+ }
+ }
+
+ private void executeSetValues(ByteBuffer bb, DataOutputStream os)
+ throws IOException, JdwpException
+ {
+ ObjectId oid = idMan.readObjectId(bb);
+ Object array = oid.getObject();
+ int first = bb.getInt();
+ int length = bb.getInt();
+ Class type = array.getClass().getComponentType();
+ for (int i = first; i < first + length; i++)
+ {
+ Object value = Value.getUntaggedObj(bb, type);
+ Array.set(array, i, value);
+ }
+ }
+}
--- /dev/null
+/* ArrayTypeCommandSet.java -- class to implement the ArrayType Command Set
+ Copyright (C) 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., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package gnu.classpath.jdwp.processor;
+
+import gnu.classpath.jdwp.JdwpConstants;
+import gnu.classpath.jdwp.exception.JdwpException;
+import gnu.classpath.jdwp.exception.JdwpInternalErrorException;
+import gnu.classpath.jdwp.exception.NotImplementedException;
+import gnu.classpath.jdwp.id.ObjectId;
+import gnu.classpath.jdwp.id.ReferenceTypeId;
+
+import java.io.DataOutputStream;
+import java.io.IOException;
+import java.lang.reflect.Array;
+import java.nio.ByteBuffer;
+
+/**
+ * A class representing the ArrayType Command Set.
+ *
+ * @author Aaron Luchko <aluchko@redhat.com>
+ */
+public class ArrayTypeCommandSet
+ extends CommandSet
+{
+ public boolean runCommand(ByteBuffer bb, DataOutputStream os, byte command)
+ throws JdwpException
+ {
+
+ // Although there's only a single command to choose from we still use
+ // a switch to maintain consistency with the rest of the CommandSets
+ try
+ {
+ switch (command)
+ {
+ case JdwpConstants.CommandSet.ArrayType.NEW_INSTANCE:
+ executeNewInstance(bb, os);
+ break;
+ default:
+ throw new NotImplementedException("Command " + command +
+ " not found in ArrayType Command Set.");
+ }
+ }
+ catch (IOException ex)
+ {
+ // The DataOutputStream we're using isn't talking to a socket at all
+ // So if we throw an IOException we're in serious trouble
+ throw new JdwpInternalErrorException(ex);
+ }
+ return true;
+ }
+
+ public void executeNewInstance(ByteBuffer bb, DataOutputStream os)
+ throws JdwpException, IOException
+ {
+ ReferenceTypeId refId = idMan.readReferenceTypeId(bb);
+ Class arrayType = refId.getType();
+ Class componentType = arrayType.getComponentType();
+
+ int length = bb.getInt();
+ Object newArray = Array.newInstance(componentType, length);
+ ObjectId oid = idMan.getObjectId(newArray);
+
+ // Since this array isn't referenced anywhere we'll disable garbage
+ // collection on it so it's still around when the debugger gets back to it.
+ oid.disableCollection();
+ oid.writeTagged(os);
+ }
+}
--- /dev/null
+/* ClassLoaderReferenceCommandSet.java -- class to implement the
+ ClassLoaderReference Command Set
+ Copyright (C) 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., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 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
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package gnu.classpath.jdwp.processor;
+
+import gnu.classpath.jdwp.JdwpConstants;
+import gnu.classpath.jdwp.VMVirtualMachine;
+import gnu.classpath.jdwp.exception.JdwpException;
+import gnu.classpath.jdwp.exception.JdwpInternalErrorException;
+import gnu.classpath.jdwp.exception.NotImplementedException;
+import gnu.classpath.jdwp.id.ObjectId;
+import gnu.classpath.jdwp.id.ReferenceTypeId;
+
+import java.io.DataOutputStream;
+import java.io.IOException;
+import java.nio.ByteBuffer;
+import java.util.ArrayList;
+import java.util.Iterator;
+
+/**
+ * A class representing the ClassLoaderReference Command Set.
+ *
+ * @author Aaron Luchko <aluchko@redhat.com>
+ */
+public class ClassLoaderReferenceCommandSet
+ extends CommandSet
+{
+ public boolean runCommand(ByteBuffer bb, DataOutputStream os, byte command)
+ throws JdwpException
+ {
+
+ // Although there's only a single command to choose from we still use
+ // a switch to maintain consistency with the rest of the CommandSets
+ try
+ {
+ switch (command)
+ {
+ case JdwpConstants.CommandSet.ClassLoaderReference.VISIBLE_CLASSES:
+ executeVisibleClasses(bb, os);
+ break;
+ default:
+ throw new NotImplementedException("Command " + command +
+ " not found in ClassLoaderReference Command Set.");
+ }
+ }
+ catch (IOException ex)
+ {
+ // The DataOutputStream we're using isn't talking to a socket at all
+ // So if we throw an IOException we're in serious trouble
+ throw new JdwpInternalErrorException(ex);
+ }
+ return true;
+ }
+
+ public void executeVisibleClasses(ByteBuffer bb, DataOutputStream os)
+ throws JdwpException, IOException
+ {
+ ObjectId oId = idMan.readObjectId(bb);
+ ClassLoader cl = (ClassLoader) oId.getObject();
+ ArrayList loadRequests = VMVirtualMachine.getLoadRequests(cl);
+ os.writeInt(loadRequests.size());
+ for (Iterator iter = loadRequests.iterator(); iter.hasNext();)
+ {
+ Class clazz = (Class)iter.next();
+ ReferenceTypeId refId = idMan.getReferenceTypeId(clazz);
+ refId.writeTagged(os);
+ }
+ }
+
+}
--- /dev/null
+/* ClassObjectReferenceCommandSet.java -- class to implement the
+ ClassObjectReference Command Set
+ Copyright (C) 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., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package gnu.classpath.jdwp.processor;
+
+import gnu.classpath.jdwp.JdwpConstants;
+import gnu.classpath.jdwp.exception.JdwpException;
+import gnu.classpath.jdwp.exception.JdwpInternalErrorException;
+import gnu.classpath.jdwp.exception.NotImplementedException;
+import gnu.classpath.jdwp.id.ObjectId;
+import gnu.classpath.jdwp.id.ReferenceTypeId;
+
+import java.io.DataOutputStream;
+import java.io.IOException;
+import java.nio.ByteBuffer;
+
+/**
+ * A class representing the ClassObjectReference Command Set.
+ *
+ * @author Aaron Luchko <aluchko@redhat.com>
+ */
+public class ClassObjectReferenceCommandSet
+ extends CommandSet
+{
+ public boolean runCommand(ByteBuffer bb, DataOutputStream os, byte command)
+ throws JdwpException
+ {
+ try
+ {
+ switch (command)
+ {
+ case JdwpConstants.CommandSet.ClassObjectReference.REFLECTED_TYPE:
+ executeReflectedType(bb, os);
+ break;
+ default:
+ throw new NotImplementedException("Command " + command +
+ " not found in ClassObject Reference Command Set.");
+ }
+ }
+ catch (IOException ex)
+ {
+ // The DataOutputStream we're using isn't talking to a socket at all
+ // So if we throw an IOException we're in serious trouble
+ throw new JdwpInternalErrorException(ex);
+ }
+ return true;
+ }
+
+ public void executeReflectedType(ByteBuffer bb, DataOutputStream os)
+ throws JdwpException, IOException
+ {
+ ObjectId oid = idMan.readObjectId(bb);
+ Class clazz = (Class) oid.getObject();
+
+ // The difference between a ClassObjectId and a ReferenceTypeId is one is
+ // stored as an ObjectId and the other as a ReferenceTypeId.
+ ReferenceTypeId refId = idMan.getReferenceTypeId(clazz);
+ refId.writeTagged(os);
+ }
+}
--- /dev/null
+/* ClassTypeCommandSet.java -- class to implement the ClassType
+ Command Set
+ Copyright (C) 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., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 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
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package gnu.classpath.jdwp.processor;
+
+import gnu.classpath.jdwp.JdwpConstants;
+import gnu.classpath.jdwp.VMVirtualMachine;
+import gnu.classpath.jdwp.exception.InvalidFieldException;
+import gnu.classpath.jdwp.exception.JdwpException;
+import gnu.classpath.jdwp.exception.JdwpInternalErrorException;
+import gnu.classpath.jdwp.exception.NotImplementedException;
+import gnu.classpath.jdwp.id.ObjectId;
+import gnu.classpath.jdwp.id.ReferenceTypeId;
+import gnu.classpath.jdwp.util.MethodResult;
+import gnu.classpath.jdwp.util.Value;
+
+import java.io.DataOutputStream;
+import java.io.IOException;
+import java.lang.reflect.Field;
+import java.lang.reflect.Method;
+import java.nio.ByteBuffer;
+
+/**
+ * A class representing the ClassType Command Set.
+ *
+ * @author Aaron Luchko <aluchko@redhat.com>
+ */
+public class ClassTypeCommandSet
+ extends CommandSet
+{
+ public boolean runCommand(ByteBuffer bb, DataOutputStream os, byte command)
+ throws JdwpException
+ {
+ try
+ {
+ switch (command)
+ {
+ case JdwpConstants.CommandSet.ClassType.SUPERCLASS:
+ executeSuperclass(bb, os);
+ break;
+ case JdwpConstants.CommandSet.ClassType.SET_VALUES:
+ executeSetValues(bb, os);
+ break;
+ case JdwpConstants.CommandSet.ClassType.INVOKE_METHOD:
+ executeInvokeMethod(bb, os);
+ break;
+ case JdwpConstants.CommandSet.ClassType.NEW_INSTANCE:
+ executeNewInstance(bb, os);
+ break;
+ default:
+ throw new NotImplementedException("Command " + command +
+ " not found in ClassType Command Set.");
+ }
+ }
+ catch (IOException ex)
+ {
+ // The DataOutputStream we're using isn't talking to a socket at all
+ // So if we throw an IOException we're in serious trouble
+ throw new JdwpInternalErrorException(ex);
+ }
+ return true;
+ }
+
+ private void executeSuperclass(ByteBuffer bb, DataOutputStream os)
+ throws JdwpException, IOException
+ {
+ ReferenceTypeId refId = idMan.readReferenceTypeId(bb);
+ Class clazz = refId.getType();
+ Class superClazz = clazz.getSuperclass();
+
+ ReferenceTypeId clazzId = idMan.getReferenceTypeId(superClazz);
+ clazzId.write(os);
+ }
+
+ private void executeSetValues(ByteBuffer bb, DataOutputStream os)
+ throws JdwpException, IOException
+ {
+ ReferenceTypeId refId = idMan.readReferenceTypeId(bb);
+
+ // We don't actually seem to need this...
+ Class clazz = refId.getType();
+
+ int numValues = bb.getInt();
+
+ for (int i = 0; i < numValues; i++)
+ {
+ ObjectId fieldId = idMan.readObjectId(bb);
+ Field field = (Field) (fieldId.getObject());
+ Object value = Value.getUntaggedObj(bb, field.getType());
+ try
+ {
+ field.setAccessible(true); // Might be a private field
+ field.set(null, value);
+ }
+ catch (IllegalArgumentException ex)
+ {
+ throw new InvalidFieldException(ex);
+ }
+ catch (IllegalAccessException ex)
+ { // Since we set it as accessible this really shouldn't happen
+ throw new JdwpInternalErrorException(ex);
+ }
+ }
+ }
+
+ private void executeInvokeMethod(ByteBuffer bb, DataOutputStream os)
+ throws JdwpException, IOException
+ {
+ MethodResult mr = invokeMethod(bb);
+
+ Object value = mr.getReturnedValue();
+ Exception exception = mr.getThrownException();
+ ObjectId eId = idMan.getObjectId(exception);
+
+ Value.writeTaggedValue(os, value);
+ eId.writeTagged(os);
+ }
+
+ private void executeNewInstance(ByteBuffer bb, DataOutputStream os)
+ throws JdwpException, IOException
+ {
+ MethodResult mr = invokeMethod(bb);
+
+ Object obj = mr.getReturnedValue();
+ ObjectId oId = idMan.getObjectId(obj);
+ Exception exception = mr.getThrownException();
+ ObjectId eId = idMan.getObjectId(exception);
+
+ oId.writeTagged(os);
+ eId.writeTagged(os);
+ }
+
+ /**
+ * Execute the static method and return the resulting MethodResult.
+ */
+ private MethodResult invokeMethod(ByteBuffer bb) throws JdwpException,
+ IOException
+ {
+ ReferenceTypeId refId = idMan.readReferenceTypeId(bb);
+ Class clazz = refId.getType();
+
+ ObjectId tId = idMan.readObjectId(bb);
+ Thread thread = (Thread) tId.getObject();
+
+ ObjectId mId = idMan.readObjectId(bb);
+ Method method = (Method) mId.getObject();
+
+ int args = bb.getInt();
+ Object[] values = new Object[args];
+
+ for (int i = 0; i < args; i++)
+ {
+ values[i] = Value.getObj(bb);
+ }
+
+ int invokeOpts = bb.getInt();
+ boolean suspend = ((invokeOpts
+ & JdwpConstants.InvokeOptions.INVOKE_SINGLE_THREADED)
+ != 0);
+ try
+ {
+ if (suspend)
+ VMVirtualMachine.suspendAllThreads ();
+
+ MethodResult mr = VMVirtualMachine.executeMethod(null, thread,
+ clazz, method,
+ values, false);
+ if (suspend)
+ VMVirtualMachine.resumeAllThreads ();
+
+ return mr;
+ }
+ catch (Exception ex)
+ {
+ if (suspend)
+ VMVirtualMachine.resumeAllThreads ();
+
+ throw new JdwpInternalErrorException(ex);
+ }
+ }
+}
--- /dev/null
+/* EventRequestCommandSet.java -- class to implement the EventRequest Command
+ Set
+ Copyright (C) 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., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package gnu.classpath.jdwp.processor;
+
+import gnu.classpath.jdwp.JdwpConstants;
+import gnu.classpath.jdwp.event.EventManager;
+import gnu.classpath.jdwp.event.EventRequest;
+import gnu.classpath.jdwp.event.filters.ClassExcludeFilter;
+import gnu.classpath.jdwp.event.filters.ClassMatchFilter;
+import gnu.classpath.jdwp.event.filters.ClassOnlyFilter;
+import gnu.classpath.jdwp.event.filters.ConditionalFilter;
+import gnu.classpath.jdwp.event.filters.CountFilter;
+import gnu.classpath.jdwp.event.filters.ExceptionOnlyFilter;
+import gnu.classpath.jdwp.event.filters.FieldOnlyFilter;
+import gnu.classpath.jdwp.event.filters.IEventFilter;
+import gnu.classpath.jdwp.event.filters.InstanceOnlyFilter;
+import gnu.classpath.jdwp.event.filters.LocationOnlyFilter;
+import gnu.classpath.jdwp.event.filters.StepFilter;
+import gnu.classpath.jdwp.event.filters.ThreadOnlyFilter;
+import gnu.classpath.jdwp.exception.JdwpException;
+import gnu.classpath.jdwp.exception.JdwpInternalErrorException;
+import gnu.classpath.jdwp.exception.NotImplementedException;
+import gnu.classpath.jdwp.id.ObjectId;
+import gnu.classpath.jdwp.id.ReferenceTypeId;
+import gnu.classpath.jdwp.id.ThreadId;
+import gnu.classpath.jdwp.util.JdwpString;
+import gnu.classpath.jdwp.util.Location;
+
+import java.io.DataOutputStream;
+import java.io.IOException;
+import java.nio.ByteBuffer;
+
+/**
+ * A class representing the EventRequest Command Set.
+ *
+ * @author Aaron Luchko <aluchko@redhat.com>
+ */
+public class EventRequestCommandSet
+ extends CommandSet
+{
+ public boolean runCommand(ByteBuffer bb, DataOutputStream os, byte command)
+ throws JdwpException
+ {
+ try
+ {
+ switch (command)
+ {
+ case JdwpConstants.CommandSet.EventRequest.SET:
+ executeSet(bb, os);
+ break;
+ case JdwpConstants.CommandSet.EventRequest.CLEAR:
+ executeClear(bb, os);
+ break;
+ case JdwpConstants.CommandSet.EventRequest.CLEAR_ALL_BREAKPOINTS:
+ executeClearAllBreakpoints(bb, os);
+ break;
+ default:
+ throw new NotImplementedException("Command " + command +
+ " not found in EventRequest Reference Command Set.");
+ }
+ }
+ catch (IOException ex)
+ {
+ // The DataOutputStream we're using isn't talking to a socket at all
+ // So if we throw an IOException we're in serious trouble
+ throw new JdwpInternalErrorException(ex);
+ }
+ return true;
+ }
+
+ private void executeSet(ByteBuffer bb, DataOutputStream os)
+ throws JdwpException, IOException
+ {
+ byte eventKind = bb.get();
+ byte suspendPolicy = bb.get();
+ int modifiers = bb.getInt();
+
+ EventRequest eventReq = new EventRequest(eventKind, suspendPolicy);
+ IEventFilter filter = null;
+ ReferenceTypeId refId;
+ for (int i = 0; i < modifiers; i++)
+ {
+ byte modKind = bb.get();
+ switch (modKind)
+ {
+ case JdwpConstants.ModKind.COUNT:
+ filter = new CountFilter(bb.getInt());
+ break;
+ case JdwpConstants.ModKind.CONDITIONAL:
+ filter = new ConditionalFilter(idMan.readObjectId(bb));
+ break;
+ case JdwpConstants.ModKind.THREAD_ONLY:
+ filter = new ThreadOnlyFilter((ThreadId) idMan.readObjectId(bb));
+ break;
+ case JdwpConstants.ModKind.CLASS_ONLY:
+ filter = new ClassOnlyFilter(idMan.readReferenceTypeId(bb));
+ break;
+ case JdwpConstants.ModKind.CLASS_MATCH:
+ filter = new ClassMatchFilter(JdwpString.readString(bb));
+ break;
+ case JdwpConstants.ModKind.CLASS_EXCLUDE:
+ filter = new ClassExcludeFilter(JdwpString.readString(bb));
+ break;
+ case JdwpConstants.ModKind.LOCATION_ONLY:
+ filter = new LocationOnlyFilter(new Location(bb));
+ break;
+ case JdwpConstants.ModKind.EXCEPTION_ONLY:
+ long id = bb.getLong();
+ if (id == 0)
+ refId = null;
+ else
+ refId = idMan.readReferenceTypeId(bb);
+ boolean caught = (bb.get() == 0) ? false : true;
+ boolean unCaught = (bb.get() == 0) ? false : true;
+ filter = new ExceptionOnlyFilter(refId, caught, unCaught);
+ break;
+ case JdwpConstants.ModKind.FIELD_ONLY:
+ refId = idMan.readReferenceTypeId(bb);
+ ReferenceTypeId fieldId = idMan.readReferenceTypeId(bb);
+ filter = new FieldOnlyFilter(refId, fieldId);
+ break;
+ case JdwpConstants.ModKind.STEP:
+ ThreadId tid = (ThreadId) idMan.readObjectId(bb);
+ int size = bb.getInt();
+ int depth = bb.getInt();
+ filter = new StepFilter(tid, size, depth);
+ break;
+ case JdwpConstants.ModKind.INSTANCE_ONLY:
+ ObjectId oid = idMan.readObjectId(bb);
+ filter = new InstanceOnlyFilter(oid);
+ break;
+ default:
+ throw new NotImplementedException("modKind " + modKind
+ + " is not implemented.");
+ }
+ eventReq.addFilter(filter);
+ }
+
+ EventManager.getDefault().requestEvent(eventReq);
+ os.writeInt(eventReq.getId());
+
+ }
+
+ private void executeClear(ByteBuffer bb, DataOutputStream os)
+ throws JdwpException, IOException
+ {
+ byte eventKind = bb.get();
+ int requestId = bb.getInt();
+ EventManager.getDefault().deleteRequest(eventKind, requestId);
+ }
+
+ private void executeClearAllBreakpoints(ByteBuffer bb, DataOutputStream os)
+ throws JdwpException, IOException
+ {
+ byte eventKind = bb.get ();
+ EventManager.getDefault().clearRequests (eventKind);
+ }
+
+}
--- /dev/null
+/* MethodCommandSet.java -- class to implement the Method Command Set
+ Copyright (C) 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., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package gnu.classpath.jdwp.processor;
+
+import gnu.classpath.jdwp.JdwpConstants;
+import gnu.classpath.jdwp.VMVirtualMachine;
+import gnu.classpath.jdwp.exception.JdwpException;
+import gnu.classpath.jdwp.exception.JdwpInternalErrorException;
+import gnu.classpath.jdwp.exception.NotImplementedException;
+import gnu.classpath.jdwp.id.ObjectId;
+import gnu.classpath.jdwp.id.ReferenceTypeId;
+import gnu.classpath.jdwp.util.LineTable;
+import gnu.classpath.jdwp.util.VariableTable;
+
+import java.io.DataOutputStream;
+import java.io.IOException;
+import java.lang.reflect.Method;
+import java.nio.ByteBuffer;
+
+/**
+ * A class representing the Method Command Set.
+ *
+ * @author Aaron Luchko <aluchko@redhat.com>
+ */
+public class MethodCommandSet
+ extends CommandSet
+{
+ public boolean runCommand(ByteBuffer bb, DataOutputStream os, byte command)
+ throws JdwpException
+ {
+ try
+ {
+ switch (command)
+ {
+ case JdwpConstants.CommandSet.Method.LINE_TABLE:
+ executeLineTable(bb, os);
+ break;
+ case JdwpConstants.CommandSet.Method.VARIABLE_TABLE:
+ executeVariableTable(bb, os);
+ break;
+ case JdwpConstants.CommandSet.Method.BYTE_CODES:
+ executeByteCodes(bb, os);
+ break;
+ case JdwpConstants.CommandSet.Method.IS_OBSOLETE:
+ executeIsObsolete(bb, os);
+ break;
+ case JdwpConstants.CommandSet.Method.VARIABLE_TABLE_WITH_GENERIC:
+ executeVariableTableWithGeneric(bb, os);
+ break;
+ default:
+ throw new NotImplementedException(
+ "Command " + command + " not found in Method Command Set.");
+ }
+ }
+ catch (IOException ex)
+ {
+ // The DataOutputStream we're using isn't talking to a socket at all
+ // So if we throw an IOException we're in serious trouble
+ throw new JdwpInternalErrorException(ex);
+ }
+ return true;
+ }
+
+ private void executeLineTable(ByteBuffer bb, DataOutputStream os)
+ throws JdwpException, IOException
+ {
+ ReferenceTypeId refId = idMan.readReferenceTypeId(bb);
+ Class clazz = refId.getType();
+
+ ObjectId oid = idMan.readObjectId(bb);
+ Method method = (Method) oid.getObject();
+
+ LineTable lt = VMVirtualMachine.getLineTable(clazz, method);
+ lt.write(os);
+ }
+
+ private void executeVariableTable(ByteBuffer bb, DataOutputStream os)
+ throws JdwpException, IOException
+ {
+ ReferenceTypeId refId = idMan.readReferenceTypeId(bb);
+ Class clazz = refId.getType();
+
+ ObjectId oid = idMan.readObjectId(bb);
+ Method method = (Method) oid.getObject();
+
+ VariableTable vt = VMVirtualMachine.getVarTable(clazz, method);
+ vt.write(os);
+ }
+
+ private void executeByteCodes(ByteBuffer bb, DataOutputStream os)
+ throws JdwpException
+ {
+ // This command is optional, determined by VirtualMachines CapabilitiesNew
+ // so we'll leave it till later to implement
+ throw new NotImplementedException("Command ByteCodes not implemented.");
+ }
+
+ private void executeIsObsolete(ByteBuffer bb, DataOutputStream os)
+ throws IOException
+ {
+ // The debugger is really asking if this method has been redefined using
+ // VirtualMachineCommandSet.RedefineClasses. Since we don't implement that
+ // command the answer to this will always be false.
+ os.writeBoolean(false);
+ }
+
+ private void executeVariableTableWithGeneric(ByteBuffer bb,
+ DataOutputStream os)
+ throws JdwpException
+ {
+ // We don't have generics yet
+ throw new NotImplementedException(
+ "Command SourceDebugExtension not implemented.");
+ }
+
+}
--- /dev/null
+/* StackFrameCommandSet.java -- class to implement the StackFrame Command Set
+ Copyright (C) 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., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 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
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package gnu.classpath.jdwp.processor;
+
+import gnu.classpath.jdwp.JdwpConstants;
+import gnu.classpath.jdwp.VMFrame;
+import gnu.classpath.jdwp.VMVirtualMachine;
+import gnu.classpath.jdwp.exception.JdwpException;
+import gnu.classpath.jdwp.exception.JdwpInternalErrorException;
+import gnu.classpath.jdwp.exception.NotImplementedException;
+import gnu.classpath.jdwp.id.ObjectId;
+import gnu.classpath.jdwp.util.Value;
+
+import java.io.DataOutputStream;
+import java.io.IOException;
+import java.nio.ByteBuffer;
+
+/**
+ * A class representing the StackFrame Command Set.
+ *
+ * @author Aaron Luchko <aluchko@redhat.com>
+ */
+public class StackFrameCommandSet
+ extends CommandSet
+{
+ public boolean runCommand(ByteBuffer bb, DataOutputStream os, byte command)
+ throws JdwpException
+ {
+ boolean keepRunning = true;
+ try
+ {
+ switch (command)
+ {
+ case JdwpConstants.CommandSet.StackFrame.GET_VALUES:
+ executeGetValues(bb, os);
+ break;
+ case JdwpConstants.CommandSet.StackFrame.SET_VALUES:
+ executeSetValues(bb, os);
+ break;
+ case JdwpConstants.CommandSet.StackFrame.THIS_OBJECT:
+ executeThisObject(bb, os);
+ break;
+ case JdwpConstants.CommandSet.StackFrame.POP_FRAMES:
+ executePopFrames(bb, os);
+ break;
+ default:
+ throw new NotImplementedException("Command " + command +
+ " not found in Stack Frame Command Set.");
+ }
+ }
+ catch (IOException ex)
+ {
+ // The DataOutputStream we're using isn't talking to a socket at all
+ // So if we throw an IOException we're in serious trouble
+ throw new JdwpInternalErrorException(ex);
+ }
+ return true;
+ }
+
+ private void executeGetValues(ByteBuffer bb, DataOutputStream os)
+ throws JdwpException, IOException
+ {
+ ObjectId tId = idMan.readObjectId(bb);
+ Thread thread = (Thread) tId.getObject();
+
+ // Although Frames look like other ids they are not. First they are not
+ // ObjectIds since they don't exist in the users code. Storing them as an
+ // ObjectId would mean they could be garbage collected since no one else
+ // has a reference to them. Furthermore they are not ReferenceTypeIds since
+ // these are held permanently and we want these to be held only as long as
+ // the Thread is suspended.
+ VMFrame frame = VMVirtualMachine.getFrame(thread, bb);
+ int slots = bb.getInt();
+ os.writeInt(slots); // Looks pointless but this is the protocol
+ for (int i = 0; i < slots; i++)
+ {
+ int slot = bb.getInt();
+ byte sig = bb.get();
+ Object val = frame.getValue(slot);
+ Value.writeTaggedValue(os, val);
+ }
+ }
+
+ private void executeSetValues(ByteBuffer bb, DataOutputStream os)
+ throws JdwpException, IOException
+ {
+ ObjectId tId = idMan.readObjectId(bb);
+ Thread thread = (Thread) tId.getObject();
+
+ VMFrame frame = VMVirtualMachine.getFrame(thread, bb);
+
+ int slots = bb.getInt();
+ for (int i = 0; i < slots; i++)
+ {
+ int slot = bb.getInt();
+ Object value = Value.getObj(bb);
+ frame.setValue(slot, value);
+ }
+ }
+
+ private void executeThisObject(ByteBuffer bb, DataOutputStream os)
+ throws JdwpException, IOException
+ {
+ ObjectId tId = idMan.readObjectId(bb);
+ Thread thread = (Thread) tId.getObject();
+
+ VMFrame frame = VMVirtualMachine.getFrame(thread, bb);
+
+ Object thisObject = frame.getObject();
+ Value.writeTaggedValue(os, thisObject);
+ }
+
+ private void executePopFrames(ByteBuffer bb, DataOutputStream os)
+ throws JdwpException
+ {
+ // This command is optional, determined by VirtualMachines CapabilitiesNew
+ // so we'll leave it till later to implement
+ throw new NotImplementedException("Command PopFrames not implemented.");
+ }
+}
--- /dev/null
+/* ThreadGroupReferenceCommandSet.java -- class to implement the
+ ThreadGroupReference Command Set
+ Copyright (C) 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., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package gnu.classpath.jdwp.processor;
+
+import gnu.classpath.jdwp.JdwpConstants;
+import gnu.classpath.jdwp.exception.JdwpException;
+import gnu.classpath.jdwp.exception.JdwpInternalErrorException;
+import gnu.classpath.jdwp.exception.NotImplementedException;
+import gnu.classpath.jdwp.id.ObjectId;
+import gnu.classpath.jdwp.util.JdwpString;
+
+import java.io.DataOutputStream;
+import java.io.IOException;
+import java.nio.ByteBuffer;
+
+/**
+ * A class representing the ThreadGroupReference Command Set.
+ *
+ * @author Aaron Luchko <aluchko@redhat.com>
+ */
+public class ThreadGroupReferenceCommandSet
+ extends CommandSet
+{
+ public boolean runCommand(ByteBuffer bb, DataOutputStream os, byte command)
+ throws JdwpException
+ {
+ try
+ {
+ switch (command)
+ {
+ case JdwpConstants.CommandSet.ThreadGroupReference.NAME:
+ executeName(bb, os);
+ break;
+ case JdwpConstants.CommandSet.ThreadGroupReference.PARENT:
+ executeParent(bb, os);
+ break;
+ case JdwpConstants.CommandSet.ThreadGroupReference.CHILDREN:
+ executeChildren(bb, os);
+ break;
+ default:
+ throw new NotImplementedException("Command " + command +
+ " not found in ThreadGroupReference Command Set.");
+ }
+ }
+ catch (IOException ex)
+ {
+ // The DataOutputStream we're using isn't talking to a socket at all
+ // So if we throw an IOException we're in serious trouble
+ throw new JdwpInternalErrorException(ex);
+ }
+ return true;
+ }
+
+ private void executeName(ByteBuffer bb, DataOutputStream os)
+ throws JdwpException, IOException
+ {
+ ObjectId oid = idMan.readObjectId(bb);
+ ThreadGroup group = (ThreadGroup) oid.getObject();
+ JdwpString.writeString(os, group.getName());
+ }
+
+ private void executeParent(ByteBuffer bb, DataOutputStream os)
+ throws JdwpException, IOException
+ {
+ ObjectId oid = idMan.readObjectId(bb);
+ ThreadGroup group = (ThreadGroup) oid.getObject();
+ ThreadGroup parent = group.getParent();
+ ObjectId parentId = idMan.getObjectId(parent);
+ parentId.write(os);
+ }
+
+ private void executeChildren(ByteBuffer bb, DataOutputStream os)
+ throws JdwpException, IOException
+ {
+ ObjectId oid = idMan.readObjectId(bb);
+ ThreadGroup group = (ThreadGroup) oid.getObject();
+
+ ThreadGroup jdwpGroup = Thread.currentThread().getThreadGroup();
+ int numThreads = group.activeCount();
+ Thread allThreads[] = new Thread[numThreads];
+
+ group.enumerate(allThreads, false);
+
+ // We need to loop through for the true count since some threads may have
+ // been destroyed since we got activeCount so those spots in the array will
+ // be null. As well we must ignore any threads that belong to jdwp
+ numThreads = 0;
+ for (int i = 0; i < allThreads.length; i++)
+ {
+ Thread thread = allThreads[i];
+ if (thread == null)
+ break; // No threads after this point
+ if (!thread.getThreadGroup().equals(jdwpGroup))
+ numThreads++;
+ }
+
+ os.writeInt(numThreads);
+
+ for (int i = 0; i < allThreads.length; i++)
+ {
+ Thread thread = allThreads[i];
+ if (thread == null)
+ break; // No threads after this point
+ if (!thread.getThreadGroup().equals(jdwpGroup))
+ idMan.getObjectId(thread).write(os);
+ }
+
+ int numGroups = group.activeCount();
+ ThreadGroup allGroups[] = new ThreadGroup[numGroups];
+
+ group.enumerate(allGroups, false);
+
+ // We need to loop through for the true count since some ThreadGroups may
+ // have been destroyed since we got activeCount so those spots in the array
+ // will be null. As well we must ignore any threads that belong to jdwp.
+ numGroups = 0;
+ for (int i = 0; i < allGroups.length; i++)
+ {
+ ThreadGroup tgroup = allGroups[i];
+ if (tgroup == null)
+ break; // No ThreadGroups after this point
+ if (!tgroup.equals(jdwpGroup))
+ numGroups++;
+ }
+
+ os.writeInt(numGroups);
+
+ for (int i = 0; i < allGroups.length; i++)
+ {
+ ThreadGroup tgroup = allGroups[i];
+ if (tgroup == null)
+ break; // No ThreadGroups after this point
+ if (!tgroup.equals(jdwpGroup))
+ idMan.getObjectId(tgroup).write(os);
+ }
+ }
+}
--- /dev/null
+/* ThreadReferenceCommandSet.java -- class to implement the ThreadReference
+ Command Set Copyright (C) 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., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 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
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package gnu.classpath.jdwp.processor;
+
+import gnu.classpath.jdwp.JdwpConstants;
+import gnu.classpath.jdwp.VMFrame;
+import gnu.classpath.jdwp.VMVirtualMachine;
+import gnu.classpath.jdwp.exception.InvalidObjectException;
+import gnu.classpath.jdwp.exception.JdwpException;
+import gnu.classpath.jdwp.exception.JdwpInternalErrorException;
+import gnu.classpath.jdwp.exception.NotImplementedException;
+import gnu.classpath.jdwp.id.ObjectId;
+import gnu.classpath.jdwp.id.ThreadId;
+import gnu.classpath.jdwp.util.JdwpString;
+import gnu.classpath.jdwp.util.Location;
+
+import java.io.DataOutputStream;
+import java.io.IOException;
+import java.nio.ByteBuffer;
+import java.util.ArrayList;
+
+/**
+ * A class representing the ThreadReference Command Set.
+ *
+ * @author Aaron Luchko <aluchko@redhat.com>
+ */
+public class ThreadReferenceCommandSet
+ extends CommandSet
+{
+ public boolean runCommand(ByteBuffer bb, DataOutputStream os, byte command)
+ throws JdwpException
+ {
+ try
+ {
+ switch (command)
+ {
+ case JdwpConstants.CommandSet.ThreadReference.NAME:
+ executeName(bb, os);
+ break;
+ case JdwpConstants.CommandSet.ThreadReference.SUSPEND:
+ executeSuspend(bb, os);
+ break;
+ case JdwpConstants.CommandSet.ThreadReference.RESUME:
+ executeResume(bb, os);
+ break;
+ case JdwpConstants.CommandSet.ThreadReference.STATUS:
+ executeStatus(bb, os);
+ break;
+ case JdwpConstants.CommandSet.ThreadReference.THREAD_GROUP:
+ executeThreadGroup(bb, os);
+ break;
+ case JdwpConstants.CommandSet.ThreadReference.FRAMES:
+ executeFrames(bb, os);
+ break;
+ case JdwpConstants.CommandSet.ThreadReference.FRAME_COUNT:
+ executeFrameCount(bb, os);
+ break;
+ case JdwpConstants.CommandSet.ThreadReference.OWNED_MONITORS:
+ executeOwnedMonitors(bb, os);
+ break;
+ case JdwpConstants.CommandSet.ThreadReference.CURRENT_CONTENDED_MONITOR:
+ executeCurrentContendedMonitor(bb, os);
+ break;
+ case JdwpConstants.CommandSet.ThreadReference.STOP:
+ executeStop(bb, os);
+ break;
+ case JdwpConstants.CommandSet.ThreadReference.INTERRUPT:
+ executeInterrupt(bb, os);
+ break;
+ case JdwpConstants.CommandSet.ThreadReference.SUSPEND_COUNT:
+ executeSuspendCount(bb, os);
+ break;
+ default:
+ throw new NotImplementedException("Command " + command +
+ " not found in Thread Reference Command Set.");
+ }
+ }
+ catch (IOException ex)
+ {
+ // The DataOutputStream we're using isn't talking to a socket at all
+ // So if we throw an IOException we're in serious trouble
+ throw new JdwpInternalErrorException(ex);
+ }
+ return true;
+ }
+
+ private void executeName(ByteBuffer bb, DataOutputStream os)
+ throws JdwpException, IOException
+ {
+ ThreadId tid = (ThreadId) idMan.readObjectId(bb);
+ Thread thread = tid.getThread();
+ JdwpString.writeString(os, thread.getName());
+ }
+
+ private void executeSuspend(ByteBuffer bb, DataOutputStream os)
+ throws JdwpException, IOException
+ {
+ ThreadId tid = (ThreadId) idMan.readObjectId(bb);
+ Thread thread = tid.getThread();
+ VMVirtualMachine.suspendThread(thread);
+ }
+
+ private void executeResume(ByteBuffer bb, DataOutputStream os)
+ throws JdwpException, IOException
+ {
+ ThreadId tid = (ThreadId) idMan.readObjectId(bb);
+ Thread thread = tid.getThread();
+ VMVirtualMachine.suspendThread(thread);
+ }
+
+ private void executeStatus(ByteBuffer bb, DataOutputStream os)
+ throws JdwpException, IOException
+ {
+ ThreadId tid = (ThreadId) idMan.readObjectId(bb);
+ Thread thread = tid.getThread();
+ int threadStatus = VMVirtualMachine.getThreadStatus(thread);
+ // There's only one possible SuspendStatus...
+ int suspendStatus = JdwpConstants.SuspendStatus.SUSPENDED;
+
+ os.writeInt(threadStatus);
+ os.writeInt(suspendStatus);
+ }
+
+ private void executeThreadGroup(ByteBuffer bb, DataOutputStream os)
+ throws JdwpException, IOException
+ {
+ ThreadId tid = (ThreadId) idMan.readObjectId(bb);
+ Thread thread = tid.getThread();
+ ThreadGroup group = thread.getThreadGroup();
+ ObjectId groupId = idMan.getObjectId(group);
+ groupId.write(os);
+ }
+
+ private void executeFrames(ByteBuffer bb, DataOutputStream os)
+ throws JdwpException, IOException
+ {
+ ThreadId tid = (ThreadId) idMan.readObjectId(bb);
+ Thread thread = tid.getThread();
+ int startFrame = bb.getInt();
+ int length = bb.getInt();
+
+ ArrayList frames = VMVirtualMachine.getFrames(thread, startFrame, length);
+ os.writeInt(frames.size());
+ for (int i = 0; i < frames.size(); i++)
+ {
+ VMFrame frame = (VMFrame) frames.get(i);
+ os.writeLong(frame.getId());
+ Location loc = frame.getLocation();
+ loc.write(os);
+ }
+ }
+
+ private void executeFrameCount(ByteBuffer bb, DataOutputStream os)
+ throws JdwpException, IOException
+ {
+ ThreadId tid = (ThreadId) idMan.readObjectId(bb);
+ Thread thread = tid.getThread();
+
+ int frameCount = VMVirtualMachine.getFrameCount(thread);
+ os.writeInt(frameCount);
+ }
+
+ private void executeOwnedMonitors(ByteBuffer bb, DataOutputStream os)
+ throws JdwpException
+ {
+ // This command is optional, determined by VirtualMachines CapabilitiesNew
+ // so we'll leave it till later to implement
+ throw new NotImplementedException(
+ "Command OwnedMonitors not implemented.");
+ }
+
+ private void executeCurrentContendedMonitor(ByteBuffer bb,
+ DataOutputStream os)
+ throws JdwpException
+ {
+ // This command is optional, determined by VirtualMachines CapabilitiesNew
+ // so we'll leave it till later to implement
+ throw new NotImplementedException(
+ "Command CurrentContentedMonitors not implemented.");
+ }
+
+ private void executeStop(ByteBuffer bb, DataOutputStream os)
+ throws JdwpException, IOException
+ {
+ ThreadId tid = (ThreadId) idMan.readObjectId(bb);
+ Thread thread = tid.getThread();
+ ObjectId exception = idMan.readObjectId(bb);
+ Throwable throwable = (Throwable) exception.getObject();
+ thread.stop (throwable);
+ }
+
+ private void executeInterrupt(ByteBuffer bb, DataOutputStream os)
+ throws JdwpException, IOException
+ {
+ ThreadId tid = (ThreadId) idMan.readObjectId(bb);
+ Thread thread = tid.getThread();
+ thread.interrupt();
+ }
+
+ private void executeSuspendCount(ByteBuffer bb, DataOutputStream os)
+ throws JdwpException, IOException
+ {
+ ThreadId tid = (ThreadId) idMan.readObjectId(bb);
+ Thread thread = tid.getThread();
+ int suspendCount = VMVirtualMachine.getSuspendCount(thread);
+ os.writeInt(suspendCount);
+ }
+}
--- /dev/null
+/* LineTable.java -- A class representing a Line Table for a method
+ Copyright (C) 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., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 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
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package gnu.classpath.jdwp.util;
+
+import java.io.DataOutputStream;
+import java.io.IOException;
+
+/**
+ * A class representing a Line Table for a method.
+ *
+ * @author Aaron Luchko <aluchko@redhat.com>
+ */
+public class LineTable
+{
+
+ private final long start;
+ private final long end;
+ private final int[] lineNum;
+ private final long[] lineCI;
+ private final int lines;
+
+ /**
+ * Construct a line table with the given parameters.
+ *
+ * @param start lowest code index for method, -1 if native
+ * @param end highest code index for method, -1 if native
+ * @param lines number of entries in line table
+ * @param lineCI code indexes for entries in line tables (of length lines)
+ * @param lineNum line numbers for in line tables (of length lines)
+ */
+ public LineTable(long start, long end, int lines, long lineCI[],
+ int lineNum[])
+ {
+ this.start = start;
+ this.end = end;
+ this.lines = lines;
+ this.lineCI = lineCI;
+ this.lineNum = lineNum;
+ }
+
+ /**
+ * Writes this line table to the given DataOutputStream.
+ *
+ * @param os the stream to write it to
+ * @throws IOException
+ */
+ public void write(DataOutputStream os)
+ throws IOException
+ {
+ os.writeLong(start);
+ os.writeLong(end);
+ os.writeInt(lines);
+ for (int i = 0; i < lines; i++)
+ {
+ os.writeLong(lineCI[i]);
+ os.writeInt(lineNum[i]);
+ }
+ }
+}
--- /dev/null
+/* Location.java -- class to read/write JDWP locations
+ Copyright (C) 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., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package gnu.classpath.jdwp.util;
+
+import gnu.classpath.jdwp.VMIdManager;
+import gnu.classpath.jdwp.exception.JdwpException;
+import gnu.classpath.jdwp.id.ClassReferenceTypeId;
+import gnu.classpath.jdwp.id.ObjectId;
+
+import java.io.DataOutputStream;
+import java.io.IOException;
+import java.lang.reflect.Method;
+import java.nio.ByteBuffer;
+
+/**
+ * A class to read/write JDWP locations.
+ *
+ * @author Aaron Luchko <aluchko@redhat.com>
+ */
+public class Location
+{
+
+ private ClassReferenceTypeId crti;
+
+ private int index;
+
+ private byte tag;
+
+ private ObjectId mid;
+
+ /**
+ * Create a location with the given parameters.
+ *
+ * @param tag the type of construct the location is in
+ * @param clazz the class the location is in
+ * @param meth the Method
+ * @param index location in the method
+ * @throws JdwpException
+ */
+ public Location(byte tag, Class clazz, Method meth, int index)
+ throws JdwpException
+ {
+ this.tag = tag;
+ this.crti =
+ (ClassReferenceTypeId) VMIdManager.getDefault().getReferenceTypeId(clazz);
+ this.mid = VMIdManager.getDefault().getObjectId(meth);
+ this.index = index;
+ }
+
+ /**
+ * Read a location from the given bytebuffer, consists of a TAG (byte),
+ * followed by a ReferenceTypeId, a MethodId and an index (int).
+ *
+ * @param bb this holds the location
+ * @throws IOException
+ * @throws JdwpException
+ */
+ public Location(ByteBuffer bb) throws IOException, JdwpException
+ {
+ this.tag = bb.get();
+ this.crti =
+ (ClassReferenceTypeId) VMIdManager.getDefault().readReferenceTypeId(bb);
+ this.mid = VMIdManager.getDefault().readObjectId(bb);
+ this.index = bb.getInt();
+ }
+
+ /**
+ * Write the given location to an output stream.
+ *
+ * @param os stream to write to
+ * @throws IOException
+ */
+ public void write(DataOutputStream os) throws IOException
+ {
+ os.writeByte(tag);
+ crti.write(os);
+ mid.write(os);
+ os.writeInt(index);
+ }
+}
--- /dev/null
+/* MethodResult.java -- class to wrap around values returned from a Method call
+ in the VM
+ Copyright (C) 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., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 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
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package gnu.classpath.jdwp.util;
+
+/**
+ * A class to wrap around values returned from a Method call in the VM.
+ *
+ * @author Aaron Luchko <aluchko@redhat.com>
+ */
+public class MethodResult
+{
+ // The Object returned by the executing method
+ private Object returnedValue;
+
+ // Any Exception that was thrown by the executing method
+ private Exception thrownException;
+
+ public Object getReturnedValue()
+ {
+ return returnedValue;
+ }
+
+ public void setReturnedValue(Object returnedValue)
+ {
+ this.returnedValue = returnedValue;
+ }
+
+ public Exception getThrownException()
+ {
+ return thrownException;
+ }
+
+ public void setThrownException(Exception thrownException)
+ {
+ this.thrownException = thrownException;
+ }
+
+}
--- /dev/null
+/* Value.java -- class to read/write JDWP tagged and untagged values
+ Copyright (C) 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., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package gnu.classpath.jdwp.util;
+
+import gnu.classpath.jdwp.JdwpConstants;
+import gnu.classpath.jdwp.VMIdManager;
+import gnu.classpath.jdwp.exception.InvalidFieldException;
+import gnu.classpath.jdwp.exception.JdwpException;
+import gnu.classpath.jdwp.exception.JdwpInternalErrorException;
+import gnu.classpath.jdwp.exception.NotImplementedException;
+import gnu.classpath.jdwp.id.ObjectId;
+
+import java.io.DataOutputStream;
+import java.io.IOException;
+import java.nio.ByteBuffer;
+
+/**
+ * A class to read/write JDWP tagged and untagged values.
+ *
+ * @author Aaron Luchko <aluchko@redhat.com>
+ */
+public class Value
+{
+ /**
+ * Will write the given object as an untagged value to the DataOutputStream.
+ *
+ * @param os write the value here
+ * @param obj the Object to write
+ * @throws IOException
+ * @throws InvalidFieldException
+ */
+ public static void writeUntaggedValue(DataOutputStream os, Object obj)
+ throws JdwpException, IOException
+ {
+ writeValue(os, obj, false);
+ }
+
+ /**
+ * Will write the given object as a tagged value to the DataOutputStream.
+ *
+ * @param os write the value here
+ * @param obj the Object to write
+ * @throws IOException
+ * @throws InvalidFieldException
+ */
+ public static void writeTaggedValue(DataOutputStream os, Object obj)
+ throws JdwpException, IOException
+ {
+ writeValue(os, obj, true);
+ }
+
+ /**
+ * Will write the given object as either a value or an untagged value to the
+ * DataOutputStream.
+ *
+ * @param os write the value here
+ * @param obj the Object to write
+ * @param tagged true if the value is tagged, false otherwise
+ * @throws IOException
+ * @throws InvalidFieldException
+ */
+ private static void writeValue(DataOutputStream os, Object obj,
+ boolean tagged)
+ throws IOException, JdwpException
+ {
+ Class clazz = obj.getClass();
+ if (clazz.isPrimitive())
+ {
+ if (clazz == byte.class)
+ {
+ if (tagged)
+ os.writeByte(JdwpConstants.Tag.BYTE);
+ os.writeByte(((Byte) obj).byteValue());
+ }
+ else if (clazz == char.class)
+ {
+ if (tagged)
+ os.writeByte(JdwpConstants.Tag.CHAR);
+ os.writeChar(((Character) obj).charValue());
+ }
+ else if (clazz == float.class)
+ {
+ if (tagged)
+ os.writeByte(JdwpConstants.Tag.FLOAT);
+ os.writeFloat(((Float) obj).floatValue());
+ }
+ else if (clazz == double.class)
+ {
+ if (tagged)
+ os.writeByte(JdwpConstants.Tag.DOUBLE);
+ os.writeDouble(((Double) obj).doubleValue());
+ }
+ else if (clazz == int.class)
+ {
+ if (tagged)
+ os.writeByte(JdwpConstants.Tag.BYTE);
+ os.writeInt(((Integer) obj).intValue());
+ }
+ else if (clazz == long.class)
+ {
+ if (tagged)
+ os.writeByte(JdwpConstants.Tag.LONG);
+ os.writeLong(((Long) obj).longValue());
+ }
+ else if (clazz == short.class)
+ {
+ if (tagged)
+ os.writeByte(JdwpConstants.Tag.SHORT);
+ os.writeInt(((Short) obj).shortValue());
+ }
+ else if (clazz == void.class)
+ { // A 'void' has no data
+ if (tagged)
+ os.writeByte(JdwpConstants.Tag.VOID);
+ }
+ else if (clazz == boolean.class)
+ {
+ if (tagged)
+ os.writeByte(JdwpConstants.Tag.BOOLEAN);
+ os.writeBoolean(((Boolean) obj).booleanValue());
+ }
+ else
+ { // This shouldn't be possible
+ throw new JdwpInternalErrorException(
+ "Field has invalid primitive!");
+ }
+ }
+ else
+ {
+ // Object is an Object, not a primitive type wrapped in an object
+ // Write the appropriate tag
+ if (tagged)
+ {
+ if (clazz.isArray())
+ os.writeByte(JdwpConstants.Tag.ARRAY);
+ else if (obj instanceof String)
+ os.writeByte(JdwpConstants.Tag.STRING);
+ else if (obj instanceof Thread)
+ os.writeByte(JdwpConstants.Tag.THREAD);
+ else if (obj instanceof ThreadGroup)
+ os.writeByte(JdwpConstants.Tag.THREAD_GROUP);
+ else if (obj instanceof ClassLoader)
+ os.writeByte(JdwpConstants.Tag.CLASS_LOADER);
+ else if (obj instanceof Class)
+ os.writeByte(JdwpConstants.Tag.CLASS_OBJECT);
+ else
+ os.writeByte(JdwpConstants.Tag.OBJECT);
+ }
+ ObjectId oid = VMIdManager.getDefault().getObjectId(obj);
+ oid.write(os);
+ }
+ }
+
+ /**
+ * Reads the appropriate object for the tagged value contained in the
+ * ByteBuffer.
+ *
+ * @param bb contains the Object
+ * @return The Object referenced by the value
+ * @throws JdwpException
+ * @throws IOException
+ */
+ public static Object getObj(ByteBuffer bb)
+ throws JdwpException, IOException
+ {
+ return getUntaggedObj(bb, bb.get());
+ }
+
+ /**
+ * Reads the an object of the given Class from the untagged value contained
+ * in the ByteBuffer.
+ *
+ * @param bb contains the Object
+ * @param type corresponds to the TAG of value to be read
+ * @return
+ * @throws JdwpException
+ * @throws IOException
+ */
+ public static Object getUntaggedObj(ByteBuffer bb, Class type)
+ throws JdwpException, IOException
+ {
+ if (type.isPrimitive())
+ {
+ if (type == byte.class)
+ return new Byte(bb.get());
+ else if (type == char.class)
+ return new Character(bb.getChar());
+ else if (type == float.class)
+ return new Float(bb.getFloat());
+ else if (type == double.class)
+ return new Double(bb.getDouble());
+ else if (type == int.class)
+ return new Integer(bb.getInt());
+ else if (type == long.class)
+ return new Long(bb.getLong());
+ else if (type == short.class)
+ return new Short(bb.getShort());
+ else if (type == boolean.class)
+ return (bb.get() == 0) ? new Boolean(false) : new Boolean(true);
+ else if (type == void.class)
+ return new byte[0];
+ else
+ { // This shouldn't be possible
+ throw new JdwpInternalErrorException(
+ "Field has invalid primitive!");
+ }
+ }
+ else
+ {
+ // Field is an object
+ ObjectId oid = VMIdManager.getDefault().readObjectId(bb);
+ return oid.getObject();
+ }
+ }
+
+ /**
+ * Reads the an object of the given Class from the untagged value contained
+ * in the ByteBuffer.
+ *
+ * @param bb contains the Object
+ * @param tag TAG of the Value to be read
+ * @return the object
+ * @throws JdwpException
+ * @throws IOException
+ */
+ public static Object getUntaggedObj(ByteBuffer bb, byte tag)
+ throws JdwpException, IOException
+ {
+ switch (tag)
+ {
+ case JdwpConstants.Tag.BYTE:
+ return new Byte(bb.get());
+ case JdwpConstants.Tag.CHAR:
+ return new Character(bb.getChar());
+ case JdwpConstants.Tag.FLOAT:
+ return new Float(bb.getFloat());
+ case JdwpConstants.Tag.DOUBLE:
+ return new Double(bb.getDouble());
+ case JdwpConstants.Tag.INT:
+ return new Integer(bb.getInt());
+ case JdwpConstants.Tag.LONG:
+ return new Long(bb.getLong());
+ case JdwpConstants.Tag.SHORT:
+ return new Short(bb.getShort());
+ case JdwpConstants.Tag.VOID:
+ return new byte[0];
+ case JdwpConstants.Tag.BOOLEAN:
+ return (bb.get() == 0) ? new Boolean(false) : new Boolean(true);
+ case JdwpConstants.Tag.STRING:
+ return JdwpString.readString(bb);
+ case JdwpConstants.Tag.ARRAY:
+ case JdwpConstants.Tag.THREAD:
+ case JdwpConstants.Tag.OBJECT:
+ case JdwpConstants.Tag.THREAD_GROUP:
+ case JdwpConstants.Tag.CLASS_LOADER:
+ case JdwpConstants.Tag.CLASS_OBJECT:
+ // All these cases are ObjectIds
+ ObjectId oid = VMIdManager.getDefault().readObjectId(bb);
+ return oid.getObject();
+ default:
+ throw new NotImplementedException("Tag " + tag
+ + " is not implemented.");
+ }
+ }
+}
--- /dev/null
+/* VariableTable.java -- A class representing a Variable Table for a method
+ Copyright (C) 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., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 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
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package gnu.classpath.jdwp.util;
+
+import java.io.DataOutputStream;
+import java.io.IOException;
+
+/**
+ * A class representing a Variable Table for a method.
+ *
+ * @author Aaron Luchko <aluchko@redhat.com>
+ */
+public class VariableTable
+{
+
+ private final long argCnt;
+
+ private final long slots;
+
+ private final long[] lineCI;
+
+ private int[] slot;
+
+ private int[] lengths;
+
+ private String[] sigs;
+
+ private String[] names;
+
+ /**
+ * Make a new variable table with the given values.
+ *
+ * @param argCnt number of words used by arguments in this frame
+ * @param slots number of variables
+ * @param lineCI first code index of given variable (size slots)
+ * @param names name of given variable (size slots)
+ * @param sigs signature of given variable (size slots)
+ * @param lengths size of region where variable is active (size slots)
+ * @param slot index of variable in this frame (size slots)
+ */
+ public VariableTable(int argCnt, int slots, long lineCI[], String names[],
+ String sigs[], int lengths[], int slot[])
+ {
+ this.argCnt = argCnt;
+ this.slots = slots;
+ this.lineCI = lineCI;
+ this.names = names;
+ this.sigs = sigs;
+ this.lengths = lengths;
+ this.slot = slot;
+ }
+
+ /**
+ * Writes this line table to the given DataOutputStream.
+ *
+ * @param os the stream to write it to
+ * @throws IOException
+ */
+ public void write(DataOutputStream os) throws IOException
+ {
+ os.writeLong(argCnt);
+ os.writeLong(slots);
+ for (int i = 0; i < slots; i++)
+ {
+ os.writeLong(lineCI[i]);
+ JdwpString.writeString(os, names[i]);
+ JdwpString.writeString(os, sigs[i]);
+ os.writeInt(lengths[i]);
+ os.writeInt(slot[i]);
+ }
+ }
+
+}
--- /dev/null
+/* GtkClipboardNotifier.java -- Helper for announcing GtkSelection changes.
+ 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., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 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.datatransfer.*;
+
+class GtkClipboardNotifier extends Thread
+{
+ /** Whether or not to announce a GtkSelection change. */
+ private static boolean announceChange;
+
+ /**
+ * The one and only instance. All operations are synchronized on
+ * this.
+ */
+ private static GtkClipboardNotifier notifier = new GtkClipboardNotifier();
+
+ /**
+ * Creates a deamon thread that monitors this for change
+ * announcements.
+ */
+ private GtkClipboardNotifier()
+ {
+ super("GtkClipBoardNotifier");
+ setDaemon(true);
+ start();
+ }
+
+ /**
+ * Notifies that a new GtkSelection has to be announced.
+ */
+ static void announce()
+ {
+ synchronized (notifier)
+ {
+ announceChange = true;
+ notifier.notifyAll();
+ }
+ }
+
+ public void run()
+ {
+ final GtkClipboard clipboard = GtkClipboard.getInstance();
+ while (true)
+ {
+ synchronized (this)
+ {
+ while (!announceChange)
+ {
+ try
+ {
+ this.wait();
+ }
+ catch (InterruptedException ie)
+ {
+ // ignore
+ }
+ }
+ announceChange = false;
+ }
+
+ // Do the actual announcement without the lock held. We will
+ // notice a new change after this notification has finished.
+ try
+ {
+ clipboard.setContents(new GtkSelection(), null);
+ }
+ catch (Throwable t)
+ {
+ // should never happen, but might if we have some faulty
+ // listener.
+ t.printStackTrace();
+ }
+ }
+ }
+}
--- /dev/null
+/* GtkClipboard.java - Class representing gtk+ clipboard selection.
+ 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., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 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 gnu.classpath.Pointer;
+
+import java.awt.datatransfer.*;
+
+import java.io.*;
+import java.net.*;
+import java.util.*;
+
+import java.awt.Image;
+
+/**
+ * Class representing the gtk+ clipboard selection. This is used when
+ * another program owns the clipboard. Whenever the system clipboard
+ * selection changes we create a new instance to notify the program
+ * that the available flavors might have changed. When requested it
+ * (lazily) caches the targets, and (text, image, or files/uris)
+ * clipboard contents.
+ *
+ * XXX - should only cache when
+ * gdk_display_supports_selection_notification is true.
+ */
+public class GtkSelection implements Transferable
+{
+ /**
+ * Static lock used for requests of mimetypes and contents retrieval.
+ */
+ static private Object requestLock = new Object();
+
+ /**
+ * Whether a request for mimetypes, text, images, uris or byte[] is
+ * currently in progress. Should only be tested or set with
+ * requestLock held. When true no other requests should be made till
+ * it is false again.
+ */
+ private boolean requestInProgress;
+
+ /**
+ * Indicates a requestMimeTypes() call was made and the
+ * corresponding mimeTypesAvailable() callback was triggered.
+ */
+ private boolean mimeTypesDelivered;
+
+ /**
+ * Set and returned by getTransferDataFlavors. Only valid when
+ * mimeTypesDelivered is true.
+ */
+ private DataFlavor[] dataFlavors;
+
+ /**
+ * Indicates a requestText() call was made and the corresponding
+ * textAvailable() callback was triggered.
+ */
+ private boolean textDelivered;
+
+ /**
+ * Set as response to a requestText() call and possibly returned by
+ * getTransferData() for text targets. Only valid when textDelivered
+ * is true.
+ */
+ private String text;
+
+ /**
+ * Indicates a requestImage() call was made and the corresponding
+ * imageAvailable() callback was triggered.
+ */
+ private boolean imageDelivered;
+
+ /**
+ * Set as response to a requestImage() call and possibly returned by
+ * getTransferData() for image targets. Only valid when
+ * imageDelivered is true and image is null.
+ */
+ private Pointer imagePointer;
+
+ /**
+ * Cached image value. Only valid when imageDelivered is
+ * true. Created from imagePointer.
+ */
+ private Image image;
+
+ /**
+ * Indicates a requestUris() call was made and the corresponding
+ * urisAvailable() callback was triggered.
+ */
+ private boolean urisDelivered;
+
+ /**
+ * Set as response to a requestURIs() call. Only valid when
+ * urisDelivered is true
+ */
+ private List uris;
+
+ /**
+ * Indicates a requestBytes(String) call was made and the
+ * corresponding bytesAvailable() callback was triggered.
+ */
+ private boolean bytesDelivered;
+
+ /**
+ * Set as response to a requestBytes(String) call. Only valid when
+ * bytesDelivered is true.
+ */
+ private byte[] bytes;
+
+ /**
+ * Should only be created by the GtkClipboard class.
+ */
+ GtkSelection()
+ {
+ }
+
+ /**
+ * Gets an array of mime-type strings from the gtk+ clipboard and
+ * transforms them into an array of DataFlavors.
+ */
+ public DataFlavor[] getTransferDataFlavors()
+ {
+ DataFlavor[] result;
+ synchronized (requestLock)
+ {
+ // Did we request already and cache the result?
+ if (mimeTypesDelivered)
+ result = (DataFlavor[]) dataFlavors.clone();
+ else
+ {
+ // Wait till there are no pending requests.
+ while (requestInProgress)
+ {
+ try
+ {
+ requestLock.wait();
+ }
+ catch (InterruptedException ie)
+ {
+ // ignored
+ }
+ }
+
+ // If nobody else beat us and cached the result we try
+ // ourselves to get it.
+ if (! mimeTypesDelivered)
+ {
+ requestInProgress = true;
+ requestMimeTypes();
+ while (! mimeTypesDelivered)
+ {
+ try
+ {
+ requestLock.wait();
+ }
+ catch (InterruptedException ie)
+ {
+ // ignored
+ }
+ }
+ requestInProgress = false;
+ }
+ result = dataFlavors;
+ if (! GtkClipboard.canCache)
+ {
+ dataFlavors = null;
+ mimeTypesDelivered = false;
+ }
+ requestLock.notifyAll();
+ }
+ }
+ return result;
+ }
+
+ /**
+ * Callback that sets the available DataFlavors[]. Note that this
+ * should not call any code that could need the main gdk lock.
+ */
+ private void mimeTypesAvailable(String[] mimeTypes)
+ {
+ synchronized (requestLock)
+ {
+ if (mimeTypes == null)
+ dataFlavors = new DataFlavor[0];
+ else
+ {
+ // Most likely the mimeTypes include text in which case we add an
+ // extra element.
+ ArrayList flavorsList = new ArrayList(mimeTypes.length + 1);
+ for (int i = 0; i < mimeTypes.length; i++)
+ {
+ try
+ {
+ if (mimeTypes[i] == GtkClipboard.stringMimeType)
+ {
+ // XXX - Fix DataFlavor.getTextPlainUnicodeFlavor()
+ // and also add it to the list.
+ flavorsList.add(DataFlavor.stringFlavor);
+ flavorsList.add(DataFlavor.plainTextFlavor);
+ }
+ else if (mimeTypes[i] == GtkClipboard.imageMimeType)
+ flavorsList.add(DataFlavor.imageFlavor);
+ else if (mimeTypes[i] == GtkClipboard.filesMimeType)
+ flavorsList.add(DataFlavor.javaFileListFlavor);
+ else
+ {
+ // We check the target to prevent duplicates
+ // of the "magic" targets above.
+ DataFlavor target = new DataFlavor(mimeTypes[i]);
+ if (! flavorsList.contains(target))
+ flavorsList.add(target);
+ }
+ }
+ catch (ClassNotFoundException cnfe)
+ {
+ cnfe.printStackTrace();
+ }
+ catch (NullPointerException npe)
+ {
+ npe.printStackTrace();
+ }
+ }
+
+ dataFlavors = new DataFlavor[flavorsList.size()];
+ flavorsList.toArray(dataFlavors);
+ }
+
+ mimeTypesDelivered = true;
+ requestLock.notifyAll();
+ }
+ }
+
+ /**
+ * Gets the available data flavors for this selection and checks
+ * that at least one of them is equal to the given DataFlavor.
+ */
+ public boolean isDataFlavorSupported(DataFlavor flavor)
+ {
+ DataFlavor[] dfs = getTransferDataFlavors();
+ for (int i = 0; i < dfs.length; i++)
+ if (flavor.equals(dfs[i]))
+ return true;
+
+ return false;
+ }
+
+ /**
+ * Helper method that tests whether we already have the text for the
+ * current gtk+ selection on the clipboard and if not requests it
+ * and waits till it is available.
+ */
+ private String getText()
+ {
+ String result;
+ synchronized (requestLock)
+ {
+ // Did we request already and cache the result?
+ if (textDelivered)
+ result = text;
+ else
+ {
+ // Wait till there are no pending requests.
+ while (requestInProgress)
+ {
+ try
+ {
+ requestLock.wait();
+ }
+ catch (InterruptedException ie)
+ {
+ // ignored
+ }
+ }
+
+ // If nobody else beat us we try ourselves to get and
+ // caching the result.
+ if (! textDelivered)
+ {
+ requestInProgress = true;
+ requestText();
+ while (! textDelivered)
+ {
+ try
+ {
+ requestLock.wait();
+ }
+ catch (InterruptedException ie)
+ {
+ // ignored
+ }
+ }
+ requestInProgress = false;
+ }
+ result = text;
+ if (! GtkClipboard.canCache)
+ {
+ text = null;
+ textDelivered = false;
+ }
+ requestLock.notifyAll();
+ }
+ }
+ return result;
+ }
+
+ /**
+ * Callback that sets the available text on the clipboard. Note that
+ * this should not call any code that could need the main gdk lock.
+ */
+ private void textAvailable(String text)
+ {
+ synchronized (requestLock)
+ {
+ this.text = text;
+ textDelivered = true;
+ requestLock.notifyAll();
+ }
+ }
+
+ /**
+ * Helper method that tests whether we already have an image for the
+ * current gtk+ selection on the clipboard and if not requests it
+ * and waits till it is available.
+ */
+ private Image getImage()
+ {
+ Image result;
+ synchronized (requestLock)
+ {
+ // Did we request already and cache the result?
+ if (imageDelivered)
+ result = image;
+ else
+ {
+ // Wait till there are no pending requests.
+ while (requestInProgress)
+ {
+ try
+ {
+ requestLock.wait();
+ }
+ catch (InterruptedException ie)
+ {
+ // ignored
+ }
+ }
+
+ // If nobody else beat us we try ourselves to get and
+ // caching the result.
+ if (! imageDelivered)
+ {
+ requestInProgress = true;
+ requestImage();
+ while (! imageDelivered)
+ {
+ try
+ {
+ requestLock.wait();
+ }
+ catch (InterruptedException ie)
+ {
+ // ignored
+ }
+ }
+ requestInProgress = false;
+ }
+ if (imagePointer != null)
+ image = new GtkImage(imagePointer);
+ imagePointer = null;
+ result = image;
+ if (! GtkClipboard.canCache)
+ {
+ image = null;
+ imageDelivered = false;
+ }
+ requestLock.notifyAll();
+ }
+ }
+ return result;
+ }
+
+ /**
+ * Callback that sets the available image on the clipboard. Note
+ * that this should not call any code that could need the main gdk
+ * lock. Note that we get a Pointer to a GdkPixbuf which we cannot
+ * turn into a real GtkImage at this point. That will be done on the
+ * "user thread" in getImage().
+ */
+ private void imageAvailable(Pointer pointer)
+ {
+ synchronized (requestLock)
+ {
+ this.imagePointer = pointer;
+ imageDelivered = true;
+ requestLock.notifyAll();
+ }
+ }
+
+ /**
+ * Helper method that test whether we already have a list of
+ * URIs/Files and if not requests them and waits till they are
+ * available.
+ */
+ private List getURIs()
+ {
+ List result;
+ synchronized (requestLock)
+ {
+ // Did we request already and cache the result?
+ if (urisDelivered)
+ result = uris;
+ else
+ {
+ // Wait till there are no pending requests.
+ while (requestInProgress)
+ {
+ try
+ {
+ requestLock.wait();
+ }
+ catch (InterruptedException ie)
+ {
+ // ignored
+ }
+ }
+
+ // If nobody else beat us we try ourselves to get and
+ // caching the result.
+ if (! urisDelivered)
+ {
+ requestInProgress = true;
+ requestURIs();
+ while (! urisDelivered)
+ {
+ try
+ {
+ requestLock.wait();
+ }
+ catch (InterruptedException ie)
+ {
+ // ignored
+ }
+ }
+ requestInProgress = false;
+ }
+ result = uris;
+ if (! GtkClipboard.canCache)
+ {
+ uris = null;
+ urisDelivered = false;
+ }
+ requestLock.notifyAll();
+ }
+ }
+ return result;
+ }
+
+ /**
+ * Callback that sets the available File list. Note that this should
+ * not call any code that could need the main gdk lock.
+ */
+ private void urisAvailable(String[] uris)
+ {
+ synchronized (requestLock)
+ {
+ if (uris != null && uris.length != 0)
+ {
+ ArrayList list = new ArrayList(uris.length);
+ for (int i = 0; i < uris.length; i++)
+ {
+ try
+ {
+ URI uri = new URI(uris[i]);
+ if (uri.getScheme().equals("file"))
+ list.add(new File(uri));
+ }
+ catch (URISyntaxException use)
+ {
+ }
+ }
+ this.uris = list;
+ }
+
+ urisDelivered = true;
+ requestLock.notifyAll();
+ }
+ }
+
+ /**
+ * Helper method that requests a byte[] for the given target
+ * mime-type flavor and waits till it is available. Note that unlike
+ * the other get methods this one doesn't cache the result since
+ * there are possibly many targets.
+ */
+ private byte[] getBytes(String target)
+ {
+ byte[] result;
+ synchronized (requestLock)
+ {
+ // Wait till there are no pending requests.
+ while (requestInProgress)
+ {
+ try
+ {
+ requestLock.wait();
+ }
+ catch (InterruptedException ie)
+ {
+ // ignored
+ }
+ }
+
+ // Request bytes and wait till they are available.
+ requestInProgress = true;
+ requestBytes(target);
+ while (! bytesDelivered)
+ {
+ try
+ {
+ requestLock.wait();
+ }
+ catch (InterruptedException ie)
+ {
+ // ignored
+ }
+ }
+ result = bytes;
+ bytes = null;
+ bytesDelivered = false;
+ requestInProgress = false;
+
+ requestLock.notifyAll();
+ }
+ return result;
+ }
+
+ /**
+ * Callback that sets the available byte array on the
+ * clipboard. Note that this should not call any code that could
+ * need the main gdk lock.
+ */
+ private void bytesAvailable(byte[] bytes)
+ {
+ synchronized (requestLock)
+ {
+ this.bytes = bytes;
+ bytesDelivered = true;
+ requestLock.notifyAll();
+ }
+ }
+
+ public Object getTransferData(DataFlavor flavor)
+ throws UnsupportedFlavorException
+ {
+ // Note the fall throughs for the "magic targets" if they fail we
+ // try one more time through getBytes().
+ if (flavor.equals(DataFlavor.stringFlavor))
+ {
+ String text = getText();
+ if (text != null)
+ return text;
+ }
+
+ if (flavor.equals(DataFlavor.plainTextFlavor))
+ {
+ String text = getText();
+ if (text != null)
+ return new StringBufferInputStream(text);
+ }
+
+ if (flavor.equals(DataFlavor.imageFlavor))
+ {
+ Image image = getImage();
+ if (image != null)
+ return image;
+ }
+
+ if (flavor.equals(DataFlavor.javaFileListFlavor))
+ {
+ List uris = getURIs();
+ if (uris != null)
+ return uris;
+ }
+
+ byte[] bytes = getBytes(flavor.getMimeType());
+ if (bytes == null)
+ throw new UnsupportedFlavorException(flavor);
+
+ if (flavor.isMimeTypeSerializedObject())
+ {
+ try
+ {
+ ByteArrayInputStream bais = new ByteArrayInputStream(bytes);
+ ObjectInputStream ois = new ObjectInputStream(bais);
+ return ois.readObject();
+ }
+ catch (IOException ioe)
+ {
+ ioe.printStackTrace();
+ }
+ catch (ClassNotFoundException cnfe)
+ {
+ cnfe.printStackTrace();
+ }
+ }
+
+ if (flavor.isRepresentationClassInputStream())
+ return new ByteArrayInputStream(bytes);
+
+ // XXX, need some more conversions?
+
+ throw new UnsupportedFlavorException(flavor);
+ }
+
+ /*
+ * Requests text, Image or an byte[] for a particular target from the
+ * other application. These methods return immediately. When the
+ * content is available the contentLock will be notified through
+ * textAvailable, imageAvailable, urisAvailable or bytesAvailable and the
+ * appropriate field is set.
+ */
+ private native void requestText();
+ private native void requestImage();
+ private native void requestURIs();
+ private native void requestBytes(String target);
+
+ /* Similar to the above but for requesting the supported targets. */
+ private native void requestMimeTypes();
+}
--- /dev/null
+/* MainQtThread.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., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 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.qt;
+
+/**
+ * This Thread is the main Qt thread.
+ *
+ * It doesn't appear to do much here, since all custom code executed by
+ * this thread is injected into Qt's main event loop through the (native)
+ * MainThreadInterface class.
+ */
+public class MainQtThread extends Thread
+{
+ long QApplicationPointer;
+ long mainThreadInterface;
+ String theme;
+ private boolean running;
+ private boolean doublebuffer;
+
+ public MainQtThread( String theme, boolean doublebuffer )
+ {
+ this.theme = theme;
+ this.doublebuffer = doublebuffer;
+ running = false;
+ }
+
+ public boolean isRunning()
+ {
+ return running;
+ }
+
+ /**
+ * Creates the QApplication
+ */
+ public native long init(String theme, boolean doublebuffer);
+
+ /**
+ * Runs the QApplication (doesn't return.)
+ */
+ public native void exec(long ptr);
+
+ public void run()
+ {
+ QApplicationPointer = init(theme, doublebuffer);
+ running = true;
+ exec(QApplicationPointer);
+ }
+
+}
+
+
--- /dev/null
+/* NativeWrapper.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., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 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.qt;
+
+public class NativeWrapper
+{
+ protected long nativeObject;
+}
--- /dev/null
+/* QMatrix.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., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 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.qt;
+
+import java.awt.geom.AffineTransform;
+
+/**
+ * A simple wrapper class for a QMatrix,
+ * interfacing it to an AffineTransform.
+ */
+public class QMatrix extends NativeWrapper
+{
+
+ public QMatrix( AffineTransform t )
+ {
+ double[] matrix = new double[6];
+ t.getMatrix( matrix );
+ init( matrix[0], matrix[1], matrix[2], matrix[3], matrix[4], matrix[5] );
+ }
+
+ private native void init(double m00, double m10, double m01, double m11,
+ double m02, double m12 );
+
+ private native double[] getMatrix();
+
+ public AffineTransform getTransform()
+ {
+ return new AffineTransform( getMatrix() );
+ }
+
+ public native void dispose();
+
+ public void finalize()
+ {
+ dispose();
+ }
+}
+
--- /dev/null
+/* QPainterPath.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., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 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.qt;
+
+import java.awt.Shape;
+import java.awt.geom.AffineTransform;
+import java.awt.geom.PathIterator;
+import java.awt.geom.GeneralPath;
+
+/**
+ * A simple wrapper class for a QPainterPath,
+ * createable from an AWT Shape
+ */
+public class QPainterPath extends NativeWrapper
+{
+ QPainterPath()
+ {
+ }
+
+ public QPainterPath( Shape s )
+ {
+ PathIterator pi = s.getPathIterator( new AffineTransform() );
+ double[] coords = new double[6];
+
+ init( pi.getWindingRule() );
+
+ while( !pi.isDone() )
+ {
+ switch( pi.currentSegment(coords) )
+ {
+ case PathIterator.SEG_MOVETO:
+ moveTo( coords[0], coords[1] );
+ break;
+
+ case PathIterator.SEG_CLOSE:
+ close();
+ break;
+
+ case PathIterator.SEG_LINETO:
+ lineTo( coords[0], coords[1] );
+ break;
+
+ case PathIterator.SEG_QUADTO:
+ quadTo( coords[0], coords[1], coords[2], coords[3] );
+ break;
+
+ case PathIterator.SEG_CUBICTO:
+ cubicTo( coords[0], coords[1],
+ coords[2], coords[3],
+ coords[4], coords[5] );
+ break;
+ }
+ pi.next();
+ }
+ }
+
+ /**
+ * Constructor for rectangles.
+ */
+ public QPainterPath( double x, double y, double w, double h )
+ {
+ init(PathIterator.WIND_EVEN_ODD);
+ moveTo( x, y );
+ lineTo( x + w, y );
+ lineTo( x + w, y + h );
+ lineTo( x , y + h );
+ lineTo( x, y );
+ close();
+ }
+
+ /**
+ * Constructor for lines.
+ */
+ public QPainterPath( double x1, double y1, double x2, double y2, boolean s )
+ {
+ init(PathIterator.WIND_EVEN_ODD);
+ moveTo( x1, y1 );
+ lineTo( x2, y2 );
+ }
+
+ /**
+ * Returns the QPainterPath as a GeneralPath
+ */
+ public native GeneralPath getPath();
+
+ private native void init(int windingRule);
+
+ private native void moveTo(double x, double y);
+
+ private native void close();
+
+ private native void lineTo(double x, double y);
+
+ private native void quadTo(double x1, double y1, double x2, double y2);
+
+ private native void cubicTo(double x1, double y1, double x2, double y2,
+ double x3, double y3);
+
+ public native void dispose();
+
+ public void finalize()
+ {
+ dispose();
+ }
+}
+
--- /dev/null
+/* QPen.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., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 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.qt;
+
+import java.awt.Stroke;
+import java.awt.BasicStroke;
+
+/**
+ * A simple wrapper class for a QPen,
+ * interfacing it to an BasicStroke.
+ */
+public class QPen extends NativeWrapper
+{
+
+ public QPen( Stroke stroke )
+ {
+ if( !( stroke instanceof BasicStroke ) )
+ throw new IllegalArgumentException("Not a basic stroke.");
+
+ BasicStroke s = (BasicStroke)stroke;
+ if(s.getDashArray() != null)
+ throw new IllegalArgumentException("Can't handle dashed strokes.");
+
+ init(s.getLineWidth(), s.getEndCap(), s.getLineJoin(), s.getMiterLimit());
+ }
+
+ private native void init(double width, int cap, int join, double miterlimit);
+
+ public native void dispose();
+
+ public void finalize()
+ {
+ dispose();
+ }
+}
+
--- /dev/null
+/* QtAudioClip.java -- Qt implementation of the applet AudioClip interface
+ 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., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 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.qt;
+
+import java.applet.AudioClip;
+import java.awt.Toolkit;
+import java.io.File;
+import java.io.IOException;
+import java.net.URL;
+
+/**
+ * Implementation of the applet AudioClip interface on a Qt
+ * QSound object.
+ */
+public class QtAudioClip extends NativeWrapper implements AudioClip
+{
+ private static Toolkit t = null;
+
+ public QtAudioClip(String filename)
+ {
+ checkForQt();
+ File f = new File(filename);
+ try
+ {
+ String fn = f.getCanonicalPath();
+ loadClip( fn );
+ }
+ catch(IOException e)
+ {
+ }
+ }
+
+ public QtAudioClip(URL url)
+ {
+
+ }
+
+ private native void loadClip(String filename);
+
+ private native void play(boolean looped);
+
+ private native boolean isAvailable();
+
+ /**
+ * Checks that Qt and sound is available.
+ */
+ private void checkForQt()
+ {
+ if( t == null )
+ t = Toolkit.getDefaultToolkit();
+ if( !( t instanceof QtToolkit) )
+ throw new IllegalStateException("This requires Qt peers.");
+ }
+
+ // *************** Public methods *******************
+
+ public void loop()
+ {
+ play( true );
+ }
+
+ public void play()
+ {
+ play( false );
+ }
+
+ public native void stop();
+
+ public native void dispose();
+
+ public void finalize()
+ {
+ dispose();
+ }
+}
--- /dev/null
+/* QtButtonPeer.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., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 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.qt;
+
+import java.awt.Button;
+import java.awt.event.ActionEvent;
+import java.awt.peer.ButtonPeer;
+
+public class QtButtonPeer extends QtComponentPeer implements ButtonPeer
+{
+ public QtButtonPeer( QtToolkit kit, Button owner )
+ {
+ super( kit, owner );
+ }
+
+ public native void init();
+
+ protected void setup()
+ {
+ super.setup();
+ setLabel( ((Button)owner).getLabel() );
+ }
+
+ /**
+ * Callback for button click events
+ */
+ void fireClick(int modifiers)
+ {
+ ActionEvent e = new ActionEvent(owner,
+ ActionEvent.ACTION_PERFORMED,
+ ((Button)owner).getActionCommand(),
+ System.currentTimeMillis(),
+ modifiers);
+ QtToolkit.eventQueue.postEvent(e);
+ }
+
+ // ************ Public methods *********************
+
+ public native void setLabel( String label );
+}
+
+
+
+
--- /dev/null
+/* QtCanvasPeer.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., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 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.qt;
+
+import java.awt.Canvas;
+import java.awt.Dimension;
+import java.awt.peer.CanvasPeer;
+
+public class QtCanvasPeer extends QtComponentPeer implements CanvasPeer
+{
+ public QtCanvasPeer( QtToolkit kit, Canvas owner )
+ {
+ super( kit, owner );
+ }
+
+ public native void init();
+
+ protected void setup()
+ {
+ super.setup();
+ }
+
+ /**
+ * Overloaded, because a Canvas doesn't have a preferred size.
+ */
+ public Dimension getPreferredSize()
+ {
+ return owner.getSize();
+ }
+}
--- /dev/null
+/* QtCheckboxPeer.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., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 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.qt;
+
+import java.awt.Rectangle;
+import java.awt.Checkbox;
+import java.awt.CheckboxGroup;
+import java.awt.event.ItemEvent;
+import java.awt.peer.CheckboxPeer;
+import java.util.WeakHashMap;
+
+public class QtCheckboxPeer extends QtComponentPeer implements CheckboxPeer
+{
+ private CheckboxGroup group;
+
+ // Map QButtonGroup<->CheckboxGroup
+ private static WeakHashMap groupMap;
+
+ static
+ {
+ groupMap = new WeakHashMap();
+ }
+
+ public QtCheckboxPeer( QtToolkit kit, Checkbox owner )
+ {
+ super( kit, owner );
+ }
+
+ protected native void init();
+
+ protected void setup()
+ {
+ super.setup();
+ setCheckboxGroup( ((Checkbox)owner).getCheckboxGroup() );
+ setLabel( ((Checkbox)owner).getLabel() );
+ setState( ((Checkbox)owner).getState() );
+ }
+
+ private void fireToggle(boolean checked)
+ {
+ if (group == null)
+ ((Checkbox)owner).setState( checked );
+ else
+ if ( checked )
+ group.setSelectedCheckbox((Checkbox)owner);
+
+ int sel = checked ? ItemEvent.SELECTED : ItemEvent.DESELECTED;
+ ItemEvent e = new ItemEvent((Checkbox)owner,
+ ItemEvent.ITEM_STATE_CHANGED,
+ ((Checkbox)owner).getLabel(),
+ sel);
+ QtToolkit.eventQueue.postEvent(e);
+ }
+
+ // ************ Public methods *********************
+
+ public void setCheckboxGroup( CheckboxGroup group )
+ {
+ if(this.group == group)
+ return;
+
+ // if we change from a checkbox to a radio button or vice versa
+ if((this.group == null) != (group == null))
+ {
+ this.group = group;
+ callInit();
+ setup();
+ }
+
+ this.group = group;
+ }
+
+ public native void setLabel( String label );
+
+ public native void setState( boolean state );
+
+}
+
+
--- /dev/null
+/* QtChoicePeer.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., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 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.qt;
+
+import java.awt.Choice;
+import java.awt.event.ItemEvent;
+import java.awt.peer.ChoicePeer;
+
+public class QtChoicePeer extends QtComponentPeer implements ChoicePeer
+{
+ public QtChoicePeer( QtToolkit kit, Choice owner )
+ {
+ super( kit, owner );
+ }
+
+ protected native void init();
+
+ protected void setup()
+ {
+ super.setup();
+
+ Choice c = (Choice) owner;
+ int n = c.getItemCount();
+ for ( int i = 0; i < n ; i++ )
+ add( c.getItem( i ), i );
+ select( c.getSelectedIndex() );
+ }
+
+ private void fireChoice( int index )
+ {
+ ((Choice)owner).select( index );
+ ItemEvent e = new ItemEvent((Choice)owner,
+ ItemEvent.ITEM_STATE_CHANGED,
+ ((Choice)owner).getItem(index),
+ ItemEvent.SELECTED);
+ QtToolkit.eventQueue.postEvent(e);
+ }
+
+ // ************ Public methods *********************
+
+ public native void add( String item, int index );
+
+ public void addItem( String item, int index )
+ {
+ add(item, index);
+ }
+
+ public native void remove( int index );
+
+ public void removeAll()
+ {
+ int n = ((Choice)owner).getItemCount();
+ for (int i = 0; i < n; i++)
+ remove( i );
+ }
+
+ public native void select( int index );
+}
+
+
--- /dev/null
+/* QtComponentGraphics.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., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 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.qt;
+
+import java.awt.Color;
+import java.awt.GraphicsConfiguration;
+import java.awt.Graphics;
+import java.awt.Graphics2D;
+import java.awt.Rectangle;
+import java.awt.Paint;
+
+/**
+ * QtComponentPainter is a Graphics2D context for painting directly to AWT
+ * components. They require an existing QPainter object (the one passed into
+ * the native paint method), and are created there (ONLY).
+ *
+ * Since this context does direct on-screen drawing it is NOT thread-safe,
+ * and should NOT be used outside the thread in which it was created.
+ *
+ * In other words,
+ * this is intended for use by QtComponentPeer.paintEvent() only.
+ *
+ */
+public class QtComponentGraphics extends QtGraphics
+{
+ private QtComponentPeer peer;
+
+ /**
+ * Creates a new ComponentGraphics from an *existing* QPainter object.
+ *
+ * @param ptr the pointer to the QPainter object.
+ */
+ public QtComponentGraphics(long ptr, QtComponentPeer component,
+ int x, int y, int w, int h)
+ {
+ nativeObject = ptr;
+ peer = component;
+
+ Rectangle r = new Rectangle(x, y, w, h);
+ initialClip = r;
+
+ setAlpha( 1.0 );
+ Color c = component.owner.getBackground();
+ if(c == null)
+ setBackground(Color.white);
+ else
+ setBackground( c );
+
+ c = component.owner.getForeground();
+ if(c == null)
+ setColor( Color.black );
+ else
+ setColor( c );
+ setup();
+ setClip( initialClip );
+ }
+
+ /**
+ * Copying constructor
+ */
+ QtComponentGraphics( QtComponentGraphics g )
+ {
+ super( g ); // Slalom is fun
+ }
+
+ public Graphics create()
+ {
+ return new QtComponentGraphics( this );
+ }
+
+ /**
+ * This is a tricky one
+ */
+ public void copyArea(int x, int y, int width, int height,
+ int dx, int dy)
+ {
+ // FIXME
+ }
+
+ /**
+ * Returns the GraphicsConfiguration of the context component.
+ */
+ public GraphicsConfiguration getDeviceConfiguration()
+ {
+ return peer.getGraphicsConfiguration();
+ }
+}
+
+
--- /dev/null
+/* QtComponentPeer.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., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 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.qt;
+
+import java.awt.AWTEvent;
+import java.awt.AWTException;
+import java.awt.BufferCapabilities;
+import java.awt.Component;
+import java.awt.Container;
+import java.awt.Color;
+import java.awt.Cursor;
+import java.awt.Dimension;
+import java.awt.Font;
+import java.awt.FontMetrics;
+import java.awt.Image;
+import java.awt.Graphics;
+import java.awt.Graphics2D;
+import java.awt.GraphicsConfiguration;
+import java.awt.GraphicsDevice;
+import java.awt.KeyboardFocusManager;
+import java.awt.Point;
+import java.awt.Rectangle;
+import java.awt.Toolkit;
+import java.awt.Window;
+import java.awt.peer.ComponentPeer;
+import java.awt.peer.ContainerPeer;
+import java.awt.image.ColorModel;
+import java.awt.image.VolatileImage;
+import java.awt.image.ImageObserver;
+import java.awt.image.ImageProducer;
+import java.awt.event.ComponentEvent; // 100%
+import java.awt.event.FocusEvent; // 100%
+import java.awt.event.InputEvent; // (abstract)
+import java.awt.event.KeyEvent; // 2/3
+import java.awt.event.MouseEvent; // 70%?
+import java.awt.event.PaintEvent; // Yup.
+import java.awt.event.WindowEvent; // 2/ 12
+import java.util.Timer;
+import java.util.TimerTask;
+
+public class QtComponentPeer extends NativeWrapper implements ComponentPeer
+{
+
+ /**
+ * Popup trigger button, may differ between platforms
+ */
+ protected static final int POPUP_TRIGGER = 3;
+
+ /**
+ * The toolkit which manufactured this peer.
+ */
+ protected QtToolkit toolkit;
+
+ /**
+ * The component which owns this peer.
+ */
+ Component owner;
+
+ /**
+ * Classpath updates our eventMask.
+ */
+ private long eventMask;
+
+ /**
+ * if the thing has mouse motion listeners or not.
+ */
+ private boolean hasMotionListeners;
+
+ /**
+ * The component's double buffer for off-screen drawing.
+ */
+ protected QtImage backBuffer;
+
+ protected long qtApp;
+
+ private boolean settingUp;
+
+ private boolean ignoreResize = false;
+
+ QtComponentPeer( QtToolkit kit, Component owner )
+ {
+ this.owner = owner;
+ this.toolkit = kit;
+ qtApp = QtToolkit.guiThread.QApplicationPointer;
+ nativeObject = 0;
+ synchronized(this)
+ {
+ callInit(); // Calls the init method FROM THE MAIN THREAD.
+ try
+ {
+ wait(); // Wait for the thing to be created.
+ }
+ catch(InterruptedException e)
+ {
+ }
+ }
+ setup();
+ hasMotionListeners = false;
+ }
+
+ protected native void callInit();
+
+ /**
+ * Init does the creation of native widgets, it is therefore
+ * called from the main thread. (the constructor waits for this to happen.)
+ */
+ protected void init()
+ {
+ }
+
+ protected void setup()
+ {
+ settingUp = true;
+ if (owner != null)
+ {
+ if (owner instanceof javax.swing.JComponent)
+ setBackground(owner.getBackground());
+ else
+ owner.setBackground(getNativeBackground());
+
+ if (owner.getForeground() != null)
+ setForeground(owner.getForeground());
+ else
+ setForeground( Color.black );
+
+ if (owner.getCursor() != null)
+ if (owner.getCursor().getType() != Cursor.DEFAULT_CURSOR)
+ setCursor(owner.getCursor());
+
+ if (owner.getFont() != null)
+ setFont(owner.getFont());
+
+ setEnabled( owner.isEnabled() );
+
+ backBuffer = null;
+ updateBounds();
+
+ setVisible( owner.isVisible() );
+ QtToolkit.repaintThread.queueComponent(this);
+ }
+ settingUp = false;
+ }
+
+ native void QtUpdate();
+ native void QtUpdateArea( int x, int y, int w, int h );
+ private synchronized native void disposeNative();
+ private native void setGround( int r, int g, int b, boolean isForeground );
+ private native void setBoundsNative( int x, int y, int width, int height );
+ private native void setCursor( int ctype );
+ private native Color getNativeBackground();
+ private native void setFontNative( QtFontPeer fp );
+ private native int whichScreen();
+ private native void reparentNative( QtContainerPeer parent );
+ private native void getLocationOnScreenNative( Point p );
+
+ private boolean drawableComponent()
+ {
+ return ((this instanceof QtContainerPeer &&
+ !(this instanceof QtScrollPanePeer)) ||
+ (this instanceof QtCanvasPeer));
+ }
+
+ void updateBounds()
+ {
+ Rectangle r = owner.getBounds();
+ setBounds( r.x, r.y, r.width, r.height );
+ }
+
+ synchronized void updateBackBuffer(int width, int height)
+ {
+ if(width <= 0 || height <= 0)
+ return;
+
+ if( !drawableComponent() && backBuffer == null)
+ return;
+
+ if( backBuffer != null )
+ {
+ if( width < backBuffer.width && height < backBuffer.height )
+ return;
+ backBuffer.dispose();
+ }
+ backBuffer = new QtImage(width, height);
+ }
+
+
+ // ************ Event methods *********************
+
+ /**
+ * Window closing event
+ */
+ protected void closeEvent()
+ {
+ if (owner instanceof Window)
+ {
+ WindowEvent e = new WindowEvent((Window)owner,
+ WindowEvent.WINDOW_CLOSING);
+ QtToolkit.eventQueue.postEvent(e);
+ }
+ }
+
+ protected void enterEvent(int modifiers, int x, int y, int dummy)
+ {
+ MouseEvent e = new MouseEvent(owner,
+ MouseEvent.MOUSE_ENTERED,
+ System.currentTimeMillis(),
+ (modifiers & 0x2FF), x, y, 0, false);
+ QtToolkit.eventQueue.postEvent(e);
+ }
+
+ protected void focusInEvent()
+ {
+ FocusEvent e = new FocusEvent(owner, FocusEvent.FOCUS_GAINED);
+ QtToolkit.eventQueue.postEvent(e);
+ }
+
+ protected void focusOutEvent()
+ {
+ FocusEvent e = new FocusEvent(owner, FocusEvent.FOCUS_LOST);
+ QtToolkit.eventQueue.postEvent(e);
+ }
+
+ protected void keyPressEvent(int modifiers, int code, int unicode, int dummy)
+ {
+ KeyboardFocusManager manager = KeyboardFocusManager.getCurrentKeyboardFocusManager ();
+ KeyEvent e = new KeyEvent(owner,
+ KeyEvent.KEY_PRESSED,
+ System.currentTimeMillis(),
+ modifiers, code, (char)(unicode & 0xFFFF),
+ KeyEvent.KEY_LOCATION_UNKNOWN);
+ if (!manager.dispatchEvent (e))
+ QtToolkit.eventQueue.postEvent(e);
+ }
+
+ protected void keyReleaseEvent(int modifiers, int code, int unicode, int dummy)
+ {
+ KeyEvent e = new KeyEvent(owner,
+ KeyEvent.KEY_RELEASED,
+ System.currentTimeMillis(),
+ modifiers, code, (char)(unicode & 0xFFFF),
+ KeyEvent.KEY_LOCATION_UNKNOWN);
+ QtToolkit.eventQueue.postEvent(e);
+ }
+
+ protected void leaveEvent(int modifiers, int x, int y, int dummy)
+ {
+ MouseEvent e = new MouseEvent(owner,
+ MouseEvent.MOUSE_EXITED,
+ System.currentTimeMillis(),
+ (modifiers & 0x2FF), x, y, 0, false);
+ QtToolkit.eventQueue.postEvent(e);
+ }
+
+ // FIXME: Coalesce press-release events into clicks.
+ protected void mouseDoubleClickEvent( int modifiers, int x, int y, int clickCount)
+ {
+ if( (eventMask & AWTEvent.MOUSE_EVENT_MASK) == 0 )
+ return;
+ int button = 0;
+ if((modifiers & InputEvent.BUTTON1_DOWN_MASK) ==
+ InputEvent.BUTTON1_DOWN_MASK) button = 1;
+ if((modifiers & InputEvent.BUTTON2_DOWN_MASK) ==
+ InputEvent.BUTTON2_DOWN_MASK) button = 2;
+ if((modifiers & InputEvent.BUTTON3_DOWN_MASK) ==
+ InputEvent.BUTTON3_DOWN_MASK) button = 3;
+ MouseEvent e = new MouseEvent(owner,
+ MouseEvent.MOUSE_CLICKED,
+ System.currentTimeMillis(),
+ (modifiers & 0x2FF), x, y, clickCount,
+ false, button);
+ QtToolkit.eventQueue.postEvent(e);
+ }
+
+ protected void mouseMoveEvent( int modifiers, int x, int y, int clickCount)
+ {
+ if( (eventMask & AWTEvent.MOUSE_EVENT_MASK) == 0 )
+ return;
+
+ int button = 0;
+ if((modifiers & InputEvent.BUTTON1_DOWN_MASK) ==
+ InputEvent.BUTTON1_DOWN_MASK) button = 1;
+ if((modifiers & InputEvent.BUTTON2_DOWN_MASK) ==
+ InputEvent.BUTTON2_DOWN_MASK) button = 2;
+ if((modifiers & InputEvent.BUTTON3_DOWN_MASK) ==
+ InputEvent.BUTTON3_DOWN_MASK) button = 3;
+
+ int type = (button != 0) ?
+ MouseEvent.MOUSE_DRAGGED :MouseEvent.MOUSE_MOVED;
+
+ MouseEvent e = new MouseEvent(owner,
+ type,
+ System.currentTimeMillis(),
+ (modifiers & 0x2FF), x, y, clickCount,
+ false, button);
+ QtToolkit.eventQueue.postEvent(e);
+ }
+
+ protected void mousePressEvent( int modifiers, int x, int y, int clickCount)
+ {
+ if( (eventMask & AWTEvent.MOUSE_EVENT_MASK) == 0 )
+ return;
+ int button = 0;
+ if((modifiers & InputEvent.BUTTON1_DOWN_MASK) ==
+ InputEvent.BUTTON1_DOWN_MASK) button = 1;
+ if((modifiers & InputEvent.BUTTON2_DOWN_MASK) ==
+ InputEvent.BUTTON2_DOWN_MASK) button = 2;
+ if((modifiers & InputEvent.BUTTON3_DOWN_MASK) ==
+ InputEvent.BUTTON3_DOWN_MASK) button = 3;
+ MouseEvent e = new MouseEvent(owner,
+ MouseEvent.MOUSE_PRESSED,
+ System.currentTimeMillis(),
+ (modifiers & 0x2FF), x, y, clickCount,
+ ( button == POPUP_TRIGGER ),
+ button);
+ QtToolkit.eventQueue.postEvent(e);
+ }
+
+ protected void mouseReleaseEvent( int modifiers, int x, int y, int clickCount)
+ {
+ if( (eventMask & AWTEvent.MOUSE_EVENT_MASK) == 0 )
+ return;
+ int button = 0;
+ if((modifiers & InputEvent.BUTTON1_DOWN_MASK) ==
+ InputEvent.BUTTON1_DOWN_MASK) button = 1;
+ if((modifiers & InputEvent.BUTTON2_DOWN_MASK) ==
+ InputEvent.BUTTON2_DOWN_MASK) button = 2;
+ if((modifiers & InputEvent.BUTTON3_DOWN_MASK) ==
+ InputEvent.BUTTON3_DOWN_MASK) button = 3;
+
+ MouseEvent e = new MouseEvent(owner,
+ MouseEvent.MOUSE_RELEASED,
+ System.currentTimeMillis(),
+ (modifiers & 0x2FF), x, y, clickCount,
+ false, button);
+ QtToolkit.eventQueue.postEvent(e);
+ }
+
+ protected void moveEvent(int x, int y, int oldx, int oldy)
+ {
+ if( !ignoreResize )
+ {
+ // Since Component.setLocation calls back to setBounds,
+ // we need to ignore that.
+ ignoreResize = true;
+ owner.setLocation( x, y );
+ ignoreResize = false;
+ }
+ }
+
+ protected void resizeEvent(int oldWidth, int oldHeight,
+ int width, int height)
+ {
+ if(!(owner instanceof Window))
+ return;
+ updateBackBuffer(width, height);
+ ignoreResize = true;
+ owner.setSize(width, height);
+ ignoreResize = false;
+ ComponentEvent e = new ComponentEvent(owner,
+ ComponentEvent.COMPONENT_RESIZED);
+ QtToolkit.eventQueue.postEvent(e);
+ QtToolkit.repaintThread.queueComponent(this);
+ }
+
+ protected void showEvent()
+ {
+ if (owner instanceof Window)
+ {
+ WindowEvent e = new WindowEvent((Window)owner,
+ WindowEvent.WINDOW_OPENED);
+ QtToolkit.eventQueue.postEvent(e);
+ }
+ else
+ {
+ ComponentEvent e = new ComponentEvent(owner,
+ ComponentEvent.COMPONENT_SHOWN);
+ QtToolkit.eventQueue.postEvent(e);
+ }
+ }
+
+ protected void hideEvent()
+ {
+ ComponentEvent e = new ComponentEvent(owner,
+ ComponentEvent.COMPONENT_HIDDEN);
+ QtToolkit.eventQueue.postEvent(e);
+ }
+
+ // ************ Public methods *********************
+
+ /** Classpath-specific method */
+ public void setEventMask(long x)
+ {
+ eventMask = x;
+ }
+
+
+ public boolean canDetermineObscurity()
+ {
+ return true;
+ }
+
+ public int checkImage(Image img,
+ int w,
+ int h,
+ ImageObserver o)
+ {
+ return toolkit.checkImage(img, w, h, o);
+ }
+
+ public void createBuffers(int numBuffers, BufferCapabilities caps)
+ throws AWTException
+ {
+ // FIXME
+ }
+
+ public Image createImage(ImageProducer producer)
+ {
+ return toolkit.createImage(producer);
+ }
+
+ public Image createImage(int width, int height)
+ {
+ return new QtImage(width, height);
+ }
+
+ public void coalescePaintEvent(PaintEvent e)
+ {
+ // FIXME
+ }
+
+ public VolatileImage createVolatileImage(int w, int h)
+ {
+ return new QtVolatileImage( w, h );
+ }
+
+ public void destroyBuffers()
+ {
+ // FIXME
+ }
+
+ public void disable()
+ {
+ setEnabled(false);
+ }
+
+ public void dispose()
+ {
+ disposeNative();
+ if( backBuffer != null )
+ backBuffer.dispose();
+ }
+
+ public void enable()
+ {
+ setEnabled(true);
+ }
+
+ public void finalize()
+ {
+ dispose();
+ }
+
+ public void flip(BufferCapabilities.FlipContents contents)
+ {
+ }
+
+ public Image getBackBuffer()
+ {
+ return backBuffer;
+ }
+
+ public ColorModel getColorModel()
+ {
+ return toolkit.getColorModel();
+ }
+
+ public FontMetrics getFontMetrics(Font font)
+ {
+ return new QtFontMetrics( font, getGraphics() );
+ }
+
+ public Graphics getGraphics()
+ {
+ if( backBuffer == null )
+ {
+ Rectangle r = owner.getBounds();
+ backBuffer = new QtImage( r.width, r.height );
+ }
+ return backBuffer.getDirectGraphics( this );
+ }
+
+ public GraphicsConfiguration getGraphicsConfiguration()
+ {
+ int id = whichScreen(); // get the ID of the screen the widget is on.
+ GraphicsDevice[] devs = QtToolkit.graphicsEnv.getScreenDevices();
+ return devs[id].getDefaultConfiguration();
+ }
+
+ public Point getLocationOnScreen()
+ {
+ Point p = new Point();
+ synchronized( p )
+ {
+ getLocationOnScreenNative( p );
+ try
+ {
+ p.wait(); // Wait for the thing to be created.
+ }
+ catch(InterruptedException e)
+ {
+ }
+ }
+ return p;
+ }
+
+ private native void getSizeNative(Dimension d, boolean preferred);
+
+ private Dimension getSize(boolean preferred)
+ {
+ Dimension d = new Dimension();
+ synchronized( d )
+ {
+ getSizeNative(d, preferred);
+ try
+ {
+ d.wait(); // Wait for the thing to be created.
+ }
+ catch(InterruptedException e)
+ {
+ }
+ }
+ return d;
+ }
+
+ public Dimension getMinimumSize()
+ {
+ return getSize( false );
+ }
+
+ public Dimension getPreferredSize()
+ {
+ return getSize( true );
+ }
+
+ public Toolkit getToolkit()
+ {
+ return toolkit;
+ }
+
+ public native boolean handlesWheelScrolling();
+
+ public void hide()
+ {
+ setVisible(false);
+ }
+
+ public native boolean isFocusable();
+
+ public boolean isFocusTraversable()
+ {
+ // FIXME
+ return false;
+ }
+
+ public native boolean isObscured();
+
+ public Dimension minimumSize()
+ {
+ return getMinimumSize();
+ }
+
+ public Dimension preferredSize()
+ {
+ return getPreferredSize();
+ }
+
+ public native void requestFocus();
+
+ public boolean requestFocus (Component source, boolean bool1,
+ boolean bool2, long x)
+ {
+ // FIXME
+ return true;
+ }
+
+ public void reshape(int x,
+ int y,
+ int width,
+ int height)
+ {
+ setBounds( x, y, width, height );
+ }
+
+ public void setBackground(Color c)
+ {
+ if(c == null && !settingUp)
+ return;
+ setGround(c.getRed(), c.getGreen(), c.getBlue(), false);
+ }
+
+ public void setBounds(int x, int y, int width, int height)
+ {
+ if( ignoreResize )
+ return;
+ updateBackBuffer(width, height);
+ QtToolkit.repaintThread.queueComponent(this);
+ setBoundsNative(x, y, width, height);
+ }
+
+ public void setCursor(Cursor cursor)
+ {
+ if (cursor != null)
+ setCursor(cursor.getType());
+ }
+
+ public native void setEnabled(boolean b);
+
+ public void setFont(Font f)
+ {
+ if( f == null || f.getPeer() == null)
+ throw new IllegalArgumentException("Null font.");
+ setFontNative( (QtFontPeer)f.getPeer() );
+ }
+
+ public void setForeground(Color c)
+ {
+ if(c == null && !settingUp)
+ return;
+ setGround(c.getRed(), c.getGreen(), c.getBlue(), true);
+ }
+
+ public native void setVisible(boolean b);
+
+ public void show()
+ {
+ setVisible(true);
+ }
+
+ public void handleEvent (AWTEvent e)
+ {
+ int eventID = e.getID();
+ Rectangle r;
+
+ switch (eventID)
+ {
+ case ComponentEvent.COMPONENT_SHOWN:
+ QtToolkit.repaintThread.queueComponent(this);
+ break;
+ case PaintEvent.PAINT:
+ case PaintEvent.UPDATE:
+ r = ((PaintEvent)e).getUpdateRect();
+ QtToolkit.repaintThread.queueComponent(this, r.x, r.y,
+ r.width, r.height);
+ break;
+ case KeyEvent.KEY_PRESSED:
+ break;
+ case KeyEvent.KEY_RELEASED:
+ break;
+ }
+ }
+
+ /**
+ * paint() is called back from the native side in response to a native
+ * repaint event.
+ */
+ public void paint(Graphics g)
+ {
+ Rectangle r = g.getClipBounds();
+
+ if (backBuffer != null)
+ backBuffer.drawPixelsScaledFlipped ((QtGraphics) g,
+ 0, 0, 0, /* bg colors */
+ false, false, /* no flipping */
+ r.x, r.y, r.width, r.height,
+ r.x, r.y, r.width, r.height,
+ false ); /* no compositing */
+ }
+
+ public void paintBackBuffer() throws InterruptedException
+ {
+ if( backBuffer != null )
+ {
+ backBuffer.clear();
+ Graphics2D bbg = (Graphics2D)backBuffer.getGraphics();
+ owner.paint(bbg);
+ bbg.dispose();
+ }
+ }
+
+ public void paintBackBuffer(int x, int y, int w, int h)
+ throws InterruptedException
+ {
+ if( backBuffer != null )
+ {
+ Graphics2D bbg = (Graphics2D)backBuffer.getGraphics();
+ bbg.setBackground( getNativeBackground() );
+ bbg.clearRect(x, y, w, h);
+ bbg.setClip(x, y, w, h);
+ owner.paint(bbg);
+ bbg.dispose();
+ }
+ }
+
+ public boolean prepareImage(Image img,
+ int w,
+ int h,
+ ImageObserver o)
+ {
+ return toolkit.prepareImage(img, w, h, o);
+ }
+
+ public void print(Graphics g)
+ {
+ // FIXME
+ }
+
+ /**
+ * Schedules a timed repaint.
+ */
+ public void repaint(long tm,
+ int x,
+ int y,
+ int w,
+ int h)
+ {
+ if( tm <= 0 )
+ {
+ QtToolkit.repaintThread.queueComponent(this, x, y, w, h);
+ return;
+ }
+ Timer t = new Timer();
+ t.schedule(new RepaintTimerTask(this, x, y, w, h), tm);
+ }
+
+ /**
+ * Update the cursor (note that setCursor is usually not called)
+ */
+ public void updateCursorImmediately()
+ {
+ if (owner.getCursor() != null)
+ setCursor(owner.getCursor().getType());
+ }
+
+ /**
+ * Timed repainter
+ */
+ private class RepaintTimerTask extends TimerTask
+ {
+ private int x, y, w, h;
+ private QtComponentPeer peer;
+ RepaintTimerTask(QtComponentPeer peer, int x, int y, int w, int h)
+ {
+ this.x=x;
+ this.y=y;
+ this.w=w;
+ this.h=h;
+ this.peer=peer;
+ }
+ public void run()
+ {
+ QtToolkit.repaintThread.queueComponent(peer, x, y, w, h);
+ }
+ }
+
+ public native Rectangle getBounds();
+
+ public void reparent(ContainerPeer parent)
+ {
+ if(!(parent instanceof QtContainerPeer))
+ throw new IllegalArgumentException("Illegal peer.");
+ reparentNative((QtContainerPeer)parent);
+ }
+
+ public void setBounds(int x, int y, int width, int height, int z)
+ {
+ // TODO Auto-generated method stub
+
+ }
+
+ public boolean isReparentSupported()
+ {
+ return true;
+ }
+
+ // What does this do, anyway?
+ public void layout()
+ {
+ // TODO Auto-generated method stub
+ }
+}
--- /dev/null
+/* QtContainerPeer.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., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 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.qt;
+
+import java.awt.Container;
+import java.awt.Component;
+import java.awt.Insets;
+import java.awt.peer.ContainerPeer;
+
+public class QtContainerPeer extends QtComponentPeer implements ContainerPeer
+{
+ public QtContainerPeer( QtToolkit kit, Component owner )
+ {
+ super( kit, owner );
+ }
+
+ protected void init()
+ {
+ }
+
+ protected void setup()
+ {
+ super.setup();
+ }
+
+ // ************ Public methods *********************
+ public void beginLayout()
+ {
+ // FIXME
+ }
+
+ public void beginValidate()
+ {
+ }
+
+ public void endLayout()
+ {
+ QtUpdate();
+ }
+
+ public void endValidate()
+ {
+ }
+
+ public Insets getInsets()
+ {
+ return new Insets(0, 0, 0, 0);
+ }
+
+ public Insets insets()
+ {
+ return getInsets();
+ }
+
+ public boolean isPaintPending()
+ {
+ // FIXME etc.
+ return false;
+ }
+
+ public boolean isRestackSupported()
+ {
+ // TODO Auto-generated method stub
+ return false;
+ }
+
+ public void cancelPendingPaint(int x, int y, int width, int height)
+ {
+ // TODO Auto-generated method stub
+
+ }
+
+ public void restack()
+ {
+ // TODO Auto-generated method stub
+
+ }
+}
+
+
+
--- /dev/null
+/* QtDialogPeer.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., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 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.qt;
+
+import java.awt.Dialog;
+import java.awt.MenuBar;
+import java.awt.Rectangle;
+import java.awt.peer.DialogPeer;
+
+public class QtDialogPeer extends QtWindowPeer implements DialogPeer
+{
+ public QtDialogPeer( QtToolkit kit, Dialog owner )
+ {
+ super( kit, owner );
+ }
+
+ protected native void init();
+
+ protected void setup()
+ {
+ super.setup();
+ setTitle( ((Dialog)owner).getTitle() );
+ setResizable( ((Dialog)owner).isResizable() );
+ setModal( ((Dialog)owner).isModal() );
+ }
+
+ native void setModal(boolean modal);
+
+ private native void setBoundsNative(int x, int y, int width, int height, boolean fixed);
+
+ // ************ Public methods *********************
+
+ public native void setResizable (boolean resizeable);
+
+ public void setBounds(int x, int y, int width, int height)
+ {
+ setBoundsNative(x, y, width, height,
+ !((Dialog)owner).isResizable());
+ }
+}
--- /dev/null
+/* QtEmbeddedWindowPeer.java -- embedded window peer
+ 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., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 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.qt;
+
+import java.awt.Component;
+import java.awt.peer.WindowPeer;
+import gnu.java.awt.peer.EmbeddedWindowPeer;
+
+/**
+ * Embedded window peer for applets.
+ * FIXME: EmbeddedWindowPeer and this class should extend Window, NOT Frame.
+ */
+public class QtEmbeddedWindowPeer extends QtFramePeer implements EmbeddedWindowPeer
+{
+ public QtEmbeddedWindowPeer( QtToolkit kit, Component owner )
+ {
+ super( kit, owner );
+ }
+
+ protected native void init();
+
+ protected void setup()
+ {
+ super.setup();
+ }
+
+ // ************ Public methods *********************
+
+ public native void embed( long handle );
+}
--- /dev/null
+/* QtFileDialogPeer.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., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 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.qt;
+
+import java.awt.FileDialog;
+import java.io.FilenameFilter;
+import java.awt.peer.FileDialogPeer;
+
+public class QtFileDialogPeer extends QtDialogPeer implements FileDialogPeer
+{
+ public QtFileDialogPeer( QtToolkit kit, FileDialog owner )
+ {
+ super( kit, owner );
+ }
+
+ protected native void init();
+
+ protected void setup()
+ {
+ super.setup();
+ setMode( ((FileDialog)owner).getMode() );
+ }
+
+ /**
+ * Sets load or save mode
+ */
+ private native void setMode(int mode);
+
+ private void fileDialogDone(String path, String filename)
+ {
+ }
+
+ // ************ Public methods *********************
+ public void setFile (String file)
+ {
+ // FIXME
+ }
+
+ public void setDirectory (String dir)
+ {
+ // FIXME
+ }
+
+ public void setFilenameFilter (FilenameFilter ff)
+ {
+ // FIXME
+ }
+}
+
--- /dev/null
+/* QtFontMetrics.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., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 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.qt;
+
+import java.awt.Font;
+import java.awt.FontMetrics;
+import java.awt.Graphics;
+import java.awt.geom.Rectangle2D;
+import java.awt.font.FontRenderContext;
+import java.awt.font.GlyphVector;
+import java.awt.font.LineMetrics;
+
+public class QtFontMetrics extends FontMetrics
+{
+
+ private long nativeObject;
+ private QtFontPeer peer;
+
+ public QtFontMetrics( Font f )
+ {
+ super( f );
+ if(f.getPeer() == null || !(f.getPeer() instanceof QtFontPeer))
+ throw new IllegalArgumentException("Invalid Font object.");
+ peer = (QtFontPeer) f.getPeer();
+ init( peer );
+ }
+
+ public QtFontMetrics( Font f, Graphics g )
+ {
+ super( f );
+ if(f.getPeer() == null || !(f.getPeer() instanceof QtFontPeer))
+ throw new IllegalArgumentException("Invalid Font object.");
+ if( !(g instanceof QtGraphics) )
+ throw new IllegalArgumentException("Invalid graphics object.");
+ peer = (QtFontPeer) f.getPeer();
+ initGraphics(peer, (QtGraphics)g );
+ }
+
+ QtFontMetrics( QtFontPeer f, Graphics g )
+ {
+ super( null );
+ if( !(g instanceof QtGraphics) )
+ throw new IllegalArgumentException("Invalid graphics object.");
+ peer = f;
+ initGraphics(peer, (QtGraphics)g );
+ }
+
+ public QtFontMetrics( QtFontPeer fp )
+ {
+ super( (Font)null );
+ peer = fp;
+ init( peer );
+ }
+
+ private native void init(QtFontPeer fp);
+
+ private native void initGraphics(QtFontPeer fp, QtGraphics g);
+
+ private native void dispose();
+
+ native Rectangle2D getStringBounds(String s);
+
+ // ****************** Package private ***************************
+
+ native boolean canDisplay( char c );
+
+ // ****************** Public methods ****************************
+
+ public native int getAscent();
+
+ public native int getDescent();
+
+ public native int getHeight();
+
+ public native int getLeading();
+
+ public native int getMaxAdvance();
+
+ public native int charWidth(char c);
+
+ public int charsWidth(char[] chars, int off, int len)
+ {
+ return stringWidth( new String(chars, off, len) );
+ }
+
+ public native int stringWidth(String str);
+
+ public Rectangle2D getStringBounds(String str, Graphics context)
+ {
+ QtFontMetrics fm = new QtFontMetrics(peer, context);
+ return fm.getStringBounds( str );
+ }
+}
--- /dev/null
+/* QtFontPeer.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., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 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.qt;
+
+import java.awt.Font;
+import java.awt.FontMetrics;
+import java.awt.geom.Rectangle2D;
+import java.awt.font.FontRenderContext;
+import java.awt.font.GlyphVector;
+import java.awt.font.LineMetrics;
+import java.text.CharacterIterator;
+import java.util.Locale;
+import java.util.Map;
+import java.awt.peer.FontPeer;
+
+import gnu.java.awt.peer.ClasspathFontPeer;
+
+public class QtFontPeer extends ClasspathFontPeer
+{
+ // Pointer to native QFont structure.
+ private long nativeObject;
+ private QtFontMetrics metrics;
+
+
+ public QtFontPeer (String name, int style)
+ {
+ this(name, style, 12);
+ }
+
+ public QtFontPeer (String name, int style, int size)
+ {
+ super(name, style, size);
+ init();
+ }
+
+ public QtFontPeer (String name, Map attributes)
+ {
+ super(name, attributes);
+ init();
+ }
+
+ public void init()
+ {
+ if(this.familyName == null)
+ throw new IllegalArgumentException("null family name");
+ if(this.familyName.equals("Helvetica"))
+ this.familyName = "sans serif";
+ if(this.familyName.equals("Dialog"))
+ this.familyName = "sans serif";
+ create(this.familyName, this.style, (int)this.size);
+ metrics = new QtFontMetrics(this);
+ }
+
+ /**
+ * Creates the QFont object.
+ */
+ private native void create(String name, int style, int size);
+
+ /**
+ * Destroys the QFont.
+ */
+ public native void dispose();
+
+
+ // ****************** ClasspathFontPeer Methods.
+
+ public boolean canDisplay (Font font, char c)
+ {
+ return metrics.canDisplay( c );
+ }
+
+ public int canDisplayUpTo (Font font, CharacterIterator i,
+ int start, int limit)
+ {
+ int index = start;
+ char c = i.setIndex( index );
+ while( index <= limit )
+ {
+ if(!canDisplay(font, c))
+ return index;
+ index++;
+ c = i.next();
+ }
+ return -1;
+ }
+
+ public String getSubFamilyName (Font font, Locale locale)
+ {
+ throw new UnsupportedOperationException();
+ }
+
+ public String getPostScriptName (Font font)
+ {
+ throw new UnsupportedOperationException();
+ }
+
+ public int getNumGlyphs (Font font)
+ {
+ throw new UnsupportedOperationException();
+ }
+
+ public int getMissingGlyphCode (Font font)
+ {
+ throw new UnsupportedOperationException();
+ }
+
+ public byte getBaselineFor (Font font, char c)
+ {
+ throw new UnsupportedOperationException();
+ }
+
+ public String getGlyphName (Font font, int glyphIndex)
+ {
+ throw new UnsupportedOperationException();
+ }
+
+ public GlyphVector createGlyphVector (Font font,
+ FontRenderContext frc,
+ CharacterIterator ci)
+ {
+ throw new UnsupportedOperationException();
+ }
+
+ public GlyphVector createGlyphVector (Font font,
+ FontRenderContext ctx,
+ int[] glyphCodes)
+ {
+ throw new UnsupportedOperationException();
+ }
+
+ public GlyphVector layoutGlyphVector (Font font,
+ FontRenderContext frc,
+ char[] chars, int start,
+ int limit, int flags)
+ {
+ throw new UnsupportedOperationException();
+ }
+
+ public FontMetrics getFontMetrics (Font font)
+ {
+ return new QtFontMetrics( this );
+ }
+
+ public boolean hasUniformLineMetrics (Font font)
+ {
+ throw new UnsupportedOperationException();
+ }
+
+ public LineMetrics getLineMetrics (Font font,
+ CharacterIterator ci,
+ int begin, int limit,
+ FontRenderContext rc)
+ {
+ throw new UnsupportedOperationException();
+ }
+
+ public Rectangle2D getMaxCharBounds (Font font,
+ FontRenderContext rc)
+ {
+ throw new UnsupportedOperationException();
+ }
+
+ public Rectangle2D getStringBounds (Font font,
+ CharacterIterator ci,
+ int begin, int limit,
+ FontRenderContext frc)
+ {
+ int index = begin;
+ String s = "" + ci.setIndex( index );
+ while( index++ <= limit )
+ s = s + ci.next();
+ return metrics.getStringBounds(s);
+ }
+}
--- /dev/null
+/* QtFramePeer.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., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 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.qt;
+
+import java.awt.Component;
+import java.awt.Frame;
+import java.awt.Image;
+import java.awt.Insets;
+import java.awt.MenuBar;
+import java.awt.Rectangle;
+import java.awt.peer.FramePeer;
+
+public class QtFramePeer extends QtWindowPeer implements FramePeer
+{
+ private int theState; // FIXME
+
+ long frameObject;
+
+ public QtFramePeer( QtToolkit kit, Component owner )
+ {
+ super( kit, owner );
+ }
+
+ protected native void init();
+
+ protected void setup()
+ {
+ super.setup();
+ setTitle( ((Frame)owner).getTitle() );
+ if( ((Frame)owner).getMenuBar() != null )
+ setMenuBar( ((Frame)owner).getMenuBar() );
+ }
+
+ private native void setIcon(QtImage image);
+
+ private native void setMaximizedBounds(int w, int h);
+
+ private native void setMenu(QtMenuBarPeer mb);
+
+ private native int menuBarHeight();
+
+ // ************ Public methods *********************
+
+ public void destroy()
+ {
+ dispose();
+ }
+
+ public int getState()
+ {
+ // FIXME
+ return theState;
+ }
+
+ public Insets getInsets()
+ {
+ int mbHeight = ( ((Frame)owner).getMenuBar() != null ) ?
+ menuBarHeight() : 0;
+ return new Insets(mbHeight, 0, 0, 0);
+ }
+
+ public void setIconImage(Image im)
+ {
+ if (im instanceof QtImage)
+ setIcon( (QtImage)im );
+ else
+ setIcon( new QtImage( im.getSource() ) );
+ }
+
+ public void setMaximizedBounds(Rectangle rect)
+ {
+ // FIXME
+ }
+
+ public void setMenuBar(MenuBar mb)
+ {
+ if( mb != null )
+ {
+ QtMenuBarPeer mbpeer = (QtMenuBarPeer)mb.getPeer();
+ if( mbpeer == null )
+ {
+ mb.addNotify();
+ mbpeer = (QtMenuBarPeer)mb.getPeer();
+ if( mbpeer == null )
+ throw new IllegalStateException("No menu bar peer.");
+ }
+ mbpeer.addMenus();
+ setMenu( mbpeer );
+ }
+ else
+ setMenu( null );
+ }
+
+ public void setResizable(boolean resizeable)
+ {
+ // FIXME
+ }
+
+ public void setState(int s)
+ {
+ theState = s;
+ // FIXME
+ }
+
+ public void setBoundsPrivate(int x, int y, int width, int height)
+ {
+ // TODO Auto-generated method stub
+
+ }
+
+ public void updateAlwaysOnTop()
+ {
+ // TODO Auto-generated method stub
+
+ }
+
+ public boolean requestWindowFocus()
+ {
+ // TODO Auto-generated method stub
+ return false;
+ }
+
+}
--- /dev/null
+/* QtGraphics.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., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 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.qt;
+
+import java.awt.AlphaComposite;
+import java.awt.BasicStroke;
+import java.awt.Color;
+import java.awt.Composite;
+import java.awt.GradientPaint;
+import java.awt.GraphicsConfiguration;
+import java.awt.Font;
+import java.awt.FontMetrics;
+import java.awt.Graphics;
+import java.awt.Graphics2D;
+import java.awt.Image;
+import java.awt.RenderingHints;
+import java.awt.Rectangle;
+import java.awt.Paint;
+import java.awt.Polygon;
+import java.awt.Shape;
+import java.awt.Stroke;
+import java.awt.font.FontRenderContext;
+import java.awt.font.GlyphVector;
+import java.awt.geom.AffineTransform;
+import java.awt.geom.PathIterator;
+import java.awt.geom.Arc2D;
+import java.awt.geom.Ellipse2D;
+import java.awt.geom.Line2D;
+import java.awt.geom.Rectangle2D;
+import java.awt.geom.RoundRectangle2D;
+import java.awt.image.BufferedImage;
+import java.awt.image.BufferedImageOp;
+import java.awt.image.ImageObserver;
+import java.awt.image.RenderedImage;
+import java.awt.image.renderable.RenderableImage;
+
+import java.text.AttributedCharacterIterator;
+import java.text.CharacterIterator;
+import java.util.Map;
+
+/**
+ * QtGraphics is an abstract implementation of Graphics2D over a QPainter
+ * object. This is to be subclassed for different drawing contexts,
+ * which may have different requirements.
+ */
+public abstract class QtGraphics extends Graphics2D
+{
+ /**
+ * Native QPainter pointer.
+ */
+ protected long nativeObject;
+
+ private static final AffineTransform identity = new AffineTransform();
+
+ // Graphics state
+ protected Font font; // Current font.
+ protected Color color, bgcolor; // Current color and background color.
+ protected Shape clip; // Current clipping area.
+ protected Shape initialClip; // Initial clip bounds
+ protected AffineTransform xform; // Current transform
+ protected Stroke currentStroke; // the current stroke
+ protected boolean nativeStroking; // whether we're using Qt's stroking or not
+ protected Composite composite; // current composite operator
+ protected double currentAlpha; // current alpha
+ protected Paint currentPaint; // current paint
+ protected RenderingHints renderingHints; // the rendering hints.
+
+ /**
+ * Owner Graphics, used by subcontext created by create()
+ * to avoid GC of the original context.
+ */
+ Graphics parent;
+
+ /**
+ * Do-nothing constructor.
+ */
+ QtGraphics()
+ {
+ }
+
+ /**
+ * Copying constructor - used by copy() and subclasses.
+ */
+ QtGraphics(QtGraphics parent)
+ {
+ cloneNativeContext( parent );
+ setFont( parent.getFont() );
+ setAlpha( parent.currentAlpha );
+ setBackground( parent.getBackground() );
+ setColor( parent.getColor() );
+ setClip( (initialClip = parent.getClip()) );
+ setTransform( parent.getTransform() );
+ setStroke( parent.getStroke() );
+ setComposite( parent.getComposite() );
+ setPaint( parent.getPaint() );
+ setRenderingHints( parent.getRenderingHints() );
+ }
+
+ /**
+ * Set up some generic defaults.
+ */
+ protected void setup()
+ {
+ font = new Font ("Dialog", Font.PLAIN, 12);
+ setTransform( identity );
+ setStroke( new BasicStroke() );
+ renderingHints = new RenderingHints( null );
+ }
+
+ public synchronized native void delete();
+
+ public void dispose()
+ {
+ }
+
+ // ********************** etc *******************************
+
+ private void resetClip()
+ {
+ AffineTransform current = getTransform();
+ setTransform( identity );
+ setClip( initialClip );
+ setTransform( current );
+ }
+
+ protected native void initImage(QtImage image);
+ protected native void initVolatileImage(QtVolatileImage image);
+
+ // Creates a new native QPainter object on the same context.
+ private native void cloneNativeContext( QtGraphics parent );
+ private native void setColor(int r, int g, int b, int a);
+ private native void drawNative( QPainterPath p );
+ private native void fillNative( QPainterPath p );
+ private native void setClipNative( QPainterPath p );
+ private native void setClipRectNative( int x, int y, int w, int h );
+ private native void intersectClipNative( QPainterPath p );
+ private native void intersectClipRectNative( int x, int y, int w, int h );
+ private native void setQtTransform(QMatrix m);
+ private native void setNativeStroke(QPen p);
+ private native void setNativeComposite(int alphaMode);
+ private native void drawStringNative(String string, double x, double y);
+ private native void setLinearGradient(int r1, int g1, int b1,
+ int r2, int g2, int b2,
+ double x1, double y1,
+ double x2, double y2, boolean cyclic);
+ private native void setAlphaNative(double alpha);
+ private native void setFontNative(QtFontPeer font);
+ private native QPainterPath getClipNative();
+
+ void setAlpha(double alpha)
+ {
+ currentAlpha = alpha;
+ setAlphaNative(currentAlpha);
+ }
+
+ // ************ Public methods *********************
+
+ /**
+ * Context-sensitive methods are declared abstract.
+ */
+ public abstract Graphics create();
+
+ public abstract void copyArea(int x, int y, int width, int height,
+ int dx, int dy);
+
+ public abstract GraphicsConfiguration getDeviceConfiguration();
+
+
+ public Color getColor()
+ {
+ return new Color(color.getRed(), color.getGreen(), color.getBlue());
+ }
+
+ public void setColor(Color c)
+ {
+ if( c == null )
+ c = Color.white;
+ this.color = c;
+ int alpha = (int)(c.getAlpha() * currentAlpha);
+ setColor(c.getRed(), c.getGreen(), c.getBlue(), alpha);
+ }
+
+ public void setBackground(Color color)
+ {
+ bgcolor = new Color(color.getRed(), color.getGreen(), color.getBlue());
+ }
+
+ public Color getBackground()
+ {
+ return new Color(bgcolor.getRed(), bgcolor.getGreen(), bgcolor.getBlue());
+ }
+
+ public void setPaintMode()
+ {
+ }
+
+ public void setXORMode(Color color)
+ {
+ // FIXME
+ }
+
+ public boolean hit(Rectangle rect, Shape s, boolean onStroke)
+ {
+ if( onStroke )
+ {
+ Shape stroked = currentStroke.createStrokedShape( s );
+ return stroked.intersects( (double)rect.x, (double)rect.y,
+ (double)rect.width, (double)rect.height );
+ }
+ return s.intersects( (double)rect.x, (double)rect.y,
+ (double)rect.width, (double)rect.height );
+ }
+
+ // ******************* Font ***********************
+ public Font getFont()
+ {
+ return font;
+ }
+
+ public void setFont(Font font)
+ {
+ if( font == null )
+ return;
+ this.font = font;
+ if(font.getPeer() != null && font.getPeer() instanceof QtFontPeer)
+ setFontNative( (QtFontPeer)font.getPeer() );
+ }
+
+ public FontMetrics getFontMetrics(Font font)
+ {
+ return new QtFontMetrics(font, this);
+ }
+
+ // ***************** Clipping *********************
+
+ /**
+ * Intersects the current clip with the shape
+ */
+ public void clip(Shape s)
+ {
+ intersectClipNative( new QPainterPath( s ) );
+ }
+
+ public void clipRect(int x, int y, int width, int height)
+ {
+ intersectClipRectNative( x, y, width, height );
+ }
+
+ public void setClip(int x, int y, int width, int height)
+ {
+ setClipRectNative( x, y, width, height );
+ }
+
+ public Shape getClip()
+ {
+ return getClipNative().getPath();
+ }
+
+ public native Rectangle getClipBounds();
+
+ /**
+ * Sets the clip
+ */
+ public void setClip(Shape clip)
+ {
+ if (clip == null)
+ resetClip();
+ else
+ setClipNative(new QPainterPath( clip ));
+ }
+
+ // ***************** Drawing primitives *********************
+
+ public void draw(Shape s)
+ {
+ if( nativeStroking )
+ drawNative( new QPainterPath(s) );
+ else
+ fillNative( new QPainterPath( currentStroke.createStrokedShape( s ) ) );
+ }
+
+ public void fill(Shape s)
+ {
+ fillNative( new QPainterPath(s) );
+ }
+
+ public void drawLine(int x1, int y1, int x2, int y2)
+ {
+ if( nativeStroking )
+ drawNative( new QPainterPath((double)x1, (double)y1, (double)x2, (double)y2, true) );
+ else
+ draw( new Line2D.Double((double)x1, (double)y1, (double)x2, (double)y2) );
+ }
+
+ public void drawRect(int x, int y, int width, int height)
+ {
+ if( nativeStroking )
+ drawNative( new QPainterPath((double)x, (double)y,
+ (double)width, (double)height) );
+ else
+ fillNative( new QPainterPath
+ ( currentStroke.createStrokedShape
+ (new Rectangle2D.Double
+ ((double)x, (double)y,
+ (double)width, (double)height) ) ) );
+ }
+
+ public void fillRect(int x, int y, int width, int height)
+ {
+ fillNative( new QPainterPath( x, y, width, height ) );
+ }
+
+ public void clearRect(int x, int y, int width, int height)
+ {
+ Color c = color;
+ setColor( bgcolor ); // FIXME
+ fillRect( x, y, width, height );
+ setColor( c );
+ }
+
+ public void drawRoundRect(int x, int y, int width, int height,
+ int arcWidth, int arcHeight)
+ {
+ draw( new RoundRectangle2D.Double(x, y, width, height,
+ arcWidth, arcHeight) );
+ }
+
+ public void fillRoundRect(int x, int y, int width, int height,
+ int arcWidth, int arcHeight)
+ {
+ fill( new RoundRectangle2D.Double(x, y, width, height,
+ arcWidth, arcHeight) );
+ }
+
+ public void drawOval(int x, int y, int width, int height)
+ {
+ draw( new Ellipse2D.Double((double)x, (double)y,
+ (double)width, (double)height) );
+ }
+
+ public void fillOval(int x, int y, int width, int height)
+ {
+ fill( new Ellipse2D.Double(x, y, width, height) );
+ }
+
+ public void drawArc(int x, int y, int width, int height,
+ int arcStart, int arcAngle)
+ {
+ draw( new Arc2D.Double(x, y, width, height, arcStart, arcAngle,
+ Arc2D.OPEN) );
+ }
+
+ public void fillArc(int x, int y, int width, int height,
+ int arcStart, int arcAngle)
+ {
+ fill( new Arc2D.Double(x, y, width, height, arcStart, arcAngle,
+ Arc2D.CHORD) );
+ }
+
+ public void drawPolyline(int xPoints[], int yPoints[], int npoints)
+ {
+ for( int i = 0; i < npoints - 1; i++)
+ drawLine(xPoints[i], yPoints[i], xPoints[i + 1], yPoints[i + 1]);
+ }
+
+ public void drawPolygon(int xPoints[], int yPoints[], int npoints)
+ {
+ draw( new Polygon(xPoints, yPoints, npoints) );
+ }
+
+ public void fillPolygon(int xPoints[], int yPoints[], int npoints)
+ {
+ fill( new Polygon(xPoints, yPoints, npoints) );
+ }
+
+ public native void fill3DRect(int x, int y, int width, int height, boolean raised);
+
+ public native void draw3DRect(int x, int y, int width, int height, boolean raised);
+
+ // *********************** Text rendering *************************
+
+ public void drawString(String string, int x, int y)
+ {
+ drawStringNative(string, (double)x, (double)y);
+ }
+
+ public void drawString(String string, float x, float y)
+ {
+ drawStringNative(string, (double)x, (double)y);
+ }
+
+ public void drawString (AttributedCharacterIterator ci, int x, int y)
+ {
+ // FIXME - to something more correct ?
+ String s = "";
+ for(char c = ci.first(); c != CharacterIterator.DONE; c = ci.next())
+ s += c;
+ drawString(s, x, y);
+ }
+
+ public void drawString(AttributedCharacterIterator ci,
+ float x, float y)
+ {
+ // FIXME - to something more correct ?
+ String s = "";
+ for(char c = ci.first(); c != CharacterIterator.DONE; c = ci.next())
+ s += c;
+ drawString(s, x, y);
+ }
+
+ public void drawGlyphVector(GlyphVector v, float x, float y)
+ {
+ throw new RuntimeException("Not implemented");
+ }
+
+ // ******************* Image drawing ******************************
+ public boolean drawImage(Image image,
+ AffineTransform Tx,
+ ImageObserver obs)
+ {
+ if (image instanceof QtImage)
+ return ((QtImage)image).drawImage(this, new QMatrix( Tx ), obs);
+
+ return (new QtImage(image.getSource())).drawImage(this,
+ new QMatrix( Tx ),
+ obs);
+ }
+
+ public boolean drawImage(Image image, int x, int y, Color bgcolor,
+ ImageObserver observer)
+ {
+ if (image instanceof QtImage)
+ return ((QtImage)image).drawImage (this, x, y, bgcolor, observer);
+ return (new QtImage(image.getSource())).drawImage (this, x, y,
+ bgcolor, observer);
+ }
+
+ public boolean drawImage(Image image,
+ int dx1, int dy1, int dx2, int dy2,
+ int sx1, int sy1, int sx2, int sy2,
+ Color bgcolor, ImageObserver observer)
+ {
+ if (image instanceof QtImage)
+ return ((QtImage)image).drawImage(this, dx1, dy1, dx2, dy2,
+ sx1, sy1, sx2, sy2, bgcolor, observer);
+
+ return (new QtImage(image.getSource())).drawImage(this, dx1, dy1,
+ dx2, dy2,
+ sx1, sy1, sx2, sy2,
+ bgcolor, observer);
+ }
+
+ public boolean drawImage(Image image, int x, int y,
+ int width, int height, Color bgcolor,
+ ImageObserver observer)
+ {
+ if (image instanceof QtImage)
+ return ((QtImage)image).drawImage (this, x, y, width, height,
+ bgcolor, observer);
+ return (new QtImage(image.getSource())).drawImage (this, x, y,
+ width, height,
+ bgcolor, observer);
+ }
+
+ public boolean drawImage(Image image, int x, int y, int width, int height,
+ ImageObserver observer)
+ {
+ return drawImage(image, x, y, width, height, null, observer);
+ }
+
+ public boolean drawImage(Image image, int x, int y, ImageObserver observer)
+ {
+ return drawImage(image, x, y, null, observer);
+ }
+
+ public boolean drawImage(Image image, int dx1, int dy1, int dx2, int dy2, int sx1, int sy1, int sx2, int sy2, ImageObserver observer)
+ {
+ return drawImage(image, dx1, dy1, dx2, dy2,
+ sx1, sy1, sx2, sy2, null, observer);
+ }
+
+ // *********************** Transform methods *************************
+ public AffineTransform getTransform()
+ {
+ return new AffineTransform( xform );
+ }
+
+ public void setTransform(AffineTransform Tx)
+ {
+ xform = new AffineTransform( Tx );
+ setQtTransform( new QMatrix( xform ) );
+ }
+
+ public void rotate(double theta)
+ {
+ xform.rotate( theta );
+ setQtTransform( new QMatrix( xform ) );
+ }
+
+ public void rotate(double theta, double x, double y)
+ {
+ xform.rotate(theta, x, y);
+ setQtTransform( new QMatrix( xform ) );
+ }
+
+ public void scale(double sx, double sy)
+ {
+ xform.scale(sx, sy);
+ setQtTransform( new QMatrix( xform ) );
+ }
+
+ public void shear(double shx, double shy)
+ {
+ xform.shear(shx, shy);
+ setQtTransform( new QMatrix( xform ) );
+ }
+
+ public void transform(AffineTransform Tx)
+ {
+ xform.concatenate( Tx );
+ setQtTransform( new QMatrix( xform ) );
+ }
+
+ public void translate(double tx, double ty)
+ {
+ xform.translate( tx, ty );
+ setQtTransform( new QMatrix( xform ) );
+ }
+
+ public void translate(int x, int y)
+ {
+ translate((double)x, (double)y);
+ }
+
+ // *************** Stroking, Filling, Compositing *****************
+ public void setStroke(Stroke s)
+ {
+ try // ..to convert the stroke into a native one.
+ {
+ QPen pen = new QPen( s );
+ nativeStroking = true;
+ setNativeStroke( pen );
+ setColor( color );
+ }
+ catch (IllegalArgumentException e)
+ {
+ nativeStroking = false;
+ }
+ currentStroke = s;
+ }
+
+ public Stroke getStroke()
+ { // FIXME: return copy?
+ return currentStroke;
+ }
+
+ public void setComposite(Composite comp)
+ {
+ if( comp == null)
+ {
+ setNativeComposite( AlphaComposite.SRC_OVER );
+ return;
+ }
+
+ if( comp instanceof AlphaComposite )
+ {
+ if( ((AlphaComposite)comp).getRule() != AlphaComposite.XOR )
+ setAlpha( ((AlphaComposite)comp).getAlpha() );
+ setNativeComposite( ((AlphaComposite)comp).getRule() );
+ composite = comp;
+ }
+ else
+ throw new UnsupportedOperationException("We don't support custom"+
+ " composites yet.");
+ }
+
+ public Composite getComposite()
+ {
+ return composite;
+ }
+
+ public void setPaint(Paint p)
+ {
+ if( p == null )
+ return;
+
+ // FIXME
+ currentPaint = p;
+ if( p instanceof GradientPaint )
+ {
+ GradientPaint lg = (GradientPaint)p;
+ setLinearGradient(lg.getColor1().getRed(), lg.getColor1().getGreen(),
+ lg.getColor1().getBlue(), lg.getColor2().getRed(),
+ lg.getColor2().getGreen(), lg.getColor2().getBlue(),
+ lg.getPoint1().getX(), lg.getPoint1().getY(),
+ lg.getPoint2().getX(), lg.getPoint2().getY(),
+ lg.isCyclic() );
+ return;
+ }
+ if( p instanceof Color )
+ {
+ setColor((Color) p);
+ return;
+ }
+ throw new UnsupportedOperationException("We don't support custom"+
+ " paints yet.");
+ }
+
+ public Paint getPaint()
+ {
+ // FIXME
+ return currentPaint;
+ }
+
+ // ********************** Rendering Hints *************************
+
+ public void addRenderingHints(Map hints)
+ {
+ renderingHints.putAll( hints );
+ }
+
+ public Object getRenderingHint(RenderingHints.Key hintKey)
+ {
+ return renderingHints.get( hintKey );
+ }
+
+ public RenderingHints getRenderingHints()
+ {
+ return new RenderingHints( renderingHints );
+ }
+
+ public void setRenderingHints(Map hints)
+ {
+ renderingHints = new RenderingHints( hints );
+ updateRenderingHints();
+ }
+
+ public void setRenderingHint(RenderingHints.Key hintKey, Object hintValue)
+ {
+ renderingHints.put( hintKey, hintValue );
+ updateRenderingHints();
+ }
+
+ private void updateRenderingHints()
+ {
+ // FIXME - update native settings.
+ }
+
+ ////////////////////////////// unimplemented /////////////////////
+
+ public FontRenderContext getFontRenderContext()
+ {
+ throw new UnsupportedOperationException("Not implemented yet");
+ }
+
+ public void drawRenderableImage(RenderableImage image, AffineTransform xform)
+ {
+ throw new UnsupportedOperationException("Not implemented yet");
+ }
+
+ public void drawRenderedImage(RenderedImage image, AffineTransform xform)
+ {
+ throw new UnsupportedOperationException("Not implemented yet");
+ }
+
+ public void drawImage(BufferedImage image, BufferedImageOp op, int x, int y)
+ {
+ throw new UnsupportedOperationException("Not implemented yet");
+ }
+}
+
--- /dev/null
+/* QtGraphicsEnvironment.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., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 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.qt;
+
+import java.awt.Font;
+import java.awt.Graphics2D;
+import java.awt.GraphicsDevice;
+import java.awt.GraphicsEnvironment;
+import java.awt.HeadlessException;
+import java.awt.image.BufferedImage;
+import java.util.Locale;
+
+public class QtGraphicsEnvironment extends GraphicsEnvironment
+{
+ QtToolkit toolkit;
+ GraphicsDevice[] screens;
+
+ public QtGraphicsEnvironment (QtToolkit tk)
+ {
+ super();
+ toolkit = tk;
+ // Get the number of screens from Qt.
+ int n = toolkit.numScreens();
+
+ /**
+ * Create the screen device objects
+ */
+ screens = new GraphicsDevice[ n ];
+ for(int i = 0; i < n; i++)
+ screens[ i ] = new QtScreenDevice( i );
+ }
+
+ public Font[] getAllFonts ()
+ {
+ String[] fonts = getAvailableFontFamilyNames();
+ Font[] fontObjs = new Font[fonts.length];
+ for( int i = 0; i < fonts.length; i++)
+ fontObjs[i] = new Font(fonts[i], Font.PLAIN, 12);
+ return fontObjs;
+ }
+
+ public String[] getAvailableFontFamilyNames()
+ {
+ return toolkit.getFontList();
+ }
+
+ public String[] getAvailableFontFamilyNames(Locale l)
+ {
+ return getAvailableFontFamilyNames();
+ }
+
+ public GraphicsDevice getDefaultScreenDevice ()
+ {
+ return screens[ toolkit.defaultScreen() ];
+ }
+
+ public Graphics2D createGraphics (BufferedImage image)
+ {
+ return (Graphics2D)image.getGraphics();
+ }
+
+ public GraphicsDevice[] getScreenDevices()
+ {
+ return screens;
+ }
+
+ public QtToolkit getToolkit()
+ {
+ return toolkit;
+ }
+}
+
+
--- /dev/null
+/* QtImage.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., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 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.qt;
+
+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.io.ByteArrayOutputStream;
+import java.io.BufferedInputStream;
+import java.net.URL;
+import java.util.Hashtable;
+import java.util.WeakHashMap;
+import java.util.Vector;
+
+/**
+ * QtImage - wraps a QImage
+ *
+ */
+public class QtImage extends Image
+{
+ int width = -1, height = -1;
+
+ /**
+ * Properties.
+ */
+ Hashtable props;
+
+ /**
+ * Loaded or not flag, for asynchronous compatibility.
+ */
+ boolean isLoaded;
+
+ /**
+ * Pointer to the QImage
+ */
+ long nativeObject;
+
+ /**
+ * Observer queue.
+ */
+ Vector observers;
+
+ /**
+ * Error flag for loading.
+ */
+ boolean errorLoading;
+
+ /**
+ * Original source, if created from an ImageProducer.
+ */
+ ImageProducer source;
+
+ /*
+ * The 32-bit AARRGGBB format the uses.
+ */
+ static ColorModel nativeModel = new DirectColorModel(32,
+ 0x00FF0000,
+ 0x0000FF00,
+ 0x000000FF,
+ 0xFF000000);
+ /**
+ * HashMap of Graphics objects painting on this Image.
+ */
+ WeakHashMap painters;
+
+ /**
+ * Flags if this image is to be destroyed.
+ */
+ boolean killFlag;
+
+ /**
+ * Clears the image to RGBA 0
+ */
+ public native void clear();
+
+ /**
+ * 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
+ */
+ private native boolean loadImage(String name);
+
+ /**
+ * Loads an image from data.
+ */
+ private native boolean loadImageFromData(byte[] data);
+
+ /**
+ * Allocates a QImage
+ */
+ private native void createImage();
+
+ /**
+ * Frees the above.
+ */
+ private synchronized native void freeImage();
+
+ /**
+ * Sets the image to scaled copy of src image. hints are rendering hints.
+ */
+ private native void createScaledImage(QtImage src, int hints);
+
+ /**
+ * Draws the image optionally composited.
+ */
+ native void drawPixels (QtGraphics gc,
+ int bg_red, int bg_green, int bg_blue,
+ int x, int y,
+ boolean composite);
+ /**
+ * Draws the image, optionally scaled and composited.
+ */
+ private native void drawPixelsScaled (QtGraphics gc,
+ int bg_red, int bg_green, int bg_blue,
+ int x, int y, int width, int height,
+ boolean composite);
+
+ /**
+ * Draws the image transformed.
+ */
+ private native void drawPixelsTransformed (QtGraphics gc, QMatrix transform);
+
+ /**
+ * Draws the image scaled flipped and optionally composited.
+ */
+ native void drawPixelsScaledFlipped (QtGraphics 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);
+
+ /**
+ * Creates the image from an ImageProducer. May result in an error image.
+ */
+ public QtImage (ImageProducer producer)
+ {
+ killFlag = false;
+ isLoaded = false;
+ observers = new Vector();
+ source = producer;
+ errorLoading = false;
+ if( producer != null )
+ source.startProduction(new QtImageConsumer(this, source));
+ }
+
+ /**
+ * Creates the image from a URL. May result in an error image.
+ */
+ public QtImage (URL url)
+ {
+ killFlag = false;
+ isLoaded = false;
+ observers = new Vector();
+ errorLoading = false;
+ if( url == null)
+ return;
+ ByteArrayOutputStream baos = new ByteArrayOutputStream( 5000 );
+ try
+ {
+ BufferedInputStream bis = new BufferedInputStream(url.openStream());
+
+ byte[] buf = new byte[5000];
+ int n = 0;
+
+ while ( (n = bis.read( buf )) != -1 )
+ baos.write(buf, 0, n);
+ bis.close();
+ }
+ catch(IOException e)
+ {
+ throw new IllegalArgumentException("Couldn't load image.");
+ }
+ if ( loadImageFromData( baos.toByteArray() ) != true )
+ throw new IllegalArgumentException("Couldn't load image.");
+
+ isLoaded = true;
+ observers = null;
+ props = new Hashtable();
+ }
+
+ /**
+ * Constructs a QtImage by loading a given file.
+ *
+ * @throws IllegalArgumentException if the image could not be loaded.
+ */
+ public QtImage (String filename)
+ {
+ killFlag = false;
+ File f = new File(filename);
+ observers = null;
+ props = new Hashtable();
+ try
+ {
+ String fn = f.getCanonicalPath();
+ if (loadImage( fn ) != true)
+ {
+ errorLoading = true;
+ isLoaded = false;
+ return;
+ }
+ }
+ catch(IOException e)
+ {
+ errorLoading = true;
+ isLoaded = false;
+ return;
+ }
+ errorLoading = false;
+ isLoaded = true;
+ }
+
+ /**
+ * Constructs a QtImage from a byte array of an image file.
+ *
+ * @throws IllegalArgumentException if the image could not be loaded.
+ */
+ public QtImage (byte[] data)
+ {
+ if (loadImageFromData(data) != true)
+ throw new IllegalArgumentException("Couldn't load image.");
+
+ killFlag = false;
+ isLoaded = true;
+ observers = null;
+ errorLoading = false;
+ props = new Hashtable();
+ }
+
+ /**
+ * Constructs an empty QtImage.
+ */
+ public QtImage (int width, int height)
+ {
+ this.width = width;
+ this.height = height;
+ props = new Hashtable();
+ isLoaded = true;
+ killFlag = false;
+ observers = null;
+ errorLoading = false;
+ createImage();
+ clear();
+ }
+
+ /**
+ * Constructs a scaled version of the src bitmap, using Qt
+ */
+ private QtImage (QtImage src, int width, int height, int hints)
+ {
+ this.width = width;
+ this.height = height;
+ props = new Hashtable();
+ isLoaded = true;
+ killFlag = false;
+ observers = null;
+ errorLoading = false;
+
+ createScaledImage(src, hints);
+ }
+
+ /**
+ * Callback from the image consumer.
+ */
+ public void setImage(int width, int height,
+ int[] pixels, Hashtable properties)
+ {
+ this.width = width;
+ this.height = height;
+ props = (properties != null) ? properties : new Hashtable();
+
+ if (width <= 0 || height <= 0 || pixels == null)
+ {
+ errorLoading = true;
+ return;
+ }
+
+ isLoaded = true;
+ deliver();
+ createImage();
+ setPixels(pixels);
+ }
+
+ // java.awt.Image methods ////////////////////////////////////////////////
+
+ public int getWidth (ImageObserver observer)
+ {
+ if (addObserver(observer))
+ return -1;
+
+ return width;
+ }
+
+ public int getHeight (ImageObserver observer)
+ {
+ if (addObserver(observer))
+ return -1;
+
+ return height;
+ }
+
+ public Object getProperty (String name, ImageObserver observer)
+ {
+ if (addObserver(observer))
+ return UndefinedProperty;
+
+ Object value = props.get (name);
+ return (value == null) ? UndefinedProperty : value;
+ }
+
+ /**
+ * Returns the source of this image.
+ */
+ public ImageProducer getSource ()
+ {
+ if (!isLoaded)
+ return null;
+ return new MemoryImageSource(width, height, nativeModel, getPixels(),
+ 0, width);
+ }
+
+ void putPainter(QtImageGraphics g)
+ {
+ if( painters == null )
+ painters = new WeakHashMap();
+ painters.put( g, "dummy" );
+ }
+
+ void removePainter(QtImageGraphics g)
+ {
+ painters.remove( g );
+ if( killFlag && painters.isEmpty() )
+ freeImage();
+ }
+
+ /**
+ * Creates a Graphics context for this image.
+ */
+ public Graphics getGraphics ()
+ {
+ if (!isLoaded || killFlag)
+ return null;
+
+ return new QtImageGraphics(this);
+ }
+
+ /**
+ * Creates a Graphics context for this image.
+ */
+ Graphics getDirectGraphics(QtComponentPeer peer)
+ {
+ if (!isLoaded)
+ return null;
+
+ return new QtImageDirectGraphics(this, peer);
+ }
+
+ /**
+ * Returns a scaled instance of this image.
+ */
+ public Image getScaledInstance(int width,
+ int height,
+ int hints)
+ {
+ if (width <= 0 || height <= 0)
+ throw new IllegalArgumentException("Width and height of scaled bitmap"+
+ "must be >= 0");
+
+ return new QtImage(this, width, height, hints);
+ }
+
+ /**
+ * 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 QtImage can't be
+ * instantiated directly, how is the user to know if it was created from
+ * an ImageProducer or not?
+ */
+ public synchronized void flush ()
+ {
+ if (isLoaded && source != null)
+ {
+ observers = new Vector();
+ isLoaded = false;
+ freeImage();
+ source.startProduction(new QtImageConsumer(this, source));
+ }
+ }
+
+ public void finalize()
+ {
+ dispose();
+ }
+
+ public void dispose()
+ {
+ if (isLoaded)
+ {
+ if( painters == null || painters.isEmpty() )
+ freeImage();
+ else
+ killFlag = true; // can't destroy image yet.
+ // Do so when all painters are gone.
+ }
+ }
+
+ /**
+ * Returns the image status, used by QtToolkit
+ */
+ public int checkImage (ImageObserver observer)
+ {
+ if (addObserver(observer))
+ {
+ if (errorLoading == true)
+ return ImageObserver.ERROR;
+ else
+ return 0;
+ }
+
+ return ImageObserver.ALLBITS | ImageObserver.WIDTH | ImageObserver.HEIGHT;
+ }
+
+ // Drawing methods ////////////////////////////////////////////////
+
+ /**
+ * Draws an image with eventual scaling/transforming.
+ */
+ public boolean drawImage (QtGraphics g, QMatrix matrix,
+ ImageObserver observer)
+ {
+ if (addObserver(observer))
+ return false;
+
+ drawPixelsTransformed (g, matrix);
+
+ return true;
+ }
+
+ /**
+ * Draws an image to the QtGraphics context, at (x,y) with optional
+ * compositing with a background color.
+ */
+ public boolean drawImage (QtGraphics g, int x, int y,
+ Color bgcolor, ImageObserver observer)
+ {
+ if (addObserver(observer))
+ return false;
+
+ if(bgcolor != null)
+ drawPixels(g, bgcolor.getRed (), bgcolor.getGreen (),
+ bgcolor.getBlue (), x, y, true);
+ else
+ drawPixels(g, 0, 0, 0, x, y, false);
+
+ return true;
+ }
+
+ /**
+ * Draws an image to the QtGraphics context, at (x,y) scaled to
+ * width and height, with optional compositing with a background color.
+ */
+ public boolean drawImage (QtGraphics g, int x, int y, int width, int height,
+ Color bgcolor, ImageObserver observer)
+ {
+ if (addObserver(observer))
+ return false;
+
+ 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);
+
+ return true;
+ }
+
+ /**
+ * Draws an image with eventual scaling/transforming.
+ */
+ public boolean drawImage (QtGraphics 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 > width)
+ {
+ dstWidth = (int)((double)dstWidth*((double)width/(double)srcWidth));
+ srcWidth = width - srcX;
+ }
+
+ if (srcHeight > height)
+ {
+ dstHeight = (int)((double)dstHeight*((double)height/(double)srcHeight));
+ srcHeight = height - srcY;
+ }
+
+ if (srcWidth + srcX > width)
+ {
+ dstWidth = (int)((double)dstWidth * (double)(width - srcX)/(double)srcWidth);
+ srcWidth = width - srcX;
+ }
+
+ if (srcHeight + srcY > height)
+ {
+ dstHeight = (int)((double)dstHeight * (double)(width - srcY)/(double)srcHeight);
+ srcHeight = height - srcY;
+ }
+
+ if ( srcWidth <= 0 || srcHeight <= 0 || dstWidth <= 0 || dstHeight <= 0)
+ return true;
+
+ 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 native void copyArea(int x, int y, int width, int height,
+ int dx, int dy);
+
+ // Private methods ////////////////////////////////////////////////
+
+ /**
+ * Delivers notifications to all queued observers.
+ */
+ private void deliver()
+ {
+ int flags = ImageObserver.HEIGHT |
+ ImageObserver.WIDTH |
+ ImageObserver.PROPERTIES |
+ ImageObserver.ALLBITS;
+
+ if (observers != null)
+ for(int i=0; i < observers.size(); i++)
+ ((ImageObserver)observers.elementAt(i)).
+ imageUpdate(this, flags, 0, 0, width, height);
+
+ observers = null;
+ }
+
+ /**
+ * Adds an observer, if we need to.
+ * @return true if an observer was added.
+ */
+ private boolean addObserver(ImageObserver observer)
+ {
+ if (!isLoaded)
+ {
+ if(observer != null)
+ if (!observers.contains (observer))
+ observers.addElement (observer);
+ return true;
+ }
+ return false;
+ }
+
+ public String toString()
+ {
+ return "QtImage [isLoaded="+isLoaded+", width="+width+", height="+height
+ +"]";
+ }
+}
--- /dev/null
+/* QtImageConsumer.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., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 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.qt;
+
+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 QtImage. Sits and gathers pixels for a QtImage and then
+ * calls QtImage.setImage().
+ *
+ * @author Sven de Marothy
+ */
+public class QtImageConsumer implements ImageConsumer
+{
+ private QtImage target;
+ private int width, height;
+ private Hashtable properties;
+ private int[] pixelCache = null;
+ private ImageProducer source;
+
+ public QtImageConsumer(QtImage 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(QtImage.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;
+ }
+}
+
+
--- /dev/null
+/* QtImageDirectGraphics.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., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 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.qt;
+
+import java.awt.Color;
+import java.awt.GraphicsConfiguration;
+import java.awt.Graphics;
+import java.awt.Graphics2D;
+import java.awt.Image;
+import java.awt.Paint;
+import java.awt.Rectangle;
+import java.util.Stack;
+import java.awt.Shape;
+import java.awt.Stroke;
+import java.awt.font.FontRenderContext;
+import java.awt.font.GlyphVector;
+import java.awt.geom.AffineTransform;
+import java.awt.geom.PathIterator;
+import java.awt.geom.Arc2D;
+import java.awt.geom.Ellipse2D;
+import java.awt.geom.Line2D;
+import java.awt.geom.Rectangle2D;
+import java.awt.geom.RoundRectangle2D;
+import java.awt.image.BufferedImage;
+import java.awt.image.BufferedImageOp;
+import java.awt.image.ImageObserver;
+import java.awt.image.RenderedImage;
+import java.awt.image.renderable.RenderableImage;
+
+/**
+ * A QtImagePainter that does an update after every drawing op.
+ */
+public class QtImageDirectGraphics extends QtImageGraphics
+{
+ private QtComponentPeer peer;
+ private boolean modified;
+
+ public QtImageDirectGraphics(QtImage image, QtComponentPeer peer)
+ {
+ super( image );
+ this.peer = peer;
+ modified = false;
+ }
+
+ public QtImageDirectGraphics(QtImageGraphics g)
+ {
+ super( g );
+ }
+
+ private void scheduleUpdate()
+ {
+ }
+
+ public void dispose()
+ {
+ super.dispose();
+ peer.toolkit.sync();
+ peer.QtUpdate();
+ }
+
+ public void draw(Shape s)
+ {
+ super.draw(s);
+ scheduleUpdate();
+ }
+
+ public void fill(Shape s)
+ {
+ super.fill(s);
+ scheduleUpdate();
+ }
+
+ public void drawString(String string, int x, int y)
+ {
+ super.drawString( string, x, y );
+ scheduleUpdate();
+ }
+
+ public void drawString(String string, float x, float y)
+ {
+ super.drawString( string, x, y );
+ scheduleUpdate();
+ }
+
+ public void drawLine(int x1, int y1, int x2, int y2)
+ {
+ super.drawLine(x1, y1, x2, y2);
+ scheduleUpdate();
+ }
+
+ public boolean drawImage(Image image,
+ AffineTransform Tx,
+ ImageObserver obs)
+ {
+ boolean r = super.drawImage(image, Tx, obs);
+ scheduleUpdate();
+ return r;
+ }
+
+ public boolean drawImage(Image image, int x, int y, Color bgcolor,
+ ImageObserver observer)
+ {
+ boolean r = super.drawImage(image, x, y, bgcolor, observer);
+ scheduleUpdate();
+ return r;
+ }
+
+ public boolean drawImage(Image image,
+ int dx1, int dy1, int dx2, int dy2,
+ int sx1, int sy1, int sx2, int sy2,
+ Color bgcolor, ImageObserver observer)
+ {
+ boolean r = super.drawImage( image, dx1, dy1, dx2, dy2,
+ sx1, sy1, sx2, sy2,
+ bgcolor, observer);
+ scheduleUpdate();
+ return r;
+ }
+
+ public boolean drawImage(Image image, int x, int y,
+ int width, int height, Color bgcolor,
+ ImageObserver observer)
+ {
+ boolean r = super.drawImage(image, x, y, width, height, bgcolor,
+ observer);
+ scheduleUpdate();
+ return r;
+ }
+}
+
+
--- /dev/null
+/* QtImageGraphics.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., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 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.qt;
+
+import java.awt.Color;
+import java.awt.GraphicsConfiguration;
+import java.awt.Graphics;
+import java.awt.Graphics2D;
+import java.awt.Image;
+import java.awt.Paint;
+import java.awt.Rectangle;
+import java.util.Stack;
+
+/**
+ * QtComponentPainter is a Graphics2D context for painting to QtImage and
+ * QtVolatileImages.
+ */
+public class QtImageGraphics extends QtGraphics
+{
+ Image parentImage;
+ Stack owners;
+ QtImageGraphics topParent;
+
+ public QtImageGraphics(Image image)
+ {
+ if(!( image instanceof QtVolatileImage || image instanceof QtImage))
+ throw new IllegalArgumentException("Cannot create QtImageGraphics for a non-QImage context.");
+
+ owners = new Stack();
+ owners.push(this);
+ topParent = null;
+ int w, h;
+ if(image instanceof QtImage)
+ {
+ w = ((QtImage)image).width;
+ h = ((QtImage)image).height;
+ initImage((QtImage) image );
+ ((QtImage)image).putPainter( this );
+ }
+ else
+ {
+ w = ((QtVolatileImage)image).width;
+ h = ((QtVolatileImage)image).height;
+ initVolatileImage((QtVolatileImage) image );
+ ((QtVolatileImage)image).putPainter( this );
+ }
+
+ parentImage = image;
+ initialClip = new Rectangle( 0, 0, w, h );
+ setClip( initialClip );
+ setBackground(Color.white); // fixme
+ currentAlpha = 1.0;
+ setColor(Color.black);
+ setup();
+ }
+
+ /**
+ * Copying constructor
+ */
+ QtImageGraphics( QtImageGraphics g )
+ {
+ super( g );
+ parentImage = g.parentImage;
+ if(parentImage instanceof QtImage)
+ ((QtImage)parentImage).putPainter( this );
+ else
+ ((QtVolatileImage)parentImage).putPainter( this );
+ }
+
+ public void dispose()
+ {
+ delete();
+ if( parentImage instanceof QtImage )
+ ((QtImage)parentImage).removePainter( this );
+ else
+ ((QtVolatileImage)parentImage).removePainter( this );
+ }
+
+ /**
+ * Create a copy of this context.
+ */
+ public Graphics create()
+ {
+ return new QtImageGraphics( this );
+ }
+
+ /**
+ * Copy an area.
+ */
+ public void copyArea(int x, int y, int width, int height,
+ int dx, int dy)
+ {
+ if(parentImage instanceof QtImage)
+ ((QtImage)parentImage).copyArea(x, y, width, height, dx, dy);
+ else
+ ((QtVolatileImage)parentImage).copyArea(x, y, width, height, dx, dy);
+ }
+
+ /**
+ * Returns the GraphicsConfiguration of the context component.
+ */
+ public GraphicsConfiguration getDeviceConfiguration()
+ {
+ throw new UnsupportedOperationException("Not implemented yet");
+ }
+}
+
+
--- /dev/null
+/* QtLabelPeer.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., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 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.qt;
+
+import java.awt.Label;
+import java.awt.peer.LabelPeer;
+
+public class QtLabelPeer extends QtComponentPeer implements LabelPeer
+{
+ public QtLabelPeer( QtToolkit kit, Label owner )
+ {
+ super( kit, owner );
+ }
+
+ protected native void init();
+
+ protected void setup()
+ {
+ super.setup();
+ setText( ((Label)owner).getText() );
+ setAlignment( ((Label)owner).getAlignment() );
+ }
+
+ public native void setAlignment( int alignment );
+
+ public native void setText( String label );
+}
--- /dev/null
+/* QtListPeer.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., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 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.qt;
+
+import java.awt.Dimension;
+import java.awt.List;
+import java.awt.event.ActionEvent;
+import java.awt.event.ItemEvent;
+import java.awt.peer.ListPeer;
+
+public class QtListPeer extends QtComponentPeer implements ListPeer
+{
+ public QtListPeer( QtToolkit kit, List owner )
+ {
+ super( kit, owner );
+ }
+
+ public native void init();
+
+ protected void setup()
+ {
+ super.setup();
+ List o = (List)owner;
+ // Multiple selection
+ setMultipleMode(o.isMultipleMode());
+ // Add initial list items.
+ String[] items = o.getItems();
+ for (int i = 0; i < items.length; i++)
+ add(items[i], i);
+
+ // Initial selections.
+ int[] selected = o.getSelectedIndexes();
+ for (int i = 0; i < selected.length; i++)
+ select(selected[i]);
+
+ // If no initial selection, use 0.
+ if(selected.length == 0 && items.length > 0)
+ select( 0 );
+ }
+
+ private boolean ignoreNextSelect = false;
+
+ /**
+ * Called back when a row is selected. -1 if no row is selected.
+ */
+ private void fireChoice( int index )
+ {
+ ignoreNextSelect = true;
+ if( index == -1)
+ ((List)owner).deselect( ((List)owner).getSelectedIndex() );
+ else
+ {
+ ((List)owner).select( index );
+ ItemEvent e = new ItemEvent((List)owner,
+ ItemEvent.ITEM_STATE_CHANGED,
+ ""+index,
+ ItemEvent.SELECTED);
+ QtToolkit.eventQueue.postEvent(e);
+ }
+ }
+
+ /**
+ * Called back when an item is double-clicked.
+ */
+ private void itemDoubleClicked( int index, int modifiers )
+ {
+ ActionEvent e = new ActionEvent(owner,
+ ActionEvent.ACTION_PERFORMED,
+ ((List)owner).getItem( index ),
+ System.currentTimeMillis(),
+ modifiers);
+ QtToolkit.eventQueue.postEvent(e);
+ }
+
+ private native void select(int index, boolean selected);
+
+ // ************ Public methods *********************
+
+ public native void add(String item, int index);
+
+ public void addItem(String item, int index)
+ {
+ add(item, index);
+ }
+
+ public void clear()
+ {
+ removeAll();
+ }
+
+ /**
+ * Deletes items from the starting index to the ending index (inclusive).
+ */
+ public native void delItems(int start_index, int end_index);
+
+ public void deselect(int index)
+ {
+ if( ignoreNextSelect == true )
+ ignoreNextSelect = false;
+ else
+ select(index, false);
+ }
+
+ public native int[] getSelectedIndexes();
+
+ public native void makeVisible(int index);
+
+ public Dimension minimumSize(int s)
+ {
+ return getMinimumSize(s);
+ }
+
+ public Dimension preferredSize(int s)
+ {
+ return getPreferredSize(s);
+ }
+
+ public void removeAll()
+ {
+ delItems(0, ((List)owner).getItemCount() - 1);
+ }
+
+ public void select(int index)
+ {
+ if( ignoreNextSelect == true )
+ ignoreNextSelect = false;
+ else
+ select(index, true);
+ }
+
+ /**
+ * Sets multiple-selection mode.
+ * Note there's a bug in multiple selection in Qt 4.0.0, use 4.0.1.
+ */
+ public native void setMultipleMode(boolean multi);
+
+ public void setMultipleSelections(boolean multi)
+ {
+ setMultipleMode(multi);
+ }
+
+ public Dimension getPreferredSize(int s)
+ {
+ // FIXME
+ return getPreferredSize();
+ }
+
+ public Dimension getMinimumSize(int s)
+ {
+ // FIXME
+ return getMinimumSize();
+ }
+}
--- /dev/null
+/* QtMenuBarPeer.java -- Qt peer for a menu bar.
+ 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., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 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.qt;
+
+import java.awt.Menu;
+import java.awt.MenuBar;
+import java.awt.peer.MenuBarPeer;
+import java.util.Vector;
+
+public class QtMenuBarPeer extends QtMenuComponentPeer implements MenuBarPeer
+{
+ public QtMenuBarPeer( QtToolkit kit, MenuBar owner )
+ {
+ super( kit, owner );
+ }
+
+ protected native void init();
+
+ protected void setup()
+ {
+ }
+
+ /**
+ * Recurses the menubar adding menus (and menu items),
+ * called from the Frame peer.
+ */
+ void addMenus()
+ {
+ MenuBar o = (MenuBar)owner;
+ int help = (o.getHelpMenu() != null) ? 1 : 0;
+ for (int i = 0; i < o.getMenuCount() - help; i++)
+ addMenu( o.getMenu(i) );
+ if(o.getHelpMenu() != null)
+ addHelpMenu( o.getHelpMenu() );
+ }
+
+ private native void addMenu( QtMenuPeer mp );
+
+ private native void addHelpMenu( QtMenuPeer mp );
+
+ private native void delMenu( QtMenuPeer mp );
+
+ // ************ Public methods *********************
+
+ public void addMenu( Menu m )
+ {
+ if (m.getPeer() == null)
+ m.addNotify();
+ ((QtMenuPeer)m.getPeer()).addItems();
+ addMenu( (QtMenuPeer)m.getPeer() );
+ }
+
+ public void addHelpMenu( Menu m )
+ {
+ if (m.getPeer() == null)
+ m.addNotify();
+ ((QtMenuPeer)m.getPeer()).addItems();
+ addHelpMenu( (QtMenuPeer)m.getPeer() );
+ }
+
+ public void delMenu( int index )
+ {
+ Menu m = ((MenuBar)owner).getMenu( index );
+ if(m != null)
+ delMenu( (QtMenuPeer)m.getPeer() );
+ }
+}
+
--- /dev/null
+/* QtMenuComponentPeer.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., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 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.qt;
+
+import java.awt.Font;
+import java.awt.MenuComponent;
+import java.awt.peer.MenuComponentPeer;
+
+public class QtMenuComponentPeer extends NativeWrapper
+ implements MenuComponentPeer
+{
+ protected QtToolkit toolkit;
+ protected MenuComponent owner;
+
+ public QtMenuComponentPeer( QtToolkit kit, MenuComponent owner )
+ {
+ this.toolkit = kit;
+ this.owner = owner;
+ nativeObject = 0;
+ synchronized(this)
+ {
+ callInit(); // Calls the init method FROM THE MAIN THREAD.
+ try
+ {
+ wait(); // Wait for the thing to be created.
+ }
+ catch(InterruptedException e)
+ {
+ }
+ }
+ setup();
+ }
+
+ protected native void callInit();
+
+ protected void init()
+ {
+ }
+
+ protected void setup()
+ {
+ }
+
+ public void finalize()
+ {
+ dispose();
+ }
+
+ // ************ Public methods *********************
+
+ public native void dispose();
+
+ public void setFont(Font font)
+ {
+ // TODO Auto-generated method stub
+
+ }
+
+}
--- /dev/null
+/* QtMenuItemPeer.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., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 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.qt;
+
+import java.awt.Menu;
+import java.awt.MenuItem;
+import java.awt.CheckboxMenuItem;
+import java.awt.event.ActionEvent;
+import java.awt.peer.MenuItemPeer;
+import java.awt.peer.CheckboxMenuItemPeer;
+
+public class QtMenuItemPeer extends QtMenuComponentPeer
+ implements MenuItemPeer, CheckboxMenuItemPeer
+{
+ public QtMenuItemPeer( QtToolkit toolkit, MenuItem owner )
+ {
+ super(toolkit, owner);
+ }
+
+ protected void init()
+ {
+ String label = ((MenuItem)owner).getLabel();
+ create(label, label.equals("-"), (owner instanceof CheckboxMenuItem));
+ }
+
+ protected void setup()
+ {
+ }
+
+ private native void create(String label, boolean isSeperator, boolean isCheckable);
+
+ public void finalize()
+ {
+ dispose();
+ }
+
+ public native void dispose();
+
+ private void fireClick(int modifiers)
+ {
+ ActionEvent e = new ActionEvent(owner,
+ ActionEvent.ACTION_PERFORMED,
+ ((MenuItem)owner).getActionCommand(),
+ System.currentTimeMillis(),
+ (modifiers & 0x2FF));
+ QtToolkit.eventQueue.postEvent(e);
+ }
+
+ // ************ Public methods *********************
+
+ public void disable()
+ {
+ setEnabled(false);
+ }
+
+ public void enable()
+ {
+ setEnabled(true);
+ }
+
+ public native void setEnabled(boolean b);
+
+ public native void setLabel(String label);
+
+ public native void setState(boolean state);
+}
+
+
+
+
+
+
+
--- /dev/null
+/* QtMenuPeer.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., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 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.qt;
+
+import java.awt.Menu;
+import java.awt.MenuItem;
+import java.awt.PopupMenu;
+import java.awt.event.ActionEvent;
+import java.awt.peer.MenuPeer;
+import java.util.Vector;
+
+public class QtMenuPeer extends QtMenuComponentPeer implements MenuPeer
+{
+ Vector items;
+ boolean itemsAdded;
+
+ public QtMenuPeer( QtToolkit kit, Menu owner )
+ {
+ super( kit, owner );
+ itemsAdded = false;
+ }
+
+ protected native void init();
+
+ protected void setup()
+ {
+ items = new Vector();
+ setLabel( ((Menu)owner).getLabel() );
+ if( ((Menu)owner).isTearOff() )
+ allowTearOff();
+ }
+
+ // Recurse the menu tree adding items,
+ // called from the MenuBar addMenus() method, called from the Frame peer.
+ void addItems()
+ {
+ if(!itemsAdded)
+ {
+ Menu o = (Menu)owner;
+ for( int i=0; i < o.getItemCount(); i++ )
+ {
+ MenuItem ci = (MenuItem)o.getItem(i);
+ if (ci instanceof Menu && ci.getPeer() != null)
+ ((QtMenuPeer)ci.getPeer()).addItems();
+ addItem( ci );
+ }
+ itemsAdded = true;
+ }
+ }
+
+ private void fireClick()
+ {
+ ActionEvent e = new ActionEvent(owner,
+ ActionEvent.ACTION_PERFORMED,
+ ((Menu)owner).getActionCommand());
+ QtToolkit.eventQueue.postEvent(e);
+ }
+
+ private native void allowTearOff();
+
+ private native void insertSeperator();
+
+ private native void insertItem(QtMenuItemPeer p);
+
+ private native void insertMenu(QtMenuPeer menu);
+
+ private native void delItem(long ptr);
+
+ private void add(long ptr)
+ {
+ items.add(new Long(ptr));
+ }
+
+ // ************ Public methods *********************
+
+ public void addItem( MenuItem item )
+ {
+ if( item instanceof Menu || item instanceof PopupMenu)
+ insertMenu((QtMenuPeer)item.getPeer());
+ else
+ {
+ QtMenuItemPeer p = (QtMenuItemPeer)item.getPeer();
+ insertItem(p);
+ }
+ }
+
+ public void addSeparator()
+ {
+ insertSeperator();
+ }
+
+ public void delItem( int index )
+ {
+ long ptr = ((Long)items.elementAt(index)).longValue();
+ delItem(ptr);
+ items.removeElementAt(index);
+ }
+
+ // Inherited methods..
+
+ public void disable()
+ {
+ setEnabled(false);
+ }
+
+ public void enable()
+ {
+ setEnabled(true);
+ }
+
+ public native void setEnabled(boolean enabled);
+
+ public native void setLabel(String text);
+}
+
+
+
--- /dev/null
+/* QtPanelPeer.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., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 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.qt;
+
+import java.awt.Component;
+import java.awt.peer.PanelPeer;
+
+public class QtPanelPeer extends QtContainerPeer implements PanelPeer
+{
+ public QtPanelPeer( QtToolkit kit, Component owner )
+ {
+ super( kit, owner );
+ }
+
+ protected native void init();
+
+ protected void setup()
+ {
+ super.setup();
+ }
+}
--- /dev/null
+/* QtPopupMenuPeer.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., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 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.qt;
+
+import java.awt.Component;
+import java.awt.Menu;
+import java.awt.MenuItem;
+import java.awt.Point;
+import java.awt.PopupMenu;
+import java.awt.Event;
+import java.awt.event.ActionEvent;
+import java.awt.peer.PopupMenuPeer;
+
+public class QtPopupMenuPeer extends QtMenuPeer implements PopupMenuPeer
+{
+ public QtPopupMenuPeer( QtToolkit kit, PopupMenu owner )
+ {
+ super( kit, owner );
+ }
+
+ private native void showNative(int x, int y);
+
+ // ************ Public methods *********************
+
+ /**
+ * Part of the older API, replaced by event version instead.
+ */
+ public void show (Component origin, int x, int y)
+ {
+ if( origin == null )
+ throw new NullPointerException("Null parent component.");
+ addItems();
+
+ Point p = origin.getLocationOnScreen();
+ showNative( (int)p.getX() + x, (int)p.getY() + y );
+ }
+
+ public void show (Event e)
+ {
+ if (!(e.target instanceof Component))
+ throw new IllegalArgumentException("Expecting a component Event target!");
+ show((Component)e.target, e.x, e.y);
+ }
+}
+
+
+
--- /dev/null
+/* QtRepaintThread.java -- Repaint thread implementation
+ 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., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 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.qt;
+
+/**
+ * This class does repainting of Component back-buffers. It is undesirable to
+ * do this directly from the paint callback in QtComponentPeer, because that
+ * is executed from the main thread. Thus, if a call is made at the same time
+ * which requires execution by the main thread, and this is sharing a lock with
+ * paint(), then a deadlock will occur, which must be avoided. In general,
+ * the main Qt thread should avoid calling into java code as far as possible.
+ *
+ */
+public class QtRepaintThread extends Thread
+{
+ static class RepaintComponent
+ {
+ public QtComponentPeer curr;
+ public RepaintComponent next;
+ public boolean paintAll;
+ public int x, y, w, h;
+
+ public RepaintComponent(QtComponentPeer p)
+ {
+ curr = p;
+ next = null;
+ paintAll = true;
+ }
+
+ public RepaintComponent(QtComponentPeer p, int x, int y, int w, int h)
+ {
+ this(p);
+ paintAll = false;
+ this.x = x;
+ this.y = y;
+ this.w = w;
+ this.h = h;
+ }
+ }
+
+ RepaintComponent component;
+ boolean busy;
+
+ public QtRepaintThread()
+ {
+ component = null;
+ }
+
+ public void run()
+ {
+ while( true )
+ {
+ try
+ {
+ busy = false;
+ // Wait for a repaint
+ sleep(100);
+ busy = true;
+ }
+ catch (InterruptedException ie)
+ {
+ while( component != null )
+ {
+ try
+ {
+ if( component.paintAll )
+ {
+ // update the back-buffer.
+ component.curr.paintBackBuffer();
+ component.curr.QtUpdate(); // trigger a native repaint event
+ }
+ else
+ {
+ component.curr.paintBackBuffer(component.x, component.y,
+ component.w, component.h);
+ component.curr.QtUpdateArea(component.x, component.y,
+ component.w, component.h);
+ }
+ }
+ catch (InterruptedException e)
+ {
+ }
+ component = component.next;
+ }
+ }
+ }
+ }
+
+ /**
+ * Enqueue a component for repainting.
+ */
+ public synchronized void queueComponent(QtComponentPeer p)
+ {
+ if( component == null )
+ component = new RepaintComponent(p);
+ else
+ {
+ RepaintComponent r = component;
+ while( r.next != null ) r = r.next;
+ r.next = new RepaintComponent(p);
+ }
+ interrupt();
+ }
+
+ /**
+ * Enqueue a component for repainting.
+ */
+ public synchronized void queueComponent(QtComponentPeer p, int x, int y,
+ int w, int h)
+ {
+ if( component == null )
+ component = new RepaintComponent(p, x, y, w, h);
+ else
+ {
+ RepaintComponent r = component;
+ while( r.next != null ) r = r.next;
+ r.next = new RepaintComponent(p, x, y, w, h);
+ }
+ interrupt();
+ }
+}
--- /dev/null
+/* QtScreenDevice.java -- Wrapper on a Qt screen Widget
+ 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., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 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.qt;
+
+import java.awt.GraphicsConfiguration;
+import java.awt.GraphicsDevice;
+import java.awt.DisplayMode;
+import java.awt.GraphicsConfigTemplate;
+import java.awt.Rectangle;
+import java.awt.Window;
+
+public class QtScreenDevice extends GraphicsDevice
+{
+ private long nativeObject;
+ private int id;
+ private String IDstring;
+ QtScreenDeviceConfiguration config;
+
+ public QtScreenDevice(int id)
+ {
+ this.id = id;
+ IDstring = "QtScreen" + id;
+ init( id );
+ config = new QtScreenDeviceConfiguration(this);
+ }
+
+ public native void init( int id );
+ public native void dispose();
+
+ // Package-private methods used by QtScreenDeviceConfiguration
+ native Rectangle getBounds();
+ native int getDpiX();
+ native int getDpiY();
+ native int depth();
+
+ // ****************** Public methods ***********************
+
+ public GraphicsConfiguration getBestConfiguration(GraphicsConfigTemplate gct)
+ {
+ return config;
+ }
+
+ public GraphicsConfiguration[] getConfigurations()
+ {
+ return new GraphicsConfiguration[]{ config };
+ }
+
+ public GraphicsConfiguration getDefaultConfiguration()
+ {
+ return config;
+ }
+
+ public String getIDstring()
+ {
+ return IDstring;
+ }
+
+ public int getType()
+ {
+ return TYPE_RASTER_SCREEN;
+ }
+
+ public boolean isDisplayChangeSupported()
+ {
+ return false;
+ }
+
+ public boolean isFullScreenSupported()
+ {
+ return false;
+ }
+
+ public void setDisplayMode(DisplayMode dm)
+ {
+ }
+
+ public void setFullScreenWindow(Window w)
+ {
+ }
+}
+
--- /dev/null
+/* QtScreenDeviceConfiguration.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., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 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.qt;
+
+import java.awt.DisplayMode;
+import java.awt.ImageCapabilities;
+import java.awt.GraphicsConfiguration;
+import java.awt.GraphicsDevice;
+import java.awt.GraphicsConfigTemplate;
+import java.awt.Rectangle;
+import java.awt.image.BufferedImage;
+import java.awt.image.ColorModel;
+import java.awt.image.VolatileImage;
+import java.awt.geom.AffineTransform;
+
+public class QtScreenDeviceConfiguration extends GraphicsConfiguration {
+
+ private QtScreenDevice owner;
+ private Rectangle bounds;
+ private double dpiX, dpiY;
+ private int depth;
+
+ public QtScreenDeviceConfiguration(QtScreenDevice owner)
+ {
+ this.owner = owner;
+ bounds = owner.getBounds();
+ dpiX = owner.getDpiX();
+ dpiY = owner.getDpiY();
+ depth = owner.depth();
+ }
+
+ public BufferedImage createCompatibleImage(int width, int height)
+ {
+ switch( depth )
+ {
+ case 24:
+ return new BufferedImage(width, height, BufferedImage.TYPE_3BYTE_BGR);
+ case 16:
+ return new BufferedImage(width, height,
+ BufferedImage.TYPE_USHORT_565_RGB);
+ case 8:
+ return new BufferedImage(width, height, BufferedImage.TYPE_BYTE_INDEXED);
+ default:
+ case 32:
+ return new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB);
+ }
+ }
+
+ public BufferedImage createCompatibleImage(int width, int height, int transparency)
+ {
+ // FIXME: Take the transpareny flag into account?
+ // For now, ignore it and just use an alpha channel.
+ if(depth == 32)
+ return new BufferedImage(width, height, BufferedImage.TYPE_INT_ARGB);
+ return createCompatibleImage(width, height);
+ }
+
+ public VolatileImage createCompatibleVolatileImage(int width, int height)
+ {
+ return new QtVolatileImage( width, height );
+ }
+
+ public VolatileImage createCompatibleVolatileImage(int width, int height,
+ ImageCapabilities caps)
+ {
+ return createCompatibleVolatileImage( width, height );
+ }
+
+ public Rectangle getBounds()
+ {
+ return bounds;
+ }
+
+ public ColorModel getColorModel()
+ {
+ // FIXME?
+ return QtToolkit.getDefaultToolkit().getColorModel();
+ }
+
+ public ColorModel getColorModel(int transparency)
+ {
+ // FIXME?
+ return QtToolkit.getDefaultToolkit().getColorModel();
+ }
+
+ public AffineTransform getDefaultTransform()
+ {
+ return new AffineTransform();
+ }
+
+ public GraphicsDevice getDevice()
+ {
+ return owner;
+ }
+
+ /**
+ * Returns the transform which transforms from this display's resolution
+ * to a 72 DPI resolution.
+ */
+ public AffineTransform getNormalizingTransform()
+ {
+ AffineTransform nTrans = new AffineTransform();
+ nTrans.scale( 72.0 / dpiX, 72.0 / dpiY );
+ return nTrans;
+ }
+
+ public VolatileImage createCompatibleVolatileImage(int width, int height,
+ int transparency)
+ {
+ return createCompatibleVolatileImage(width, height);
+ }
+}
--- /dev/null
+/* QtScrollPanePeer.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., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 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.qt;
+
+import java.awt.Adjustable;
+import java.awt.Dimension;
+import java.awt.Insets;
+import java.awt.ScrollPane;
+import java.awt.peer.ScrollPanePeer;
+
+public class QtScrollPanePeer extends QtContainerPeer implements ScrollPanePeer
+{
+ public QtScrollPanePeer( QtToolkit kit, ScrollPane owner )
+ {
+ super( kit, owner );
+ }
+
+ protected native void init();
+
+ protected void setup()
+ {
+ super.setup();
+ setPolicy( ((ScrollPane)owner).getScrollbarDisplayPolicy() );
+ }
+
+ private native void setPolicy(int policy);
+
+ // ************ Public methods *********************
+
+ public native void childResized(int width, int height);
+
+ public native int getHScrollbarHeight();
+
+ public native int getVScrollbarWidth();
+
+ public native void setScrollPosition(int x, int y);
+
+ public Insets getInsets()
+ {
+ // FIXME : more accurate?
+ return new Insets(5 + getHScrollbarHeight(), // Top
+ 5 + getVScrollbarWidth(), // Left
+ 5, // Bottom
+ 5); // Right
+ }
+
+ public void setUnitIncrement(Adjustable item, int inc)
+ {
+ // FIXME
+ }
+
+ public void setValue(Adjustable item, int value)
+ {
+ // FIXME
+ }
+}
--- /dev/null
+/* QtScrollbarPeer.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., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 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.qt;
+
+import java.awt.Scrollbar;
+import java.awt.event.AdjustmentEvent;
+import java.awt.peer.ScrollbarPeer;
+
+public class QtScrollbarPeer extends QtComponentPeer implements ScrollbarPeer
+{
+ public QtScrollbarPeer( QtToolkit kit, Scrollbar owner )
+ {
+ super( kit, owner );
+ }
+
+ public native void init();
+
+ protected void setup()
+ {
+ super.setup();
+ Scrollbar o = (Scrollbar)owner;
+ setValues(o.getValue(), o.getVisible(), o.getMinimum(), o.getMaximum());
+ setOrientation(o.getOrientation());
+ setLineIncrement(o.getLineIncrement());
+ setPageIncrement(o.getPageIncrement());
+ }
+
+ private native void setOrientation(int orientation);
+
+ private void fireMoved(int type, int value)
+ {
+ AdjustmentEvent e = new AdjustmentEvent((Scrollbar)owner,
+ AdjustmentEvent.ADJUSTMENT_VALUE_CHANGED,
+ type, value);
+ QtToolkit.eventQueue.postEvent(e);
+ }
+
+ // ************ Public methods *********************
+
+ public native void setLineIncrement(int inc);
+
+ public native void setPageIncrement(int inc);
+
+ public native void setValues(int value, int visible, int min, int max);
+}
--- /dev/null
+/* QtTextAreaPeer.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., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 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.qt;
+
+import java.awt.Dimension;
+import java.awt.Rectangle;
+import java.awt.TextArea;
+import java.awt.event.TextEvent;
+import java.awt.im.InputMethodRequests;
+import java.awt.peer.TextAreaPeer;
+
+public class QtTextAreaPeer extends QtComponentPeer implements TextAreaPeer
+{
+ public QtTextAreaPeer( QtToolkit kit, TextArea owner )
+ {
+ super( kit, owner );
+ }
+
+ protected native void init();
+
+ protected void setup()
+ {
+ super.setup();
+ setText(((TextArea)owner).getText());
+ setEditable(((TextArea)owner).isEditable());
+ }
+
+ /**
+ * Returns the start (start = true) or end (start = false) of the selection.
+ */
+ private native int getSelection(boolean start);
+
+ /**
+ * Called back on a text edit.
+ */
+ private void textChanged()
+ {
+ TextEvent e = new TextEvent(owner, TextEvent.TEXT_VALUE_CHANGED);
+ QtToolkit.eventQueue.postEvent(e);
+ }
+
+ // ************ Public methods *********************
+
+ public long filterEvents(long filter)
+ {
+ return filter;
+ }
+
+ public native int getCaretPosition();
+
+ public Rectangle getCharacterBounds(int pos)
+ {
+ // FIXME
+ return new Rectangle(0,0,0,0);
+ }
+
+ /**
+ * Implemented, but who uses it?
+ */
+ public native int getIndexAtPoint(int x, int y);
+
+// public void reshape(int x, int y,
+// int width, int height)
+// {
+// if(width != 0 || height != 0)
+// super.reshape(x, y, width, height);
+// else
+// super.reshape(x, y, 10, 10);
+// }
+
+ public Dimension getMinimumSize(int rows, int cols)
+ {
+ // FIXME
+ return getMinimumSize();
+ }
+
+ public Dimension getPreferredSize(int rows, int cols)
+ {
+ // FIXME
+ return getPreferredSize();
+ }
+
+ public int getSelectionEnd()
+ {
+ return getSelection(false);
+ }
+
+ public int getSelectionStart()
+ {
+ return getSelection(true);
+ }
+
+ public native String getText();
+
+ public void insert(String text, int pos)
+ {
+ // Not very efficient, no.
+ String s = getText();
+ setText(s.substring(0, pos) + text + s.substring(pos));
+ }
+
+ public void insertText(String text, int pos)
+ {
+ insert(text, pos);
+ }
+
+ public Dimension minimumSize(int rows, int cols)
+ {
+ return getMinimumSize(rows, cols);
+ }
+
+ public Dimension preferredSize(int rows, int cols)
+ {
+ return getPreferredSize(rows, cols);
+ }
+
+ public void replaceRange(String insert, int start_pos, int end_pos)
+ {
+ // Not very efficient, no.
+ String text = getText();
+ String right = text.substring(0, start_pos);
+ String left = text.substring(end_pos);
+ setText(right + insert + left);
+ }
+
+ public void replaceText(String text, int start_pos, int end_pos)
+ {
+ replaceRange(text, start_pos, end_pos);
+ }
+
+ public native void setText(String text);
+
+ public native void select(int start_pos, int end_pos);
+
+ public native void setEditable(boolean editable);
+
+ public native void setCaretPosition(int pos);
+
+ public InputMethodRequests getInputMethodRequests()
+ {
+ // TODO Auto-generated method stub
+ return null;
+ }
+}
+
--- /dev/null
+/* QtTextFieldPeer.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., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 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.qt;
+
+import java.awt.Dimension;
+import java.awt.Rectangle;
+import java.awt.TextField;
+import java.awt.event.TextEvent;
+import java.awt.im.InputMethodRequests;
+import java.awt.peer.TextFieldPeer;
+
+public class QtTextFieldPeer extends QtComponentPeer implements TextFieldPeer
+{
+ public QtTextFieldPeer( QtToolkit kit, TextField owner )
+ {
+ super( kit, owner );
+ }
+
+ protected native void init();
+
+ protected void setup()
+ {
+ super.setup();
+ setText(((TextField)owner).getText());
+ setEditable(((TextField)owner).isEditable());
+ }
+
+ /**
+ * Called back on a text edit.
+ */
+ private void textChanged()
+ {
+ TextEvent e = new TextEvent(owner, TextEvent.TEXT_VALUE_CHANGED);
+ QtToolkit.eventQueue.postEvent(e);
+ }
+
+ /**
+ * Returns the start (start = true) or end (start = false) of the selection.
+ */
+ private native int getSelection(boolean start);
+
+ private native Dimension getMinimumSizeNative(int columns);
+
+ private native Dimension getPreferredSizeNative(int columns);
+
+ // ************ Public methods *********************
+
+ public long filterEvents(long e)
+ {
+ return e;
+ }
+
+ public native int getCaretPosition();
+
+ public Rectangle getCharacterBounds(int i)
+ {
+ return new Rectangle(0,0,0,0);
+ }
+
+ public int getIndexAtPoint(int x, int y)
+ {
+ // FIXME
+ return 0;
+ }
+
+ public Dimension getMinimumSize(int columns)
+ {
+ Dimension d = getMinimumSizeNative( columns );
+ if ( d == null )
+ return new Dimension(10, 10);
+ return d;
+ }
+
+ public Dimension getPreferredSize(int columns)
+ {
+ Dimension d = getPreferredSizeNative( columns );
+ if ( d == null )
+ return owner.getSize();
+ return d;
+ }
+
+ public int getSelectionEnd()
+ {
+ return getSelection(false);
+ }
+
+ public int getSelectionStart()
+ {
+ return getSelection(true);
+ }
+
+ public native String getText();
+
+ public Dimension minimumSize(int cols)
+ {
+ return getMinimumSize(cols);
+ }
+
+ public Dimension preferredSize(int cols)
+ {
+ return getPreferredSize(cols);
+ }
+
+ public native void select(int selStart, int selEnd);
+
+ public native void setCaretPosition(int pos);
+
+ public void setEchoCharacter(char c)
+ {
+ setEchoChar(c);
+ }
+
+ public native void setEchoChar(char echoChar);
+
+ public native void setEditable(boolean editable);
+
+ public native void setText(String l);
+
+ public InputMethodRequests getInputMethodRequests()
+ {
+ // TODO Auto-generated method stub
+ return null;
+ }
+}
+
--- /dev/null
+/* QtToolkit.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., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 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.qt;
+
+import gnu.java.awt.EmbeddedWindow;
+import gnu.java.awt.peer.ClasspathFontPeer;
+import gnu.java.awt.peer.EmbeddedWindowPeer;
+import gnu.java.awt.peer.ClasspathTextLayoutPeer;
+import java.awt.AWTEvent;
+import java.awt.AWTException;
+import java.awt.Button;
+import java.awt.Canvas;
+import java.awt.Checkbox;
+import java.awt.CheckboxMenuItem;
+import java.awt.Choice;
+import java.awt.Component;
+import java.awt.Dialog;
+import java.awt.Dimension;
+import java.awt.EventQueue;
+import java.awt.Font;
+import java.awt.FontMetrics;
+import java.awt.Frame;
+import java.awt.Image;
+import java.awt.Label;
+import java.awt.List;
+import java.awt.MenuBar;
+import java.awt.Menu;
+import java.awt.MenuItem;
+import java.awt.Panel;
+import java.awt.TextArea;
+import java.awt.TextField;
+import java.awt.FileDialog;
+import java.awt.GraphicsDevice;
+import java.awt.GraphicsEnvironment;
+import java.awt.HeadlessException;
+import java.awt.PopupMenu;
+import java.awt.PrintJob;
+import java.awt.Scrollbar;
+import java.awt.ScrollPane;
+import java.awt.Toolkit;
+import java.awt.Window;
+import java.awt.datatransfer.Clipboard;
+import java.awt.dnd.DragGestureEvent;
+import java.awt.dnd.DragGestureListener;
+import java.awt.dnd.DragGestureRecognizer;
+import java.awt.dnd.DragSource;
+import java.awt.dnd.peer.DragSourceContextPeer;
+import java.awt.event.AWTEventListener;
+import java.awt.image.ColorModel;
+import java.awt.image.DirectColorModel;
+import java.awt.image.ImageObserver;
+import java.awt.image.ImageProducer;
+import java.awt.im.InputMethodHighlight;
+import java.awt.peer.ButtonPeer;
+import java.awt.peer.FontPeer;
+import java.awt.peer.PanelPeer;
+import java.awt.peer.CanvasPeer;
+import java.awt.peer.FramePeer;
+import java.awt.peer.PopupMenuPeer;
+import java.awt.peer.CheckboxMenuItemPeer;
+import java.awt.peer.LabelPeer;
+import java.awt.peer.RobotPeer;
+import java.awt.peer.CheckboxPeer;
+import java.awt.peer.LightweightPeer;
+import java.awt.peer.ScrollPanePeer;
+import java.awt.peer.ChoicePeer;
+import java.awt.peer.ListPeer;
+import java.awt.peer.ScrollbarPeer;
+import java.awt.peer.ComponentPeer;
+import java.awt.peer.MenuBarPeer;
+import java.awt.peer.TextAreaPeer;
+import java.awt.peer.ContainerPeer;
+import java.awt.peer.MenuComponentPeer;
+import java.awt.peer.TextComponentPeer;
+import java.awt.peer.DialogPeer;
+import java.awt.peer.MenuItemPeer;
+import java.awt.peer.TextFieldPeer;
+import java.awt.peer.FileDialogPeer;
+import java.awt.peer.MenuPeer;
+import java.awt.peer.WindowPeer;
+import java.awt.font.FontRenderContext;
+import java.io.InputStream;
+import java.net.URL;
+import java.text.AttributedString;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Properties;
+import javax.imageio.spi.IIORegistry;
+
+import gnu.java.awt.ClasspathToolkit;
+
+public class QtToolkit extends ClasspathToolkit
+{
+ public static EventQueue eventQueue = null; // the native event queue
+ public static QtRepaintThread repaintThread = null;
+ public static MainQtThread guiThread = null;
+ public static QtGraphicsEnvironment graphicsEnv = null;
+
+ private static void initToolkit()
+ {
+ eventQueue = new EventQueue();
+ repaintThread = new QtRepaintThread();
+ System.loadLibrary("qtpeer");
+
+ String theme = null;
+ try
+ {
+ String style = System.getProperty("qtoptions.style");
+ if(style != null)
+ theme = style;
+ }
+ catch(SecurityException e)
+ {
+ }
+ catch(IllegalArgumentException e)
+ {
+ }
+
+ boolean doublebuffer = true;
+ try
+ {
+ String style = System.getProperty("qtoptions.nodoublebuffer");
+ if(style != null)
+ doublebuffer = false;
+ }
+ catch(SecurityException e)
+ {
+ }
+ catch(IllegalArgumentException e)
+ {
+ }
+
+ guiThread = new MainQtThread( theme, doublebuffer );
+ guiThread.start();
+ repaintThread.start();
+ }
+
+ /**
+ * Construct the toolkit!
+ */
+ public QtToolkit()
+ {
+ if( guiThread == null )
+ initToolkit();
+
+ while (!guiThread.isRunning()); // make sure the GUI thread has started.
+
+ if( graphicsEnv == null )
+ graphicsEnv = new QtGraphicsEnvironment( this );
+ }
+
+ native String[] nativeFontFamilies();
+
+ native int numScreens();
+
+ native int defaultScreen();
+
+ // ************ Public methods *********************
+
+ public synchronized native void beep();
+
+ public int checkImage(Image image, int w, int h, ImageObserver observer)
+ {
+ if(image instanceof QtImage)
+ return ((QtImage)image).checkImage(observer);
+
+ return ImageObserver.ERROR; // FIXME
+ }
+
+ protected ButtonPeer createButton( Button target )
+ {
+ return new QtButtonPeer( this, target );
+ }
+
+ protected CanvasPeer createCanvas(Canvas target)
+ {
+ return new QtCanvasPeer( this, target );
+ }
+
+ protected CheckboxPeer createCheckbox(Checkbox target)
+ {
+ return new QtCheckboxPeer( this, target );
+ }
+
+ protected ChoicePeer createChoice(Choice target)
+ {
+ return new QtChoicePeer( this, target );
+ }
+
+ protected CheckboxMenuItemPeer createCheckboxMenuItem(CheckboxMenuItem target)
+ {
+ return new QtMenuItemPeer( this, target );
+ }
+
+ public DragSourceContextPeer createDragSourceContextPeer(DragGestureEvent dge)
+ {
+ throw new RuntimeException("Not implemented");
+ }
+
+ protected FramePeer createFrame(Frame target)
+ {
+ return new QtFramePeer( this, target );
+ }
+
+ protected FileDialogPeer createFileDialog(FileDialog target)
+ {
+ return new QtFileDialogPeer( this, target );
+ }
+
+ public Image createImage(ImageProducer producer)
+ {
+ return new QtImage( producer );
+ }
+
+ public Image createImage(byte[] imageData,
+ int imageOffset,
+ int imageLength)
+ {
+ byte[] dataCopy = new byte[imageLength];
+ System.arraycopy(imageData, imageOffset, dataCopy, 0, imageLength);
+ return new QtImage( dataCopy );
+ }
+
+ public Image createImage(String filename)
+ {
+ return new QtImage( filename );
+ }
+
+ public Image createImage(URL url)
+ {
+ return new QtImage( url );
+ }
+
+ protected TextFieldPeer createTextField(TextField target)
+ {
+ return new QtTextFieldPeer(this,target);
+ }
+
+ protected LabelPeer createLabel(Label target)
+ {
+ return new QtLabelPeer( this, target );
+ }
+
+ protected ListPeer createList(List target)
+ {
+ return new QtListPeer( this, target );
+ }
+
+ protected ScrollbarPeer createScrollbar(Scrollbar target)
+ {
+ return new QtScrollbarPeer( this, target );
+ }
+
+ protected ScrollPanePeer createScrollPane(ScrollPane target)
+ {
+ return new QtScrollPanePeer( this, target );
+ }
+
+ protected TextAreaPeer createTextArea(TextArea target)
+ {
+ return new QtTextAreaPeer( this, target );
+ }
+
+ protected PanelPeer createPanel(Panel target)
+ {
+ return new QtPanelPeer( this, target);
+ }
+
+ protected WindowPeer createWindow(Window target)
+ {
+ return new QtWindowPeer( this, target );
+ }
+
+ protected DialogPeer createDialog(Dialog target)
+ {
+ return new QtDialogPeer( this, target );
+ }
+
+ protected MenuBarPeer createMenuBar(MenuBar target)
+ {
+ return new QtMenuBarPeer( this, target );
+ }
+
+ protected MenuPeer createMenu(Menu target)
+ {
+ return new QtMenuPeer( this, target );
+ }
+
+ protected PopupMenuPeer createPopupMenu(PopupMenu target)
+ {
+ return new QtPopupMenuPeer( this, target );
+ }
+
+ protected MenuItemPeer createMenuItem(MenuItem target)
+ {
+ return new QtMenuItemPeer( this, target );
+ }
+
+ /**
+ * @since 1.4
+ */
+ public AWTEventListener[] getAWTEventListeners()
+ {
+ return null; // FIXME
+ }
+
+ /**
+ * @since 1.4
+ */
+ public AWTEventListener[] getAWTEventListeners(long mask)
+ {
+ return null; // FIXME
+ }
+
+ public ColorModel getColorModel()
+ {
+ return new DirectColorModel(32,
+ 0x00FF0000,
+ 0x0000FF00,
+ 0x000000FF,
+ 0xFF000000);
+ }
+
+ /**
+ * Just return the defaults.
+ */
+ public String[] getFontList()
+ {
+ String[] builtIn = new String[] { "Dialog",
+ "DialogInput",
+ "Monospaced",
+ "Serif",
+ "SansSerif" };
+ String[] nat = nativeFontFamilies();
+ String[] allFonts = new String[ nat.length + 5 ];
+ System.arraycopy(builtIn, 0, allFonts, 0, 5);
+ System.arraycopy(nat, 0, allFonts, 5, nat.length);
+ return allFonts;
+ }
+
+ public FontMetrics getFontMetrics(Font font)
+ {
+ return new QtFontMetrics(font);
+ }
+
+ protected FontPeer getFontPeer(String name,
+ int style)
+ {
+ Map attrs = new HashMap ();
+ ClasspathFontPeer.copyStyleToAttrs(style, attrs);
+ ClasspathFontPeer.copySizeToAttrs(12, attrs); // Default size is 12.
+ return getClasspathFontPeer (name, attrs);
+ }
+
+ public Image getImage(String filename)
+ {
+ return new QtImage(filename);
+ }
+
+ public Image getImage(URL url)
+ {
+ return createImage( url );
+ }
+
+ public PrintJob getPrintJob(Frame frame,
+ String jobtitle,
+ Properties props)
+ {
+ throw new RuntimeException("Not implemented");
+ }
+
+ public Clipboard getSystemClipboard()
+ {
+ throw new RuntimeException("Not implemented");
+ }
+
+ protected EventQueue getSystemEventQueueImpl()
+ {
+ return eventQueue;
+ }
+
+ public native Dimension getScreenSize();
+
+ public native int getScreenResolution();
+
+ public Map mapInputMethodHighlight(InputMethodHighlight highlight)
+ {
+ return null; // FIXME
+ }
+
+ public boolean prepareImage(Image image, int w, int h, ImageObserver observer)
+ {
+ if(image instanceof QtImage)
+ return true;
+ return false; // FIXME?
+ }
+
+ public native void sync();
+
+ // ********************** ClasspathToolkit methods
+
+ public GraphicsEnvironment getLocalGraphicsEnvironment()
+ {
+ return graphicsEnv;
+ }
+
+ public ClasspathFontPeer getClasspathFontPeer (String name, Map attrs)
+ {
+ return new QtFontPeer (name, attrs);
+ }
+
+ public ClasspathTextLayoutPeer getClasspathTextLayoutPeer(AttributedString str,
+ FontRenderContext frc)
+ {
+ return null;
+ }
+
+ // FIXME
+ public Font createFont(int format, InputStream stream)
+ {
+ throw new UnsupportedOperationException();
+ }
+
+ // FIXME
+ public RobotPeer createRobot (GraphicsDevice screen) throws AWTException
+ {
+ throw new UnsupportedOperationException();
+ }
+
+ public EmbeddedWindowPeer createEmbeddedWindow(EmbeddedWindow w)
+ {
+ // return new QtEmbeddedWindowPeer( this, w );
+ return null;
+ }
+}
--- /dev/null
+/* QtVolatileImage.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., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 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.qt;
+
+import java.awt.Graphics;
+import java.awt.Graphics2D;
+import java.awt.Color;
+import java.awt.Image;
+import java.awt.ImageCapabilities;
+import java.awt.GraphicsConfiguration;
+import java.awt.image.BufferedImage;
+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.awt.image.VolatileImage;
+import java.io.File;
+import java.io.IOException;
+import java.util.Hashtable;
+import java.util.WeakHashMap;
+import java.util.Vector;
+
+/**
+ * QtVolatileImage - wraps a QImage
+ *
+ */
+public class QtVolatileImage extends VolatileImage
+{
+ int width = -1, height = -1;
+
+ /**
+ * Properties.
+ */
+ Hashtable props;
+
+ /**
+ * Pointer to the QImage
+ */
+ long nativeObject;
+
+ /*
+ * The 32-bit AARRGGBB format the uses.
+ */
+ static ColorModel nativeModel = new DirectColorModel(32,
+ 0x00FF0000,
+ 0x0000FF00,
+ 0x000000FF,
+ 0xFF000000);
+
+ /**
+ * Clears the image to RGBA 0
+ */
+ public native void clear();
+
+ /**
+ * Returns a copy of the pixel data as a java array.
+ */
+ private native int[] getPixels();
+
+ /**
+ * Allocates a QImage
+ */
+ private native void createImage();
+
+ /**
+ * HashMap of Graphics objects painting on this Image.
+ */
+ WeakHashMap painters;
+
+ /**
+ * Flags if this image is to be destroyed.
+ */
+ boolean killFlag;
+
+ /**
+ * Frees the above.
+ */
+ private native void freeImage();
+
+ /**
+ * Blit a QImage
+ */
+ public native void blit(QtImage i);
+ public native void blit(QtImage i, int x, int y, int w, int h);
+
+ /**
+ * Sets the image to scaled copy of src image. hints are rendering hints.
+ */
+ private native void createScaledImage(QtVolatileImage src, int hints);
+
+ /**
+ * Draws the image optionally composited.
+ */
+ private native void drawPixels (QtGraphics gc,
+ int bg_red, int bg_green, int bg_blue,
+ int x, int y,
+ boolean composite);
+ /**
+ * Draws the image, optionally scaled and composited.
+ */
+ private native void drawPixelsScaled (QtGraphics gc,
+ int bg_red, int bg_green, int bg_blue,
+ int x, int y, int width, int height,
+ boolean composite);
+
+ /**
+ * Draws the image transformed.
+ */
+ private native void drawPixelsTransformed (QtGraphics gc, QMatrix transform);
+
+ /**
+ * Draws the image scaled flipped and optionally composited.
+ */
+ native void drawPixelsScaledFlipped (QtGraphics 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 an empty QtVolatileImage.
+ */
+ public QtVolatileImage (int width, int height)
+ {
+ this.width = width;
+ this.height = height;
+ props = new Hashtable();
+ createImage();
+ clear();
+ }
+
+ /**
+ * Constructs a scaled version of the src bitmap, using Qt
+ */
+ private QtVolatileImage (QtVolatileImage src, int width, int height,
+ int hints)
+ {
+ this.width = width;
+ this.height = height;
+ props = new Hashtable();
+
+ createScaledImage(src, hints);
+ }
+
+
+ public void finalize()
+ {
+ dispose();
+ }
+
+ public void dispose()
+ {
+ if( painters == null || painters.isEmpty() )
+ freeImage();
+ else
+ killFlag = true; // can't destroy image yet.
+ // Do so when all painters are gone.
+ }
+
+ // java.awt.Image methods ////////////////////////////////////////////////
+
+ public int getWidth (ImageObserver observer)
+ {
+ return getWidth();
+ }
+
+ public int getHeight (ImageObserver observer)
+ {
+ return getHeight();
+ }
+
+ public Object getProperty (String name, ImageObserver observer)
+ {
+ Object value = props.get (name);
+ return (value == null) ? UndefinedProperty : value;
+ }
+
+ /**
+ * Returns the source of this image.
+ */
+ public ImageProducer getSource ()
+ {
+ return new MemoryImageSource(width, height, nativeModel, getPixels(),
+ 0, width);
+ }
+
+ void putPainter(QtImageGraphics g)
+ {
+ if( painters == null )
+ painters = new WeakHashMap();
+ painters.put( g, "dummy" );
+ }
+
+ void removePainter(QtImageGraphics g)
+ {
+ painters.remove( g );
+ if( killFlag && painters.isEmpty() )
+ freeImage();
+ }
+
+ /**
+ * Creates a Graphics context for this image.
+ */
+ public Graphics getGraphics ()
+ {
+ QtImageGraphics g = new QtImageGraphics( this );
+ putPainter( g );
+ return g;
+ }
+
+ /**
+ * Returns a scaled instance of this image.
+ */
+ public Image getScaledInstance(int width,
+ int height,
+ int hints)
+ {
+ if (width <= 0 || height <= 0)
+ throw new IllegalArgumentException("Width and height of scaled bitmap"+
+ "must be >= 0");
+
+ return new QtVolatileImage(this, width, height, hints);
+ }
+
+ /**
+ */
+ public void flush ()
+ {
+ // FIXME ?
+ }
+
+ /**
+ * Returns the image status, used by QtToolkit
+ */
+ public int checkImage (ImageObserver observer)
+ {
+ return ImageObserver.ALLBITS | ImageObserver.WIDTH | ImageObserver.HEIGHT;
+ }
+
+ // Drawing methods ////////////////////////////////////////////////
+
+ /**
+ * Draws an image with eventual scaling/transforming.
+ */
+ public boolean drawImage (QtGraphics g, QMatrix matrix,
+ ImageObserver observer)
+ {
+ drawPixelsTransformed (g, matrix);
+ return true;
+ }
+
+ /**
+ * Draws an image to the QtGraphics context, at (x,y) with optional
+ * compositing with a background color.
+ */
+ public boolean drawImage (QtGraphics g, int x, int y,
+ Color bgcolor, ImageObserver observer)
+ {
+ if(bgcolor != null)
+ drawPixels(g, bgcolor.getRed (), bgcolor.getGreen (),
+ bgcolor.getBlue (), x, y, true);
+ else
+ drawPixels(g, 0, 0, 0, x, y, false);
+
+ return true;
+ }
+
+ /**
+ * Draws an image to the QtGraphics context, at (x,y) scaled to
+ * width and height, with optional compositing with a background color.
+ */
+ public boolean drawImage (QtGraphics g, int x, int y, int width, int height,
+ Color bgcolor, ImageObserver observer)
+ {
+ 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);
+
+ return true;
+ }
+
+ /**
+ * Draws an image with eventual scaling/transforming.
+ */
+ public boolean drawImage (QtGraphics g, int dx1, int dy1, int dx2, int dy2,
+ int sx1, int sy1, int sx2, int sy2,
+ Color bgcolor, ImageObserver observer)
+ {
+ 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 > width)
+ {
+ dstWidth = (int)((double)dstWidth*((double)width/(double)srcWidth));
+ srcWidth = width - srcX;
+ }
+
+ if (srcHeight > height)
+ {
+ dstHeight = (int)((double)dstHeight*((double)height/(double)srcHeight));
+ srcHeight = height - srcY;
+ }
+
+ if (srcWidth + srcX > width)
+ {
+ dstWidth = (int)((double)dstWidth * (double)(width - srcX)/(double)srcWidth);
+ srcWidth = width - srcX;
+ }
+
+ if (srcHeight + srcY > height)
+ {
+ dstHeight = (int)((double)dstHeight * (double)(width - srcY)/(double)srcHeight);
+ srcHeight = height - srcY;
+ }
+
+ if ( srcWidth <= 0 || srcHeight <= 0 || dstWidth <= 0 || dstHeight <= 0)
+ return true;
+
+ 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 native void copyArea(int x, int y, int width, int height,
+ int dx, int dy);
+
+ //******************** VolatileImage stuff ********************
+
+ public boolean contentsLost()
+ {
+ return false;
+ }
+
+ public Graphics2D createGraphics()
+ {
+ QtImageGraphics g = new QtImageGraphics(this);
+ putPainter( g );
+ return g;
+ }
+
+ public ImageCapabilities getCapabilities()
+ {
+ return new ImageCapabilities(false)
+ {
+ public boolean isTrueVolatile()
+ {
+ return false;
+ }
+ };
+ }
+
+ public int getHeight()
+ {
+ return height;
+ }
+
+ public BufferedImage getSnapshot()
+ {
+ BufferedImage bi = new BufferedImage(width, height,
+ BufferedImage.TYPE_INT_ARGB_PRE);
+ bi.setRGB( 0, 0, width, height, getPixels(), 0, width);
+ return bi;
+ }
+
+ public int getWidth()
+ {
+ return width;
+ }
+
+ public int validate(GraphicsConfiguration gc)
+ {
+ return IMAGE_OK;
+ }
+}
--- /dev/null
+/* QtWindowPeer.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., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 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.qt;
+
+import java.awt.Component;
+import java.awt.peer.WindowPeer;
+
+public class QtWindowPeer extends QtContainerPeer implements WindowPeer
+{
+ public QtWindowPeer( QtToolkit kit, Component owner )
+ {
+ super( kit, owner );
+ }
+
+ protected native void init();
+
+ protected void setup()
+ {
+ super.setup();
+ }
+
+ // ************ Public methods *********************
+
+ public native void toBack();
+
+ public native void toFront();
+
+ /*
+ * Belongs to Frame and Dialog, but no sense in duplicating code.
+ */
+ public native void setTitle(String title);
+
+ public void updateAlwaysOnTop()
+ {
+ // TODO Auto-generated method stub
+
+ }
+
+ public boolean requestWindowFocus()
+ {
+ // TODO Auto-generated method stub
+ return false;
+ }
+
+}
--- /dev/null
+/* AttributeImpl.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., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 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.xml.stream;
+
+import java.io.IOException;
+import java.io.Writer;
+import javax.xml.namespace.QName;
+import javax.xml.stream.events.Attribute;
+import javax.xml.stream.Location;
+import javax.xml.stream.XMLStreamException;
+
+/**
+ * An attribute event.
+ *
+ * @author <a href='mailto:dog@gnu.org'>Chris Burdess</a>
+ */
+public class AttributeImpl
+ extends XMLEventImpl
+ implements Attribute
+{
+
+ protected final QName name;
+ protected final String value;
+ protected final QName type;
+ protected final boolean specified;
+
+ protected AttributeImpl(Location location,
+ QName name, String value, QName type,
+ boolean specified)
+ {
+ super(location);
+ this.name = name;
+ this.value = value;
+ this.type = type;
+ this.specified = specified;
+ }
+
+ public int getEventType()
+ {
+ return ATTRIBUTE;
+ }
+
+ public QName getName()
+ {
+ return name;
+ }
+
+ public String getValue()
+ {
+ return value;
+ }
+
+ public QName getDTDType()
+ {
+ return type;
+ }
+
+ public boolean isSpecified()
+ {
+ return specified;
+ }
+
+ public void writeAsEncodedUnicode(Writer writer)
+ throws XMLStreamException
+ {
+ try
+ {
+ String prefix = name.getPrefix();
+ if (prefix != null && !"".equals(prefix))
+ {
+ writer.write(prefix);
+ writer.write(':');
+ }
+ writer.write(name.getLocalPart());
+ writer.write('=');
+ writer.write('"');
+ writer.write(encode(value, true));
+ writer.write('"');
+ }
+ catch (IOException e)
+ {
+ XMLStreamException e2 = new XMLStreamException(e.getMessage());
+ e2.initCause(e);
+ throw e2;
+ }
+ }
+
+}
+
--- /dev/null
+/* CharactersImpl.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., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 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.xml.stream;
+
+import java.io.IOException;
+import java.io.Writer;
+import javax.xml.stream.Location;
+import javax.xml.stream.XMLStreamException;
+import javax.xml.stream.events.Characters;
+
+/**
+ * A character data (text) event.
+ *
+ * @author <a href='mailto:dog@gnu.org'>Chris Burdess</a>
+ */
+public class CharactersImpl
+ extends XMLEventImpl
+ implements Characters
+{
+
+ protected final String data;
+ protected final boolean whitespace;
+ protected final boolean cdata;
+ protected final boolean ignorableWhitespace;
+
+ protected CharactersImpl(Location location,
+ String data, boolean whitespace, boolean cdata,
+ boolean ignorableWhitespace)
+ {
+ super(location);
+ this.data = data;
+ this.whitespace = whitespace;
+ this.cdata = cdata;
+ this.ignorableWhitespace = ignorableWhitespace;
+ }
+
+ public int getEventType()
+ {
+ return cdata ? CDATA : whitespace ? SPACE : CHARACTERS;
+ }
+
+ public String getData()
+ {
+ return data;
+ }
+
+ public boolean isWhiteSpace()
+ {
+ return whitespace;
+ }
+
+ public boolean isCData()
+ {
+ return cdata;
+ }
+
+ public boolean isIgnorableWhiteSpace()
+ {
+ return ignorableWhitespace;
+ }
+
+ public void writeAsEncodedUnicode(Writer writer)
+ throws XMLStreamException
+ {
+ try
+ {
+ if (cdata)
+ {
+ writer.write("<![CDATA[");
+ writer.write(data);
+ writer.write("]]>");
+ }
+ else
+ writer.write(encode(data, false));
+ }
+ catch (IOException e)
+ {
+ XMLStreamException e2 = new XMLStreamException(e.getMessage());
+ e2.initCause(e);
+ throw e2;
+ }
+ }
+
+}
+
--- /dev/null
+/* CommentImpl.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., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 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.xml.stream;
+
+import java.io.IOException;
+import java.io.Writer;
+import javax.xml.stream.Location;
+import javax.xml.stream.XMLStreamException;
+import javax.xml.stream.events.Comment;
+
+/**
+ * A comment event.
+ *
+ * @author <a href'mailto:dog@gnu.org'>Chris Burdess</a>
+ */
+public class CommentImpl
+ extends XMLEventImpl
+ implements Comment
+{
+
+ protected final String text;
+
+ protected CommentImpl(Location location, String text)
+ {
+ super(location);
+ this.text = text;
+ }
+
+ public int getEventType()
+ {
+ return COMMENT;
+ }
+
+ public String getText()
+ {
+ return text;
+ }
+
+ public void writeAsEncodedUnicode(Writer writer)
+ throws XMLStreamException
+ {
+ try
+ {
+ writer.write("<!--");
+ writer.write(encode(text, false));
+ writer.write("-->");
+ }
+ catch (IOException e)
+ {
+ XMLStreamException e2 = new XMLStreamException(e.getMessage());
+ e2.initCause(e);
+ throw e2;
+ }
+ }
+
+}
+
--- /dev/null
+/* DTDImpl.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., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 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.xml.stream;
+
+import java.io.IOException;
+import java.io.Writer;
+import java.util.List;
+import javax.xml.stream.Location;
+import javax.xml.stream.XMLStreamException;
+import javax.xml.stream.events.DTD;
+
+/**
+ * A DOCTYPE declaration event.
+ *
+ * @author <a href='mailto:dog@gnu.org'>Chris Burdess</a>
+ */
+public class DTDImpl
+ extends XMLEventImpl
+ implements DTD
+{
+
+ protected final String body;
+ protected final Object impl;
+ protected final List notations;
+ protected final List entities;
+
+ protected DTDImpl(Location location,
+ String body, Object impl, List notations, List entities)
+ {
+ super(location);
+ this.body = body;
+ this.impl = impl;
+ this.notations = notations;
+ this.entities = entities;
+ }
+
+ public int getEventType()
+ {
+ return DTD;
+ }
+
+ public String getDocumentTypeDeclaration()
+ {
+ return body;
+ }
+
+ public Object getProcessedDTD()
+ {
+ return impl;
+ }
+
+ public List getNotations()
+ {
+ return notations;
+ }
+
+ public List getEntities()
+ {
+ return entities;
+ }
+
+ public void writeAsEncodedUnicode(Writer writer)
+ throws XMLStreamException
+ {
+ try
+ {
+ writer.write("<!DOCTYPE ");
+ writer.write(body);
+ writer.write(">");
+ }
+ catch (IOException e)
+ {
+ XMLStreamException e2 = new XMLStreamException(e.getMessage());
+ e2.initCause(e);
+ throw e2;
+ }
+ }
+
+}
+
--- /dev/null
+/* EndDocumentImpl.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., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 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.xml.stream;
+
+import java.io.IOException;
+import java.io.Writer;
+import javax.xml.stream.Location;
+import javax.xml.stream.XMLStreamException;
+import javax.xml.stream.events.EndDocument;
+
+/**
+ * An end-document event.
+ *
+ * @author <a href='mailto:dog@gnu.org'>Chris Burdess</a>
+ */
+public class EndDocumentImpl
+ extends XMLEventImpl
+ implements EndDocument
+{
+
+ protected EndDocumentImpl(Location location)
+ {
+ super(location);
+ }
+
+ public int getEventType()
+ {
+ return END_DOCUMENT;
+ }
+
+ public void writeAsEncodedUnicode(Writer writer)
+ throws XMLStreamException
+ {
+ }
+
+}
+
--- /dev/null
+/* EndElementImpl.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., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 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.xml.stream;
+
+import java.io.IOException;
+import java.io.Writer;
+import java.util.Iterator;
+import java.util.List;
+import javax.xml.namespace.QName;
+import javax.xml.stream.Location;
+import javax.xml.stream.XMLStreamException;
+import javax.xml.stream.events.EndElement;
+
+/**
+ * An end-element event.
+ *
+ * @author <a href='mailto:dog@gnu.org'>Chris Burdess</a>
+ */
+public class EndElementImpl
+ extends XMLEventImpl
+ implements EndElement
+{
+
+ protected final QName name;
+ protected final List namespaces;
+
+ protected EndElementImpl(Location location, QName name, List namespaces)
+ {
+ super(location);
+ this.name = name;
+ this.namespaces = namespaces;
+ }
+
+ public int getEventType()
+ {
+ return END_ELEMENT;
+ }
+
+ public QName getName()
+ {
+ return name;
+ }
+
+ public Iterator getNamespaces()
+ {
+ return namespaces.iterator();
+ }
+
+ public void writeAsEncodedUnicode(Writer writer)
+ throws XMLStreamException
+ {
+ try
+ {
+ writer.write("</");
+ String prefix = name.getPrefix();
+ if (prefix != null && !"".equals(prefix))
+ {
+ writer.write(prefix);
+ writer.write(':');
+ }
+ writer.write(name.getLocalPart());
+ writer.write(">");
+ }
+ catch (IOException e)
+ {
+ XMLStreamException e2 = new XMLStreamException(e.getMessage());
+ e2.initCause(e);
+ throw e2;
+ }
+ }
+
+}
+
--- /dev/null
+/* EndEntityImpl.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., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 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.xml.stream;
+
+import java.io.IOException;
+import java.io.Writer;
+import javax.xml.stream.Location;
+import javax.xml.stream.XMLStreamException;
+import javax.xml.stream.events.EndEntity;
+
+/**
+ * An end-entity event.
+ *
+ * @author <a href='mailto:dog@gnu.org'>Chris Burdess</a>
+ */
+public class EndEntityImpl
+ extends XMLEventImpl
+ implements EndEntity
+{
+
+ protected final String name;
+
+ protected EndEntityImpl(Location location, String name)
+ {
+ super(location);
+ this.name = name;
+ }
+
+ public int getEventType()
+ {
+ return END_ENTITY;
+ }
+
+ public String getName()
+ {
+ return name;
+ }
+
+ public void writeAsEncodedUnicode(Writer writer)
+ throws XMLStreamException
+ {
+ }
+
+}
+
--- /dev/null
+/* EntityDeclarationImpl.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., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 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.xml.stream;
+
+import java.io.IOException;
+import java.io.Writer;
+import javax.xml.stream.Location;
+import javax.xml.stream.XMLStreamException;
+import javax.xml.stream.events.EntityDeclaration;
+
+/**
+ * An entity declaration event.
+ *
+ * @author <a href='mailto:dog@gnu.org'>Chris Burdess</a>
+ */
+public class EntityDeclarationImpl
+ extends XMLEventImpl
+ implements EntityDeclaration
+{
+
+ protected final String publicId;
+ protected final String systemId;
+ protected final String name;
+ protected final String notationName;
+ protected final String replacementText;
+ protected final String baseUri;
+
+ protected EntityDeclarationImpl(Location location,
+ String publicId, String systemId,
+ String name, String notationName,
+ String replacementText, String baseUri)
+ {
+ super(location);
+ this.publicId = publicId;
+ this.systemId = systemId;
+ this.name = name;
+ this.notationName = notationName;
+ this.replacementText = replacementText;
+ this.baseUri = baseUri;
+ }
+
+ public int getEventType()
+ {
+ return ENTITY_DECLARATION;
+ }
+
+ public String getPublicId()
+ {
+ return publicId;
+ }
+
+ public String getSystemId()
+ {
+ return systemId;
+ }
+
+ public String getName()
+ {
+ return name;
+ }
+
+ public String getNotationName()
+ {
+ return notationName;
+ }
+
+ public String getReplacementText()
+ {
+ return replacementText;
+ }
+
+ public String getBaseURI()
+ {
+ return baseUri;
+ }
+
+ public void writeAsEncodedUnicode(Writer writer)
+ throws XMLStreamException
+ {
+ try
+ {
+ writer.write("<!ENTITY ");
+ writer.write(name);
+ writer.write(' ');
+ if (systemId != null)
+ {
+ if (publicId != null)
+ {
+ writer.write(" PUBLIC ");
+ writer.write('"');
+ writer.write(publicId);
+ writer.write('"');
+ writer.write(' ');
+ writer.write('"');
+ writer.write(systemId);
+ writer.write('"');
+ }
+ else
+ {
+ writer.write(" SYSTEM ");
+ writer.write('"');
+ writer.write(systemId);
+ writer.write('"');
+ }
+ if (notationName != null)
+ {
+ writer.write(" NDATA ");
+ writer.write(notationName);
+ }
+ }
+ else
+ {
+ writer.write('"');
+ if (replacementText != null)
+ writer.write(replacementText);
+ writer.write('"');
+ }
+ writer.write(">");
+ }
+ catch (IOException e)
+ {
+ XMLStreamException e2 = new XMLStreamException(e.getMessage());
+ e2.initCause(e);
+ throw e2;
+ }
+ }
+
+}
+
--- /dev/null
+/* EntityReferenceImpl.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., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 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.xml.stream;
+
+import java.io.IOException;
+import java.io.Writer;
+import javax.xml.stream.Location;
+import javax.xml.stream.XMLStreamException;
+//import javax.xml.stream.events.EntityDeclaration;
+import javax.xml.stream.events.EntityReference;
+
+/**
+ * An entity reference event.
+ *
+ * @author <a href='mailto:dog@gnu.org'>Chris Burdess</a>
+ */
+public class EntityReferenceImpl
+ extends XMLEventImpl
+ implements EntityReference
+{
+
+ //protected final EntityDeclaration decl;
+ protected final String name;
+ protected final String baseUri;
+ protected final String publicId;
+ protected final String systemId;
+ protected final String replacementText;
+
+ protected EntityReferenceImpl(Location location,
+ //EntityDeclaration decl,
+ String name,
+ String baseUri, String publicId,
+ String systemId, String replacementText)
+ {
+ super(location);
+ //this.decl = decl;
+ this.name = name;
+ this.baseUri = baseUri;
+ this.publicId = publicId;
+ this.systemId = systemId;
+ this.replacementText = replacementText;
+ }
+
+ public int getEventType()
+ {
+ return ENTITY_REFERENCE;
+ }
+
+ /*public EntityDeclaration getDeclaration()
+ {
+ return decl;
+ }*/
+
+ public String getName()
+ {
+ return name;
+ }
+
+ public String getBaseUri()
+ {
+ return baseUri;
+ }
+
+ public String getPublicId()
+ {
+ return publicId;
+ }
+
+ public String getSystemId()
+ {
+ return systemId;
+ }
+
+ public String getReplacementText()
+ {
+ return replacementText;
+ }
+
+ public void writeAsEncodedUnicode(Writer writer)
+ throws XMLStreamException
+ {
+ try
+ {
+ writer.write('&');
+ writer.write(name);
+ writer.write(';');
+ }
+ catch (IOException e)
+ {
+ XMLStreamException e2 = new XMLStreamException(e.getMessage());
+ e2.initCause(e);
+ throw e2;
+ }
+ }
+
+}
+
--- /dev/null
+/* FilteredEventReader.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., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 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.xml.stream;
+
+import javax.xml.stream.EventFilter;
+import javax.xml.stream.XMLEventReader;
+import javax.xml.stream.XMLStreamException;
+import javax.xml.stream.events.XMLEvent;
+import javax.xml.stream.util.EventReaderDelegate;
+
+class FilteredEventReader
+ extends EventReaderDelegate
+{
+
+ final EventFilter filter;
+
+ FilteredEventReader(XMLEventReader reader, EventFilter filter)
+ {
+ super(reader);
+ this.filter = filter;
+ }
+
+ public boolean hasNext()
+ throws XMLStreamException
+ {
+ // XXX ???
+ return super.hasNext();
+ }
+
+ public XMLEvent next()
+ throws XMLStreamException
+ {
+ XMLEvent ret;
+ do
+ {
+ ret = super.next();
+ }
+ while (!filter.accept(ret));
+ return ret;
+ }
+
+ public XMLEvent peek()
+ throws XMLStreamException
+ {
+ XMLEvent ret;
+ do
+ {
+ ret = super.peek();
+ }
+ while (!filter.accept(ret));
+ return ret;
+ }
+
+ public XMLEvent nextTag()
+ throws XMLStreamException
+ {
+ XMLEvent ret;
+ do
+ {
+ ret = super.nextTag();
+ }
+ while (!filter.accept(ret));
+ return ret;
+ }
+
+}
+
--- /dev/null
+/* FilteredStreamReader.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., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 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.xml.stream;
+
+import javax.xml.stream.StreamFilter;
+import javax.xml.stream.XMLStreamException;
+import javax.xml.stream.XMLStreamReader;
+import javax.xml.stream.util.ReaderDelegate;
+
+class FilteredStreamReader
+ extends ReaderDelegate
+{
+
+ final XMLStreamReader reader;
+ final StreamFilter filter;
+
+ FilteredStreamReader(XMLStreamReader reader, StreamFilter filter)
+ {
+ super(reader);
+ this.reader = reader;
+ this.filter = filter;
+ }
+
+ public boolean hasNext()
+ throws XMLStreamException
+ {
+ // XXX ???
+ return super.hasNext();
+ }
+
+ public int next()
+ throws XMLStreamException
+ {
+ int ret;
+ do
+ {
+ ret = super.next();
+ }
+ while (!filter.accept(reader));
+ return ret;
+ }
+
+ public int nextTag()
+ throws XMLStreamException
+ {
+ int ret;
+ do
+ {
+ ret = super.nextTag();
+ }
+ while (!filter.accept(reader));
+ return ret;
+ }
+
+}
+
--- /dev/null
+/* LocationImpl.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., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 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.xml.stream;
+
+import javax.xml.stream.Location;
+
+/**
+ * Information about the location of an XML event within the underlying
+ * stream.
+ *
+ * @author <a href='mailto:dog@gnu.org'>Chris Burdess</a>
+ */
+public class LocationImpl
+ implements Location
+{
+
+ protected final int offset;
+
+ protected final int col;
+
+ protected final int line;
+
+ protected final String systemId;
+
+ protected LocationImpl(int offset, int col, int line, String systemId)
+ {
+ this.offset = offset;
+ this.col = col;
+ this.line = line;
+ this.systemId = systemId;
+ }
+
+ public int getLineNumber()
+ {
+ return line;
+ }
+
+ public int getColumnNumber()
+ {
+ return col;
+ }
+
+ public int getCharacterOffset()
+ {
+ return offset;
+ }
+
+ public String getLocationURI()
+ {
+ return systemId;
+ }
+
+}
+
--- /dev/null
+/* NamespaceImpl.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., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 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.xml.stream;
+
+import java.io.IOException;
+import java.io.Writer;
+import javax.xml.stream.Location;
+import javax.xml.stream.XMLStreamException;
+import javax.xml.stream.events.Namespace;
+
+/**
+ * A namespace declaration event.
+ *
+ * @author <a href='mailto:dog@gnu.org'>Chris Burdess</a>
+ */
+public class NamespaceImpl
+ extends XMLEventImpl
+ implements Namespace
+{
+
+ protected final String prefix;
+ protected final String uri;
+
+ protected NamespaceImpl(Location location, String prefix, String uri)
+ {
+ super(location);
+ this.prefix = prefix;
+ this.uri = uri;
+ }
+
+ public int getEventType()
+ {
+ return NAMESPACE;
+ }
+
+ public String getPrefix()
+ {
+ return prefix;
+ }
+
+ public String getNamespaceURI()
+ {
+ return uri;
+ }
+
+ public boolean isDefaultNamespaceDeclaration()
+ {
+ return (prefix == null || "".equals(prefix));
+ }
+
+ public void writeAsEncodedUnicode(Writer writer)
+ throws XMLStreamException
+ {
+ try
+ {
+ writer.write("xmlns");
+ if (prefix != null && !"".equals(prefix))
+ {
+ writer.write(':');
+ writer.write(prefix);
+ }
+ writer.write('=');
+ writer.write('"');
+ writer.write(encode(uri, true));
+ writer.write('"');
+ }
+ catch (IOException e)
+ {
+ XMLStreamException e2 = new XMLStreamException(e.getMessage());
+ e2.initCause(e);
+ throw e2;
+ }
+ }
+
+}
+
--- /dev/null
+/* NotationDeclarationImpl.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., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 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.xml.stream;
+
+import java.io.IOException;
+import java.io.Writer;
+import javax.xml.stream.Location;
+import javax.xml.stream.XMLStreamException;
+import javax.xml.stream.events.NotationDeclaration;
+
+/**
+ * A notation declaration event.
+ *
+ * @author <a href='mailto:dog@gnu.org'>Chris Burdess</a>
+ */
+public class NotationDeclarationImpl
+ extends XMLEventImpl
+ implements NotationDeclaration
+{
+
+ protected final String name;
+ protected final String publicId;
+ protected final String systemId;
+
+ protected NotationDeclarationImpl(Location location,
+ String name, String publicId,
+ String systemId)
+ {
+ super(location);
+ this.name = name;
+ this.publicId = publicId;
+ this.systemId = systemId;
+ }
+
+ public int getEventType()
+ {
+ return NOTATION_DECLARATION;
+ }
+
+ public String getName()
+ {
+ return name;
+ }
+
+ public String getPublicId()
+ {
+ return publicId;
+ }
+
+ public String getSystemId()
+ {
+ return systemId;
+ }
+
+ public void writeAsEncodedUnicode(Writer writer)
+ throws XMLStreamException
+ {
+ try
+ {
+ writer.write("<!NOTATION ");
+ writer.write(name);
+ if (publicId != null)
+ {
+ writer.write(" PUBLIC ");
+ writer.write('"');
+ writer.write(publicId);
+ writer.write('"');
+ writer.write(' ');
+ writer.write('"');
+ writer.write(systemId);
+ writer.write('"');
+ }
+ else
+ {
+ writer.write(" SYSTEM ");
+ writer.write('"');
+ writer.write(systemId);
+ writer.write('"');
+ }
+ writer.write('>');
+ }
+ catch (IOException e)
+ {
+ XMLStreamException e2 = new XMLStreamException(e.getMessage());
+ e2.initCause(e);
+ throw e2;
+ }
+ }
+
+}
+
--- /dev/null
+/* ProcessingInstructionImpl.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., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 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.xml.stream;
+
+import java.io.IOException;
+import java.io.Writer;
+import javax.xml.stream.Location;
+import javax.xml.stream.XMLStreamException;
+import javax.xml.stream.events.ProcessingInstruction;
+
+/**
+ * A processing instruction event.
+ *
+ * @author <a href='mailto:dog@gnu.org'>Chris Burdess</a>
+ */
+public class ProcessingInstructionImpl
+ extends XMLEventImpl
+ implements ProcessingInstruction
+{
+
+ protected final String target;
+ protected final String data;
+
+ protected ProcessingInstructionImpl(Location location,
+ String target, String data)
+ {
+ super(location);
+ this.target = target;
+ this.data = data;
+ }
+
+ public int getEventType()
+ {
+ return PROCESSING_INSTRUCTION;
+ }
+
+ public String getTarget()
+ {
+ return target;
+ }
+
+ public String getData()
+ {
+ return data;
+ }
+
+ public void writeAsEncodedUnicode(Writer writer)
+ throws XMLStreamException
+ {
+ try
+ {
+ writer.write("<?");
+ writer.write(target);
+ if (data != null)
+ {
+ writer.write(' ');
+ writer.write(data);
+ }
+ writer.write("?>");
+ }
+ catch (IOException e)
+ {
+ XMLStreamException e2 = new XMLStreamException(e.getMessage());
+ e2.initCause(e);
+ throw e2;
+ }
+ }
+
+}
+
--- /dev/null
+/* StartDocumentImpl.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., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 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.xml.stream;
+
+import java.io.IOException;
+import java.io.Writer;
+import javax.xml.stream.Location;
+import javax.xml.stream.XMLStreamException;
+import javax.xml.stream.events.StartDocument;
+
+/**
+ * A start-document event.
+ *
+ * @author <a href='mailto:dog@gnu.org'>Chris Burdess</a>
+ */
+public class StartDocumentImpl
+ extends XMLEventImpl
+ implements StartDocument
+{
+
+ protected final String systemId;
+ protected final String encoding;
+ protected final String xmlVersion;
+ protected final boolean xmlStandalone;
+ protected final boolean standaloneDeclared;
+ protected final boolean encodingDeclared;
+
+ protected StartDocumentImpl(Location location,
+ String systemId, String encoding,
+ String xmlVersion, boolean xmlStandalone,
+ boolean standaloneDeclared,
+ boolean encodingDeclared)
+ {
+ super(location);
+ this.systemId = systemId;
+ this.encoding = encoding;
+ this.xmlVersion = xmlVersion;
+ this.xmlStandalone = xmlStandalone;
+ this.standaloneDeclared = standaloneDeclared;
+ this.encodingDeclared = encodingDeclared;
+ }
+
+ public int getEventType()
+ {
+ return START_DOCUMENT;
+ }
+
+ public String getSystemId()
+ {
+ return systemId;
+ }
+
+ public String getCharacterEncodingScheme()
+ {
+ return encoding;
+ }
+
+ public boolean encodingSet()
+ {
+ return encodingDeclared;
+ }
+
+ public boolean isStandalone()
+ {
+ return xmlStandalone;
+ }
+
+ public boolean standaloneSet()
+ {
+ return standaloneDeclared;
+ }
+
+ public String getVersion()
+ {
+ return xmlVersion;
+ }
+
+ public void writeAsEncodedUnicode(Writer writer)
+ throws XMLStreamException
+ {
+ try
+ {
+ writer.write("<?xml version='");
+ writer.write(xmlVersion);
+ writer.write('\'');
+ if (standaloneDeclared)
+ {
+ writer.write(" standalone='");
+ writer.write(xmlStandalone ? "yes" : "no");
+ writer.write('\'');
+ }
+ if (encodingDeclared)
+ {
+ writer.write(" encoding='");
+ writer.write(encoding);
+ writer.write('\'');
+ }
+ writer.write("?>");
+ }
+ catch (IOException e)
+ {
+ XMLStreamException e2 = new XMLStreamException(e.getMessage());
+ e2.initCause(e);
+ throw e2;
+ }
+ }
+
+}
+
--- /dev/null
+/* StartElementImpl.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., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 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.xml.stream;
+
+import java.io.IOException;
+import java.io.Writer;
+import java.util.Iterator;
+import java.util.List;
+import javax.xml.namespace.NamespaceContext;
+import javax.xml.namespace.QName;
+import javax.xml.stream.Location;
+import javax.xml.stream.XMLStreamException;
+import javax.xml.stream.events.Attribute;
+import javax.xml.stream.events.Namespace;
+import javax.xml.stream.events.StartElement;
+
+/**
+ * A start-element event.
+ *
+ * @author <a href='mailto:dog@gnu.org'>Chris Burdess</a>
+ */
+public class StartElementImpl
+ extends XMLEventImpl
+ implements StartElement
+{
+
+ protected final QName name;
+ protected final List attributes;
+ protected final List namespaces;
+ protected final NamespaceContext namespaceContext;
+
+ protected StartElementImpl(Location location,
+ QName name, List attributes, List namespaces,
+ NamespaceContext namespaceContext)
+ {
+ super(location);
+ this.name = name;
+ this.attributes = attributes;
+ this.namespaces = namespaces;
+ this.namespaceContext = namespaceContext;
+ }
+
+ public int getEventType()
+ {
+ return START_ELEMENT;
+ }
+
+ public QName getName()
+ {
+ return name;
+ }
+
+ public Iterator getAttributes()
+ {
+ return attributes.iterator();
+ }
+
+ public Iterator getNamespaces()
+ {
+ return namespaces.iterator();
+ }
+
+ public Attribute getAttributeByName(QName name)
+ {
+ for (Iterator i = attributes.iterator(); i.hasNext(); )
+ {
+ Attribute attr = (Attribute) i.next();
+ if (name.equals(attr.getName()))
+ return attr;
+ }
+ return null;
+ }
+
+ public NamespaceContext getNamespaceContext()
+ {
+ return namespaceContext;
+ }
+
+ public String getNamespaceURI(String prefix)
+ {
+ return namespaceContext.getNamespaceURI(prefix);
+ }
+
+ public void writeAsEncodedUnicode(Writer writer)
+ throws XMLStreamException
+ {
+ try
+ {
+ writer.write('<');
+ String prefix = name.getPrefix();
+ if (prefix != null && !"".equals(prefix))
+ {
+ writer.write(prefix);
+ writer.write(':');
+ }
+ writer.write(name.getLocalPart());
+ for (Iterator i = namespaces.iterator(); i.hasNext(); )
+ {
+ writer.write(' ');
+ ((Namespace) i.next()).writeAsEncodedUnicode(writer);
+ }
+ for (Iterator i = attributes.iterator(); i.hasNext(); )
+ {
+ writer.write(' ');
+ ((Attribute) i.next()).writeAsEncodedUnicode(writer);
+ }
+ writer.write('>');
+ }
+ catch (IOException e)
+ {
+ XMLStreamException e2 = new XMLStreamException(e.getMessage());
+ e2.initCause(e);
+ throw e2;
+ }
+ }
+
+}
+
--- /dev/null
+/* StartEntityImpl.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., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 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.xml.stream;
+
+import java.io.IOException;
+import java.io.Writer;
+import javax.xml.stream.Location;
+import javax.xml.stream.XMLStreamException;
+import javax.xml.stream.events.StartEntity;
+
+/**
+ * A start-entity event.
+ *
+ * @author <a href='mailto:dog@gnu.org'>Chris Burdess</a>
+ */
+public class StartEntityImpl
+ extends XMLEventImpl
+ implements StartEntity
+{
+
+ protected final String name;
+
+ protected StartEntityImpl(Location location, String name)
+ {
+ super(location);
+ this.name = name;
+ }
+
+ public int getEventType()
+ {
+ return START_ENTITY;
+ }
+
+ public String getName()
+ {
+ return name;
+ }
+
+ public void writeAsEncodedUnicode(Writer writer)
+ throws XMLStreamException
+ {
+ }
+
+}
+
--- /dev/null
+/* XMLEventAllocatorImpl.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., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 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.xml.stream;
+
+import java.util.HashMap;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.Map;
+import javax.xml.namespace.QName;
+import javax.xml.stream.Location;
+import javax.xml.stream.XMLStreamConstants;
+import javax.xml.stream.XMLStreamException;
+import javax.xml.stream.XMLStreamReader;
+import javax.xml.stream.events.EntityDeclaration;
+import javax.xml.stream.events.XMLEvent;
+import javax.xml.stream.util.XMLEventAllocator;
+import javax.xml.stream.util.XMLEventConsumer;
+
+/**
+ * Allocator for creating XML events based on a reader state.
+ *
+ * @author <a href='mailto:dog@gnu.org'>Chris Burdess</a>
+ */
+public class XMLEventAllocatorImpl
+ implements XMLEventAllocator
+{
+
+ protected Map entityDeclarations;
+
+ protected XMLEventAllocatorImpl()
+ {
+ entityDeclarations = new HashMap();
+ }
+
+ public XMLEvent allocate(XMLStreamReader reader)
+ throws XMLStreamException
+ {
+ String text;
+ boolean whitespace;
+ boolean ignorableWhitespace;
+ int len;
+ List namespaces;
+ int eventType = reader.getEventType();
+ Location location = reader.getLocation();
+ switch (eventType)
+ {
+ case XMLStreamConstants.CDATA:
+ text = reader.getText();
+ whitespace = isWhitespace(text);
+ // TODO ignorableWhitespace
+ ignorableWhitespace = whitespace && false;
+ return new CharactersImpl(location, text,
+ whitespace, true, ignorableWhitespace);
+ case XMLStreamConstants.CHARACTERS:
+ text = reader.getText();
+ whitespace = false;
+ // TODO ignorableWhitespace
+ ignorableWhitespace = whitespace && false;
+ return new CharactersImpl(location, text,
+ whitespace, false, ignorableWhitespace);
+ case XMLStreamConstants.COMMENT:
+ text = reader.getText();
+ return new CommentImpl(location, text);
+ case XMLStreamConstants.DTD:
+ text = reader.getText();
+ List notations = new LinkedList();
+ List entities = new LinkedList();
+ // TODO readDTDBody(notations, entities);
+ return new DTDImpl(location, text, null, notations, entities);
+ case XMLStreamConstants.END_DOCUMENT:
+ return new EndDocumentImpl(location);
+ case XMLStreamConstants.END_ELEMENT:
+ len = reader.getNamespaceCount();
+ namespaces = new LinkedList();
+ for (int i = 0; i < len; i++)
+ namespaces.add(new NamespaceImpl(location,
+ reader.getNamespacePrefix(i),
+ reader.getNamespaceURI(i)));
+ return new EndElementImpl(location,
+ reader.getName(),
+ namespaces);
+ case XMLStreamConstants.ENTITY_REFERENCE:
+ String name = reader.getLocalName();
+ //EntityDeclaration decl =
+ // (EntityDeclaration) entityDeclarations.get(name);
+ //return new EntityReferenceImpl(location, decl, name);
+ return new EntityReferenceImpl(location, name, null, null, null, null);
+ case XMLStreamConstants.PROCESSING_INSTRUCTION:
+ return new ProcessingInstructionImpl(location,
+ reader.getPITarget(),
+ reader.getPIData());
+ case XMLStreamConstants.SPACE:
+ text = reader.getText();
+ whitespace = true;
+ // TODO ignorableWhitespace
+ ignorableWhitespace = whitespace && false;
+ return new CharactersImpl(location, text,
+ whitespace, false, ignorableWhitespace);
+ case XMLStreamConstants.START_DOCUMENT:
+ String systemId = location.getLocationURI();
+ String encoding = reader.getCharacterEncodingScheme();
+ boolean encodingDeclared = encoding != null;
+ if (encoding == null)
+ {
+ encoding = reader.getEncoding();
+ if (encoding == null)
+ encoding = "UTF-8";
+ }
+ String xmlVersion = reader.getVersion();
+ if (xmlVersion == null)
+ xmlVersion = "1.0";
+ boolean xmlStandalone = reader.isStandalone();
+ boolean standaloneDeclared = reader.standaloneSet();
+ return new StartDocumentImpl(location,
+ systemId,
+ encoding,
+ xmlVersion,
+ xmlStandalone,
+ standaloneDeclared,
+ encodingDeclared);
+ case XMLStreamConstants.START_ELEMENT:
+ len = reader.getNamespaceCount();
+ namespaces = new LinkedList();
+ for (int i = 0; i < len; i++)
+ namespaces.add(new NamespaceImpl(location,
+ reader.getNamespacePrefix(i),
+ reader.getNamespaceURI(i)));
+ len = reader.getAttributeCount();
+ List attributes = new LinkedList();
+ for (int i = 0; i < len; i++)
+ attributes.add(new AttributeImpl(location,
+ reader.getAttributeQName(i),
+ reader.getAttributeValue(i),
+ QName.valueOf(reader.getAttributeType(i)),
+ reader.isAttributeSpecified(i)));
+ return new StartElementImpl(location,
+ reader.getName(),
+ attributes, namespaces,
+ reader.getNamespaceContext());
+ default:
+ throw new XMLStreamException("Unknown event type: " + eventType);
+ }
+ }
+
+ public void allocate(XMLStreamReader reader, XMLEventConsumer consumer)
+ throws XMLStreamException
+ {
+ consumer.add(allocate(reader));
+ }
+
+ public XMLEventAllocator newInstance()
+ {
+ return new XMLEventAllocatorImpl();
+ }
+
+ protected boolean isWhitespace(String text)
+ {
+ int len = text.length();
+ for (int i = 0; i < len; i++)
+ {
+ char c = text.charAt(i);
+ if (c != 0x20 && c != 0x09 && c != 0x0a && c != 0x0d)
+ return false;
+ }
+ return true;
+ }
+
+}
+
--- /dev/null
+/* XMLEventFactoryImpl.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., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 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.xml.stream;
+
+import java.util.Collections;
+import java.util.Iterator;
+import java.util.LinkedList;
+import javax.xml.XMLConstants;
+import javax.xml.namespace.NamespaceContext;
+import javax.xml.namespace.QName;
+import javax.xml.stream.Location;
+import javax.xml.stream.XMLEventFactory;
+import javax.xml.stream.events.Attribute;
+import javax.xml.stream.events.Characters;
+import javax.xml.stream.events.Comment;
+import javax.xml.stream.events.DTD;
+import javax.xml.stream.events.EndDocument;
+import javax.xml.stream.events.EndElement;
+import javax.xml.stream.events.EntityDeclaration;
+import javax.xml.stream.events.EntityReference;
+import javax.xml.stream.events.Namespace;
+import javax.xml.stream.events.ProcessingInstruction;
+import javax.xml.stream.events.StartDocument;
+import javax.xml.stream.events.StartElement;
+
+/**
+ * Factory for XML events.
+ *
+ * @author <a href='mailto:dog@gnu.org'>Chris Burdess</a>
+ */
+public class XMLEventFactoryImpl
+ extends XMLEventFactory
+{
+
+ protected Location location;
+
+ public void setLocation(Location location)
+ {
+ this.location = location;
+ }
+
+ public Attribute createAttribute(String prefix, String namespaceURI,
+ String localName, String value)
+ {
+ return new AttributeImpl(location,
+ new QName(namespaceURI, localName, prefix),
+ value, QName.valueOf("CDATA"), true);
+ }
+
+ public Attribute createAttribute(String localName, String value)
+ {
+ return new AttributeImpl(location,
+ new QName(localName),
+ value, QName.valueOf("CDATA"), true);
+ }
+
+ public Attribute createAttribute(QName name, String value)
+ {
+ return new AttributeImpl(location, name, value,
+ QName.valueOf("CDATA"), true);
+ }
+
+ public Namespace createNamespace(String namespaceURI)
+ {
+ return new NamespaceImpl(location,
+ XMLConstants.DEFAULT_NS_PREFIX, namespaceURI);
+ }
+
+ public Namespace createNamespace(String prefix, String namespaceUri)
+ {
+ return new NamespaceImpl(location, prefix, namespaceUri);
+ }
+
+ public StartElement createStartElement(QName name,
+ Iterator attributes,
+ Iterator namespaces)
+ {
+ return new StartElementImpl(location, name,
+ createLinkedList(attributes),
+ createLinkedList(namespaces),
+ null);
+ }
+
+ public StartElement createStartElement(String prefix,
+ String namespaceUri,
+ String localName)
+ {
+ return new StartElementImpl(location,
+ new QName(namespaceUri, localName, prefix),
+ Collections.EMPTY_LIST,
+ Collections.EMPTY_LIST,
+ null);
+ }
+
+ public StartElement createStartElement(String prefix,
+ String namespaceUri,
+ String localName,
+ Iterator attributes,
+ Iterator namespaces)
+ {
+ return new StartElementImpl(location,
+ new QName(namespaceUri, localName, prefix),
+ createLinkedList(attributes),
+ createLinkedList(namespaces),
+ null);
+ }
+
+ public StartElement createStartElement(String prefix,
+ String namespaceUri,
+ String localName,
+ Iterator attributes,
+ Iterator namespaces,
+ NamespaceContext context)
+ {
+ return new StartElementImpl(location,
+ new QName(namespaceUri, localName, prefix),
+ createLinkedList(attributes),
+ createLinkedList(namespaces),
+ context);
+ }
+
+ public EndElement createEndElement(QName name,
+ Iterator namespaces)
+ {
+ return new EndElementImpl(location, name,
+ createLinkedList(namespaces));
+ }
+
+ public EndElement createEndElement(String prefix,
+ String namespaceUri,
+ String localName)
+ {
+ return new EndElementImpl(location,
+ new QName(namespaceUri, localName, prefix),
+ Collections.EMPTY_LIST);
+ }
+
+ public EndElement createEndElement(String prefix,
+ String namespaceUri,
+ String localName,
+ Iterator namespaces)
+ {
+ return new EndElementImpl(location,
+ new QName(namespaceUri, localName, prefix),
+ createLinkedList(namespaces));
+ }
+
+ public Characters createCharacters(String content)
+ {
+ return new CharactersImpl(location, content, false, false, false);
+ }
+
+ public Characters createCData(String content)
+ {
+ return new CharactersImpl(location, content, false, true, false);
+ }
+
+ public Characters createSpace(String content)
+ {
+ return new CharactersImpl(location, content, true, false, false);
+ }
+
+ public Characters createIgnorableSpace(String content)
+ {
+ return new CharactersImpl(location, content, true, false, true);
+ }
+
+ public StartDocument createStartDocument()
+ {
+ return new StartDocumentImpl(location, null, "UTF-8", "1.0",
+ false, false, false);
+ }
+
+ public StartDocument createStartDocument(String encoding,
+ String version,
+ boolean standalone)
+ {
+ return new StartDocumentImpl(location, null, encoding, version,
+ standalone, true, true);
+ }
+
+ public StartDocument createStartDocument(String encoding,
+ String version)
+ {
+ return new StartDocumentImpl(location, null, encoding, version,
+ false, false, true);
+ }
+
+ public StartDocument createStartDocument(String encoding)
+ {
+ return new StartDocumentImpl(location, null, encoding, "1.0",
+ false, false, true);
+ }
+
+ public EndDocument createEndDocument()
+ {
+ return new EndDocumentImpl(location);
+ }
+
+ public EntityReference createEntityReference(String name,
+ //EntityDeclaration declaration)
+ String replacementText)
+ {
+ //return new EntityReferenceImpl(location, declaration, name);
+ return new EntityReferenceImpl(location, name, null, null, null,
+ replacementText);
+ }
+
+ public Comment createComment(String text)
+ {
+ return new CommentImpl(location, text);
+ }
+
+ public ProcessingInstruction createProcessingInstruction(String target,
+ String data)
+ {
+ return new ProcessingInstructionImpl(location, target, data);
+ }
+
+ public DTD createDTD(String dtd)
+ {
+ return new DTDImpl(location, dtd, null,
+ Collections.EMPTY_LIST,
+ Collections.EMPTY_LIST);
+ }
+
+ LinkedList createLinkedList(Iterator i)
+ {
+ LinkedList ret = new LinkedList();
+ while (i.hasNext())
+ ret.add(i.next());
+ return ret;
+ }
+
+}
+
--- /dev/null
+/* XMLEventImpl.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., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 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.xml.stream;
+
+import java.io.Writer;
+import javax.xml.namespace.QName;
+import javax.xml.stream.Location;
+import javax.xml.stream.XMLStreamConstants;
+import javax.xml.stream.XMLStreamException;
+import javax.xml.stream.events.Characters;
+import javax.xml.stream.events.EndElement;
+import javax.xml.stream.events.StartElement;
+import javax.xml.stream.events.XMLEvent;
+
+/**
+ * An XML stream event.
+ *
+ * @author <a href='mailto:dog@gnu.org'>Chris Burdess</a>
+ */
+public abstract class XMLEventImpl
+ implements XMLEvent
+{
+
+ protected final Location location;
+
+ protected XMLEventImpl(Location location)
+ {
+ this.location = location;
+ }
+
+ public abstract int getEventType();
+
+ public Location getLocation()
+ {
+ return location;
+ }
+
+ public boolean isStartElement()
+ {
+ return getEventType() == START_ELEMENT;
+ }
+
+ public boolean isAttribute()
+ {
+ return getEventType() == ATTRIBUTE;
+ }
+
+ public boolean isNamespace()
+ {
+ return getEventType() == NAMESPACE;
+ }
+
+ public boolean isEndElement()
+ {
+ return getEventType() == END_ELEMENT;
+ }
+
+ public boolean isEntityReference()
+ {
+ return getEventType() == ENTITY_REFERENCE;
+ }
+
+ public boolean isProcessingInstruction()
+ {
+ return getEventType() == PROCESSING_INSTRUCTION;
+ }
+
+ public boolean isCharacters()
+ {
+ int et = getEventType();
+ return et == CHARACTERS || et == CDATA;
+ }
+
+ public boolean isStartDocument()
+ {
+ return getEventType() == START_DOCUMENT;
+ }
+
+ public boolean isEndDocument()
+ {
+ return getEventType() == END_DOCUMENT;
+ }
+
+ public boolean isStartEntity()
+ {
+ return getEventType() == START_ENTITY;
+ }
+
+ public boolean isEndEntity()
+ {
+ return getEventType() == END_ENTITY;
+ }
+
+ public StartElement asStartElement()
+ {
+ return (StartElement) this;
+ }
+
+ public EndElement asEndElement()
+ {
+ return (EndElement) this;
+ }
+
+ public Characters asCharacters()
+ {
+ return (Characters) this;
+ }
+
+ public QName getSchemaType()
+ {
+ return null;
+ }
+
+ public abstract void writeAsEncodedUnicode(Writer writer)
+ throws XMLStreamException;
+
+ protected String encode(String text, boolean inAttr)
+ {
+ int len = text.length();
+ StringBuffer buf = null;
+ for (int i = 0; i < len; i++)
+ {
+ char c = text.charAt(i);
+ if (c == '<')
+ {
+ if (buf == null)
+ {
+ buf = new StringBuffer(text.substring(0, i));
+ }
+ buf.append("<");
+ }
+ else if (c == '>')
+ {
+ if (buf == null)
+ {
+ buf = new StringBuffer(text.substring(0, i));
+ }
+ buf.append(">");
+ }
+ else if (c == '&')
+ {
+ if (buf == null)
+ {
+ buf = new StringBuffer(text.substring(0, i));
+ }
+ buf.append("&");
+ }
+ else if (c == '\'' && inAttr)
+ {
+ if (buf == null)
+ {
+ buf = new StringBuffer(text.substring(0, i));
+ }
+ buf.append("'");
+ }
+ else if (c == '"' && inAttr)
+ {
+ if (buf == null)
+ {
+ buf = new StringBuffer(text.substring(0, i));
+ }
+ buf.append(""");
+ }
+ else if (buf != null)
+ {
+ buf.append(c);
+ }
+ }
+ return (buf == null) ? text : buf.toString();
+ }
+
+}
+
--- /dev/null
+/* XMLEventReaderImpl.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., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 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.xml.stream;
+
+import javax.xml.stream.XMLEventReader;
+import javax.xml.stream.XMLStreamConstants;
+import javax.xml.stream.XMLStreamException;
+import javax.xml.stream.XMLStreamReader;
+import javax.xml.stream.events.XMLEvent;
+import javax.xml.stream.util.XMLEventAllocator;
+
+/**
+ * Parser using XML events.
+ *
+ * @author <a href='mailto:dog@gnu.org'>Chris Burdess</a>
+ */
+public class XMLEventReaderImpl
+ implements XMLEventReader
+{
+
+ protected final XMLStreamReader reader;
+ protected final XMLEventAllocator allocator;
+ protected final String systemId;
+ protected XMLEvent peekEvent;
+
+ protected XMLEventReaderImpl(XMLStreamReader reader,
+ XMLEventAllocator allocator,
+ String systemId)
+ {
+ this.reader = reader;
+ this.allocator = allocator;
+ this.systemId = systemId;
+ }
+
+ public XMLEvent next()
+ throws XMLStreamException
+ {
+ XMLEvent ret = peek();
+ peekEvent = null;
+ return ret;
+ }
+
+ public boolean hasNext()
+ throws XMLStreamException
+ {
+ return peekEvent != null || reader.hasNext();
+ }
+
+ public XMLEvent peek()
+ throws XMLStreamException
+ {
+ if (peekEvent != null)
+ return peekEvent;
+ if (!reader.hasNext())
+ return null;
+ reader.next();
+ peekEvent = allocator.allocate(reader);
+ return peekEvent;
+ }
+
+ public String getElementText()
+ throws XMLStreamException
+ {
+ return reader.getElementText();
+ }
+
+ public XMLEvent nextTag()
+ throws XMLStreamException
+ {
+ if (peekEvent != null)
+ {
+ int eventType = peekEvent.getEventType();
+ if (eventType == XMLStreamConstants.START_ELEMENT ||
+ eventType == XMLStreamConstants.END_ELEMENT)
+ return peekEvent;
+ else
+ peekEvent = null;
+ }
+ reader.nextTag();
+ return allocator.allocate(reader);
+ }
+
+ public Object getProperty(String name)
+ throws IllegalArgumentException
+ {
+ return reader.getProperty(name);
+ }
+
+}
+
--- /dev/null
+/* XMLEventWriterImpl.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., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 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.xml.stream;
+
+import javax.xml.namespace.NamespaceContext;
+import javax.xml.namespace.QName;
+import javax.xml.stream.XMLEventReader;
+import javax.xml.stream.XMLEventWriter;
+import javax.xml.stream.XMLStreamConstants;
+import javax.xml.stream.XMLStreamException;
+import javax.xml.stream.XMLStreamWriter;
+import javax.xml.stream.events.Attribute;
+import javax.xml.stream.events.Characters;
+import javax.xml.stream.events.Comment;
+import javax.xml.stream.events.DTD;
+import javax.xml.stream.events.Namespace;
+import javax.xml.stream.events.ProcessingInstruction;
+import javax.xml.stream.events.StartDocument;
+import javax.xml.stream.events.StartElement;
+import javax.xml.stream.events.XMLEvent;
+
+/**
+ * Writer to write events to an underlying XML stream writer.
+ *
+ * @author <a href='mailto:dog@gnu.org'>Chris Burdess</a>
+ */
+public class XMLEventWriterImpl
+ implements XMLEventWriter
+{
+
+ protected final XMLStreamWriter writer;
+
+ protected XMLEventWriterImpl(XMLStreamWriter writer)
+ {
+ this.writer = writer;
+ }
+
+ public void flush()
+ throws XMLStreamException
+ {
+ writer.flush();
+ }
+
+ public void close()
+ throws XMLStreamException
+ {
+ writer.close();
+ }
+
+ public void add(XMLEvent event)
+ throws XMLStreamException
+ {
+ QName name;
+ String uri;
+ switch (event.getEventType())
+ {
+ case XMLStreamConstants.START_ELEMENT:
+ StartElement startElement = event.asStartElement();
+ name = startElement.getName();
+ uri = name.getNamespaceURI();
+ if (uri != null && !"".equals(uri))
+ writer.writeStartElement(name.getPrefix(), name.getLocalPart(), uri);
+ else
+ writer.writeStartElement(name.getLocalPart());
+ break;
+ case XMLStreamConstants.END_ELEMENT:
+ writer.writeEndElement();
+ break;
+ case XMLStreamConstants.ATTRIBUTE:
+ Attribute attribute = (Attribute) event;
+ name = attribute.getName();
+ uri = name.getNamespaceURI();
+ if (uri != null && !"".equals(uri))
+ writer.writeAttribute(name.getPrefix(), uri, name.getLocalPart(),
+ attribute.getValue());
+ else
+ writer.writeAttribute(name.getLocalPart(), attribute.getValue());
+ break;
+ case XMLStreamConstants.NAMESPACE:
+ Namespace namespace = (Namespace) event;
+ uri = namespace.getNamespaceURI();
+ writer.writeNamespace(namespace.getPrefix(), uri);
+ break;
+ case XMLStreamConstants.PROCESSING_INSTRUCTION:
+ ProcessingInstruction pi = (ProcessingInstruction) event;
+ String data = pi.getData();
+ if (data == null)
+ writer.writeProcessingInstruction(pi.getTarget());
+ else
+ writer.writeProcessingInstruction(pi.getTarget(), data);
+ break;
+ case XMLStreamConstants.COMMENT:
+ Comment comment = (Comment) event;
+ writer.writeComment(comment.getText());
+ break;
+ case XMLStreamConstants.START_DOCUMENT:
+ StartDocument startDocument = (StartDocument) event;
+ writer.writeStartDocument(startDocument.getVersion());
+ break;
+ case XMLStreamConstants.END_DOCUMENT:
+ writer.writeEndDocument();
+ break;
+ case XMLStreamConstants.DTD:
+ DTD dtd = (DTD) event;
+ writer.writeDTD(dtd.getDocumentTypeDeclaration());
+ break;
+ case XMLStreamConstants.CHARACTERS:
+ case XMLStreamConstants.SPACE:
+ Characters characters = event.asCharacters();
+ writer.writeCharacters(characters.getData());
+ break;
+ case XMLStreamConstants.CDATA:
+ Characters cdata = event.asCharacters();
+ writer.writeCData(cdata.getData());
+ break;
+ }
+ }
+
+ public void add(XMLEventReader reader)
+ throws XMLStreamException
+ {
+ while (reader.hasNext())
+ add(reader.next());
+ }
+
+ public String getPrefix(String uri)
+ throws XMLStreamException
+ {
+ return writer.getPrefix(uri);
+ }
+
+ public void setPrefix(String prefix, String uri)
+ throws XMLStreamException
+ {
+ writer.setPrefix(prefix, uri);
+ }
+
+ public void setDefaultNamespace(String uri)
+ throws XMLStreamException
+ {
+ writer.setDefaultNamespace(uri);
+ }
+
+ public void setNamespaceContext(NamespaceContext context)
+ throws XMLStreamException
+ {
+ writer.setNamespaceContext(context);
+ }
+
+ public NamespaceContext getNamespaceContext()
+ {
+ return writer.getNamespaceContext();
+ }
+
+}
+
--- /dev/null
+/* XMLInputFactoryImpl.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., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 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.xml.stream;
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileNotFoundException;
+import java.io.InputStream;
+import java.io.IOException;
+import java.io.Reader;
+import java.net.MalformedURLException;
+import java.net.URL;
+
+import javax.xml.transform.Source;
+import javax.xml.transform.stream.StreamSource;
+import javax.xml.stream.EventFilter;
+import javax.xml.stream.StreamFilter;
+import javax.xml.stream.XMLEventReader;
+import javax.xml.stream.XMLReporter;
+import javax.xml.stream.XMLResolver;
+import javax.xml.stream.XMLStreamException;
+import javax.xml.stream.XMLStreamReader;
+import javax.xml.stream.XMLInputFactory;
+import javax.xml.stream.util.XMLEventAllocator;
+
+/**
+ * Factory for creating parsers from various kinds of XML source.
+ *
+ * @author <a href='mailto:dog@gnu.org'>Chris Burdess</a>
+ */
+public class XMLInputFactoryImpl
+ extends XMLInputFactory
+{
+
+ protected XMLResolver resolver;
+ protected XMLReporter reporter;
+ protected XMLEventAllocator allocator;
+
+ protected boolean validating;
+ protected boolean namespaceAware = true;
+ protected boolean coalescing;
+ protected boolean replacingEntityReferences = true;
+ protected boolean externalEntities = true;
+ protected boolean supportDTD = true;
+
+ public XMLInputFactoryImpl()
+ {
+ allocator = new XMLEventAllocatorImpl();
+ }
+
+ public XMLStreamReader createXMLStreamReader(Reader reader)
+ throws XMLStreamException
+ {
+ return new XMLStreamReaderImpl(reader, null, null,
+ resolver, reporter,
+ validating, namespaceAware,
+ coalescing, replacingEntityReferences,
+ externalEntities, supportDTD);
+ }
+
+ public XMLStreamReader createXMLStreamReader(Source source)
+ throws XMLStreamException
+ {
+ String systemId = source.getSystemId();
+ InputStream in = getInputStream(source);
+ return new XMLStreamReaderImpl(in, null, systemId,
+ resolver, reporter,
+ validating, namespaceAware,
+ coalescing, replacingEntityReferences,
+ externalEntities, supportDTD);
+ }
+
+ public XMLStreamReader createXMLStreamReader(InputStream in)
+ throws XMLStreamException
+ {
+ return new XMLStreamReaderImpl(in, null, null,
+ resolver, reporter,
+ validating, namespaceAware,
+ coalescing, replacingEntityReferences,
+ externalEntities, supportDTD);
+ }
+
+ public XMLStreamReader createXMLStreamReader(InputStream in, String encoding)
+ throws XMLStreamException
+ {
+ return createXMLStreamReader(in);
+ }
+
+ public XMLEventReader createXMLEventReader(Reader reader)
+ throws XMLStreamException
+ {
+ XMLStreamReader sr = createXMLStreamReader(reader);
+ return new XMLEventReaderImpl(sr, allocator, null);
+ }
+
+ public XMLEventReader createXMLEventReader(XMLStreamReader reader)
+ throws XMLStreamException
+ {
+ return new XMLEventReaderImpl(reader, allocator, null);
+ }
+
+ public XMLEventReader createXMLEventReader(Source source)
+ throws XMLStreamException
+ {
+ XMLStreamReader sr = createXMLStreamReader(source);
+ return new XMLEventReaderImpl(sr, allocator, null);
+ }
+
+ public XMLEventReader createXMLEventReader(InputStream in)
+ throws XMLStreamException
+ {
+ XMLStreamReader sr = createXMLStreamReader(in);
+ return new XMLEventReaderImpl(sr, allocator, null);
+ }
+
+ public XMLEventReader createXMLEventReader(InputStream in, String encoding)
+ throws XMLStreamException
+ {
+ XMLStreamReader sr = createXMLStreamReader(in, encoding);
+ return new XMLEventReaderImpl(sr, allocator, null);
+ }
+
+ public XMLStreamReader createFilteredReader(XMLStreamReader reader,
+ StreamFilter filter)
+ throws XMLStreamException
+ {
+ return new FilteredStreamReader(reader, filter);
+ }
+
+ public XMLEventReader createFilteredReader(XMLEventReader reader,
+ EventFilter filter)
+ throws XMLStreamException
+ {
+ return new FilteredEventReader(reader, filter);
+ }
+
+ public XMLResolver getXMLResolver()
+ {
+ return resolver;
+ }
+
+ public void setXMLResolver(XMLResolver resolver)
+ {
+ this.resolver = resolver;
+ }
+
+ public XMLReporter getXMLReporter()
+ {
+ return reporter;
+ }
+
+ public void setXMLReporter(XMLReporter reporter)
+ {
+ this.reporter = reporter;
+ }
+
+ public void setProperty(String name, Object value)
+ throws IllegalArgumentException
+ {
+ if (name.equals(IS_NAMESPACE_AWARE))
+ namespaceAware = ((Boolean) value).booleanValue();
+ else if (name.equals(IS_VALIDATING))
+ validating = ((Boolean) value).booleanValue();
+ else if (name.equals(IS_COALESCING))
+ coalescing = ((Boolean) value).booleanValue();
+ else if (name.equals(IS_REPLACING_ENTITY_REFERENCES))
+ replacingEntityReferences = ((Boolean) value).booleanValue();
+ else if (name.equals(IS_SUPPORTING_EXTERNAL_ENTITIES))
+ externalEntities = ((Boolean) value).booleanValue();
+ else if (name.equals(SUPPORT_DTD))
+ supportDTD = ((Boolean) value).booleanValue();
+ else if (name.equals(REPORTER))
+ reporter = (XMLReporter) value;
+ else if (name.equals(RESOLVER))
+ resolver = (XMLResolver) value;
+ else if (name.equals(ALLOCATOR))
+ allocator = (XMLEventAllocator) value;
+ else
+ throw new IllegalArgumentException(name);
+ }
+
+ public Object getProperty(String name)
+ throws IllegalArgumentException
+ {
+ if (name.equals(IS_NAMESPACE_AWARE))
+ return namespaceAware ? Boolean.TRUE : Boolean.FALSE;
+ if (name.equals(IS_VALIDATING))
+ return validating ? Boolean.TRUE : Boolean.FALSE;
+ if (name.equals(IS_COALESCING))
+ return coalescing ? Boolean.TRUE : Boolean.FALSE;
+ if (name.equals(IS_REPLACING_ENTITY_REFERENCES))
+ return replacingEntityReferences ? Boolean.TRUE : Boolean.FALSE;
+ if (name.equals(IS_SUPPORTING_EXTERNAL_ENTITIES))
+ return externalEntities ? Boolean.TRUE : Boolean.FALSE;
+ if (name.equals(SUPPORT_DTD))
+ return supportDTD ? Boolean.TRUE : Boolean.FALSE;
+ if (name.equals(REPORTER))
+ return reporter;
+ if (name.equals(RESOLVER))
+ return resolver;
+ if (name.equals(ALLOCATOR))
+ return allocator;
+ throw new IllegalArgumentException(name);
+ }
+
+ public boolean isPropertySupported(String name)
+ {
+ return name.equals(IS_NAMESPACE_AWARE) ||
+ name.equals(IS_VALIDATING) ||
+ name.equals(IS_COALESCING) ||
+ name.equals(IS_REPLACING_ENTITY_REFERENCES) ||
+ name.equals(IS_SUPPORTING_EXTERNAL_ENTITIES) ||
+ name.equals(SUPPORT_DTD) ||
+ name.equals(REPORTER) ||
+ name.equals(RESOLVER) ||
+ name.equals(ALLOCATOR);
+ }
+
+ public void setEventAllocator(XMLEventAllocator allocator)
+ {
+ this.allocator = allocator;
+ }
+
+ public XMLEventAllocator getEventAllocator()
+ {
+ return allocator;
+ }
+
+ public void setCoalescing(boolean coalescing)
+ {
+ this.coalescing = coalescing;
+ }
+
+ public boolean isCoalescing()
+ {
+ return coalescing;
+ }
+
+ protected InputStream getInputStream(Source source)
+ throws XMLStreamException
+ {
+ InputStream in = null;
+ if (source instanceof StreamSource)
+ {
+ StreamSource streamSource = (StreamSource) source;
+ in = streamSource.getInputStream();
+ }
+ if (in == null)
+ {
+ String systemId = source.getSystemId();
+ try
+ {
+ URL url = new URL(systemId);
+ try
+ {
+ in = url.openStream();
+ }
+ catch (IOException e2)
+ {
+ XMLStreamException e3 = new XMLStreamException(e2);
+ e3.initCause(e2);
+ throw e3;
+ }
+ }
+ catch (MalformedURLException e)
+ {
+ // Fall back to relative file
+ if (File.separatorChar != '/')
+ systemId = systemId.replace('/', File.separatorChar);
+ try
+ {
+ in = new FileInputStream(systemId);
+ }
+ catch (FileNotFoundException e2)
+ {
+ XMLStreamException e3 = new XMLStreamException(e2);
+ e3.initCause(e2);
+ throw e3;
+ }
+ }
+ }
+ return in;
+ }
+
+}
+
--- /dev/null
+/* XMLOutputFactoryImpl.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., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 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.xml.stream;
+
+import java.io.OutputStream;
+import java.io.OutputStreamWriter;
+import java.io.Writer;
+import java.io.UnsupportedEncodingException;
+
+import javax.xml.stream.XMLEventWriter;
+import javax.xml.stream.XMLOutputFactory;
+import javax.xml.stream.XMLStreamException;
+import javax.xml.stream.XMLStreamWriter;
+
+/**
+ * Standard output factory.
+ *
+ * @author <a href='mailto:dog@gnu.org'>Chris Burdess</a>
+ */
+public class XMLOutputFactoryImpl
+ extends XMLOutputFactory
+{
+
+ protected boolean prefixDefaulting = false;
+
+ public XMLOutputFactoryImpl()
+ {
+ }
+
+ public XMLStreamWriter createXMLStreamWriter(Writer stream)
+ throws XMLStreamException
+ {
+ // XXX try to determine character encoding of writer?
+ return new XMLStreamWriterImpl(stream, null, prefixDefaulting);
+ }
+
+ public XMLStreamWriter createXMLStreamWriter(OutputStream stream)
+ throws XMLStreamException
+ {
+ return createXMLStreamWriter(stream, "UTF-8");
+ }
+
+ public XMLStreamWriter createXMLStreamWriter(OutputStream stream,
+ String encoding)
+ throws XMLStreamException
+ {
+ if (encoding == null)
+ encoding = "UTF-8";
+ try
+ {
+ Writer writer = new OutputStreamWriter(stream, encoding);
+ return new XMLStreamWriterImpl(writer, encoding, prefixDefaulting);
+ }
+ catch (UnsupportedEncodingException e)
+ {
+ XMLStreamException e2 = new XMLStreamException(e);
+ e2.initCause(e);
+ throw e2;
+ }
+ }
+
+ public XMLEventWriter createXMLEventWriter(OutputStream stream)
+ throws XMLStreamException
+ {
+ XMLStreamWriter writer = createXMLStreamWriter(stream);
+ return new XMLEventWriterImpl(writer);
+ }
+
+ public XMLEventWriter createXMLEventWriter(OutputStream stream,
+ String encoding)
+ throws XMLStreamException
+ {
+ XMLStreamWriter writer = createXMLStreamWriter(stream, encoding);
+ return new XMLEventWriterImpl(writer);
+ }
+
+ public XMLEventWriter createXMLEventWriter(Writer stream)
+ throws XMLStreamException
+ {
+ XMLStreamWriter writer = createXMLStreamWriter(stream);
+ return new XMLEventWriterImpl(writer);
+ }
+
+ public void setProperty(String name, Object value)
+ throws IllegalArgumentException
+ {
+ if (IS_PREFIX_DEFAULTING.equals(name))
+ prefixDefaulting = ((Boolean) value).booleanValue();
+ throw new IllegalArgumentException(name);
+ }
+
+ public Object getProperty(String name)
+ throws IllegalArgumentException
+ {
+ if (IS_PREFIX_DEFAULTING.equals(name))
+ return new Boolean(prefixDefaulting);
+ throw new IllegalArgumentException(name);
+ }
+
+ public boolean isPropertySupported(String name)
+ {
+ if (IS_PREFIX_DEFAULTING.equals(name))
+ return true;
+ return false;
+ }
+
+ public boolean isPrefixDefaulting()
+ {
+ return prefixDefaulting;
+ }
+
+ public void setPrefixDefaulting(boolean value)
+ {
+ prefixDefaulting = value;
+ }
+
+}
+
--- /dev/null
+/* XMLStreamReaderImpl.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., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 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.xml.stream;
+
+import java.io.InputStream;
+import java.io.IOException;
+import java.io.Reader;
+import java.util.Enumeration;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.LinkedList;
+import java.util.Map;
+import javax.xml.namespace.NamespaceContext;
+import javax.xml.namespace.QName;
+import javax.xml.parsers.ParserConfigurationException;
+import javax.xml.parsers.SAXParser;
+import javax.xml.parsers.SAXParserFactory;
+import javax.xml.stream.Location;
+import javax.xml.stream.XMLResolver;
+import javax.xml.stream.XMLReporter;
+import javax.xml.stream.XMLStreamConstants;
+import javax.xml.stream.XMLStreamException;
+import javax.xml.stream.XMLStreamReader;
+
+import javax.xml.stream.events.Attribute;
+import javax.xml.stream.events.Characters;
+import javax.xml.stream.events.Comment;
+import javax.xml.stream.events.DTD;
+import javax.xml.stream.events.EndDocument;
+import javax.xml.stream.events.EndElement;
+import javax.xml.stream.events.EndEntity;
+import javax.xml.stream.events.EntityDeclaration;
+import javax.xml.stream.events.EntityReference;
+import javax.xml.stream.events.Namespace;
+import javax.xml.stream.events.NotationDeclaration;
+import javax.xml.stream.events.ProcessingInstruction;
+import javax.xml.stream.events.StartDocument;
+import javax.xml.stream.events.StartElement;
+import javax.xml.stream.events.StartEntity;
+import javax.xml.stream.events.XMLEvent;
+
+import org.xml.sax.Attributes;
+import org.xml.sax.ContentHandler;
+import org.xml.sax.DTDHandler;
+import org.xml.sax.EntityResolver;
+import org.xml.sax.ErrorHandler;
+import org.xml.sax.InputSource;
+import org.xml.sax.Locator;
+import org.xml.sax.SAXException;
+import org.xml.sax.SAXParseException;
+import org.xml.sax.XMLReader;
+import org.xml.sax.ext.Attributes2;
+import org.xml.sax.ext.DeclHandler;
+import org.xml.sax.ext.LexicalHandler;
+import org.xml.sax.ext.Locator2;
+import org.xml.sax.helpers.NamespaceSupport;
+
+/**
+ * An XML parser.
+ *
+ * This implementation uses SAX to create a series of events in memory,
+ * and then iterates over this series. This has the advantage of being simple
+ * and unifying the existing XML parsing code. However, it is quite
+ * memory-inefficient and obviously won't cope with streams of arbitrary
+ * length.
+ *
+ * A future task could be to write a real, progressive/incremental
+ * implementation of this class. In that case we should consider making that
+ * the default XML parser implementation and using a SAX wrapper to it to
+ * provide the GNU SAX implementation.
+ *
+ * @author <a href='mailto:dog@gnu.org'>Chris Burdess</a>
+ */
+public class XMLStreamReaderImpl
+ implements XMLStreamReader, NamespaceContext
+{
+
+ private LinkedList events;
+ private XMLEvent currentEvent;
+ private int eventType;
+ private NamespaceSupport namespaces;
+
+ protected String publicId;
+ protected String systemId;
+
+ protected XMLResolver resolver;
+ protected XMLReporter reporter;
+ protected boolean validating;
+ protected boolean namespaceAware;
+ protected boolean coalescing;
+ protected boolean replacingEntityReferences;
+ protected boolean externalEntities;
+ protected boolean supportDTD;
+
+ protected XMLStreamReaderImpl(InputStream in,
+ String publicId,
+ String systemId,
+ XMLResolver resolver,
+ XMLReporter reporter,
+ boolean validating,
+ boolean namespaceAware,
+ boolean coalescing,
+ boolean replacingEntityReferences,
+ boolean externalEntities,
+ boolean supportDTD)
+ throws XMLStreamException
+ {
+ //this.in = in;
+ this.publicId = publicId;
+ this.systemId = systemId;
+ this.resolver = resolver;
+ this.reporter = reporter;
+ this.validating = validating;
+ this.namespaceAware = namespaceAware;
+ this.coalescing = coalescing;
+ this.replacingEntityReferences = replacingEntityReferences;
+ this.externalEntities = externalEntities;
+ this.supportDTD = supportDTD;
+ namespaces = new NamespaceSupport();
+ events = new LinkedList();
+
+ // Configure the SAX parser and perform the parse
+ try
+ {
+ SAXParserFactory f = SAXParserFactory.newInstance();
+ f.setNamespaceAware(namespaceAware);
+ f.setValidating(validating);
+ SAXParser p = f.newSAXParser();
+ XMLReader r = p.getXMLReader();
+ CallbackHandler ch = this.new CallbackHandler(r);
+ r.setFeature("http://xml.org/sax/features/external-general-entities",
+ externalEntities);
+ r.setFeature("http://xml.org/sax/features/namespaces",
+ namespaceAware);
+ r.setContentHandler(ch);
+ r.setDTDHandler(ch);
+ r.setEntityResolver(ch);
+ r.setErrorHandler(ch);
+ r.setProperty("http://xml.org/sax/properties/lexical-handler",
+ ch);
+ InputSource source = new InputSource(in);
+ source.setSystemId(systemId);
+ r.parse(source);
+ }
+ catch (SAXException e)
+ {
+ events.add(e);
+ }
+ catch (IOException e)
+ {
+ events.add(e);
+ }
+ catch (ParserConfigurationException e)
+ {
+ XMLStreamException e2 = new XMLStreamException(e);
+ e2.initCause(e);
+ throw e2;
+ }
+ }
+
+ protected XMLStreamReaderImpl(Reader reader,
+ String publicId,
+ String systemId,
+ XMLResolver resolver,
+ XMLReporter reporter,
+ boolean validating,
+ boolean namespaceAware,
+ boolean coalescing,
+ boolean replacingEntityReferences,
+ boolean externalEntities,
+ boolean supportDTD)
+ throws XMLStreamException
+ {
+ //this.reader = reader;
+ this.publicId = publicId;
+ this.systemId = systemId;
+ this.resolver = resolver;
+ this.reporter = reporter;
+ this.validating = validating;
+ this.namespaceAware = namespaceAware;
+ this.coalescing = coalescing;
+ this.replacingEntityReferences = replacingEntityReferences;
+ this.externalEntities = externalEntities;
+ this.supportDTD = supportDTD;
+ namespaces = new NamespaceSupport();
+ events = new LinkedList();
+
+ // Configure the SAX parser and perform the parse
+ try
+ {
+ SAXParserFactory f = SAXParserFactory.newInstance();
+ f.setNamespaceAware(namespaceAware);
+ f.setValidating(validating);
+ SAXParser p = f.newSAXParser();
+ XMLReader r = p.getXMLReader();
+ CallbackHandler ch = this.new CallbackHandler(r);
+ r.setFeature("http://xml.org/sax/features/external-general-entities",
+ externalEntities);
+ r.setFeature("http://xml.org/sax/features/namespaces",
+ namespaceAware);
+ r.setContentHandler(ch);
+ r.setDTDHandler(ch);
+ r.setEntityResolver(ch);
+ r.setErrorHandler(ch);
+ r.setProperty("http://xml.org/sax/properties/lexical-handler",
+ ch);
+ InputSource source = new InputSource(reader);
+ source.setSystemId(systemId);
+ r.parse(source);
+ }
+ catch (SAXException e)
+ {
+ events.add(e);
+ }
+ catch (IOException e)
+ {
+ events.add(e);
+ }
+ catch (ParserConfigurationException e)
+ {
+ XMLStreamException e2 = new XMLStreamException(e);
+ e2.initCause(e);
+ throw e2;
+ }
+ }
+
+ public Object getProperty(String name)
+ throws IllegalArgumentException
+ {
+ throw new IllegalArgumentException(name);
+ }
+
+ public int next()
+ throws XMLStreamException
+ {
+ if (events.isEmpty())
+ throw new XMLStreamException("EOF");
+ Object event = events.removeFirst();
+ if (event instanceof Exception)
+ {
+ Exception e = (Exception) event;
+ XMLStreamException e2 = new XMLStreamException(e);
+ e2.initCause(e);
+ throw e2;
+ }
+ currentEvent = (XMLEvent) event;
+ eventType = currentEvent.getEventType();
+ return eventType;
+ }
+
+ public void require(int type, String namespaceURI, String localName)
+ throws XMLStreamException
+ {
+ // TODO
+ throw new UnsupportedOperationException();
+ }
+
+ public String getElementText()
+ throws XMLStreamException
+ {
+ // TODO
+ throw new UnsupportedOperationException();
+ }
+
+ public int nextTag()
+ throws XMLStreamException
+ {
+ int ret;
+ do
+ {
+ ret = next();
+ }
+ while (ret != XMLStreamConstants.START_ELEMENT &&
+ ret != XMLStreamConstants.END_ELEMENT);
+ return ret;
+ }
+
+ public boolean hasNext()
+ throws XMLStreamException
+ {
+ return !events.isEmpty();
+ }
+
+ public void close()
+ throws XMLStreamException
+ {
+ }
+
+ public String getNamespaceURI(String prefix)
+ {
+ return namespaces.getURI(prefix);
+ }
+
+ public String getPrefix(String namespaceURI)
+ {
+ return namespaces.getPrefix(namespaceURI);
+ }
+
+ public Iterator getPrefixes(String namespaceURI)
+ {
+ LinkedList acc = new LinkedList();
+ for (Enumeration e = namespaces.getPrefixes(namespaceURI);
+ e.hasMoreElements(); )
+ acc.add(e.nextElement());
+ return acc.iterator();
+ }
+
+ public boolean isStartElement()
+ {
+ return eventType == START_ELEMENT;
+ }
+
+ public boolean isEndElement()
+ {
+ return eventType == END_ELEMENT;
+ }
+
+ public boolean isCharacters()
+ {
+ return eventType == CHARACTERS || eventType == CDATA;
+ }
+
+ public boolean isWhiteSpace()
+ {
+ return eventType == SPACE;
+ }
+
+ public String getAttributeValue(String namespaceURI, String localName)
+ {
+ StartElement se = (StartElement) currentEvent;
+ for (Iterator i = se.getAttributes(); i.hasNext(); )
+ {
+ Attribute attr = (Attribute) i.next();
+ QName name = attr.getName();
+ if (namespaceURI != null &&
+ !namespaceURI.equals(name.getNamespaceURI()))
+ continue;
+ if (!localName.equals(name.getLocalPart()))
+ continue;
+ return attr.getValue();
+ }
+ return null;
+ }
+
+ public int getAttributeCount()
+ {
+ StartElement se = (StartElement) currentEvent;
+ int count = 0;
+ for (Iterator i = se.getAttributes(); i.hasNext(); )
+ {
+ i.next();
+ count++;
+ }
+ return count;
+ }
+
+ public QName getAttributeQName(int index)
+ {
+ StartElement se = (StartElement) currentEvent;
+ int count = 0;
+ for (Iterator i = se.getAttributes(); i.hasNext(); )
+ {
+ Attribute attr = (Attribute) i.next();
+ if (index == count)
+ return attr.getName();
+ count++;
+ }
+ return null;
+ }
+
+ public String getAttributeNamespace(int index)
+ {
+ QName name = getAttributeQName(index);
+ return (name == null) ? null : name.getNamespaceURI();
+ }
+
+ public String getAttributeName(int index)
+ {
+ QName name = getAttributeQName(index);
+ return (name == null) ? null : name.getLocalPart();
+ }
+
+ public String getAttributePrefix(int index)
+ {
+ QName name = getAttributeQName(index);
+ return (name == null) ? null : name.getPrefix();
+ }
+
+ public String getAttributeType(int index)
+ {
+ StartElement se = (StartElement) currentEvent;
+ int count = 0;
+ for (Iterator i = se.getAttributes(); i.hasNext(); )
+ {
+ Attribute attr = (Attribute) i.next();
+ if (index == count)
+ {
+ QName type = attr.getDTDType();
+ return (type == null) ? "CDATA" : type.toString();
+ }
+ count++;
+ }
+ return null;
+ }
+
+ public String getAttributeValue(int index)
+ {
+ StartElement se = (StartElement) currentEvent;
+ int count = 0;
+ for (Iterator i = se.getAttributes(); i.hasNext(); )
+ {
+ Attribute attr = (Attribute) i.next();
+ if (index == count)
+ return attr.getValue();
+ count++;
+ }
+ return null;
+ }
+
+ public boolean isAttributeSpecified(int index)
+ {
+ StartElement se = (StartElement) currentEvent;
+ int count = 0;
+ for (Iterator i = se.getAttributes(); i.hasNext(); )
+ {
+ Attribute attr = (Attribute) i.next();
+ if (index == count)
+ return attr.isSpecified();
+ count++;
+ }
+ return false;
+ }
+
+ public int getNamespaceCount()
+ {
+ Iterator i = null;
+ switch (eventType)
+ {
+ case XMLStreamConstants.START_ELEMENT:
+ i = ((StartElement) currentEvent).getNamespaces();
+ break;
+ case XMLStreamConstants.END_ELEMENT:
+ i = ((EndElement) currentEvent).getNamespaces();
+ break;
+ default:
+ throw new IllegalStateException();
+ }
+ int count = 0;
+ while (i.hasNext())
+ {
+ i.next();
+ count++;
+ }
+ return count;
+ }
+
+ public String getNamespacePrefix(int index)
+ {
+ Iterator i = null;
+ switch (eventType)
+ {
+ case XMLStreamConstants.START_ELEMENT:
+ i = ((StartElement) currentEvent).getNamespaces();
+ break;
+ case XMLStreamConstants.END_ELEMENT:
+ i = ((EndElement) currentEvent).getNamespaces();
+ break;
+ default:
+ throw new IllegalStateException();
+ }
+ int count = 0;
+ while (i.hasNext())
+ {
+ Namespace ns = (Namespace) i.next();
+ if (index == count)
+ return ns.getPrefix();
+ count++;
+ }
+ return null;
+ }
+
+ public String getNamespaceURI(int index)
+ {
+ Iterator i = null;
+ switch (eventType)
+ {
+ case XMLStreamConstants.START_ELEMENT:
+ i = ((StartElement) currentEvent).getNamespaces();
+ break;
+ case XMLStreamConstants.END_ELEMENT:
+ i = ((EndElement) currentEvent).getNamespaces();
+ break;
+ default:
+ throw new IllegalStateException();
+ }
+ int count = 0;
+ while (i.hasNext())
+ {
+ Namespace ns = (Namespace) i.next();
+ if (index == count)
+ return ns.getNamespaceURI();
+ count++;
+ }
+ return null;
+ }
+
+ public NamespaceContext getNamespaceContext()
+ {
+ return this;
+ }
+
+ public int getEventType()
+ {
+ return eventType;
+ }
+
+ public String getText()
+ {
+ switch (eventType)
+ {
+ case XMLStreamConstants.CHARACTERS:
+ case XMLStreamConstants.CDATA:
+ case XMLStreamConstants.SPACE:
+ return ((Characters) currentEvent).getData();
+ case XMLStreamConstants.COMMENT:
+ return ((Comment) currentEvent).getText();
+ case XMLStreamConstants.ENTITY_REFERENCE:
+ return ((EntityReference) currentEvent).getReplacementText();
+ case XMLStreamConstants.DTD:
+ return ((DTD) currentEvent).getDocumentTypeDeclaration();
+ }
+ return null;
+ }
+
+ public char[] getTextCharacters()
+ {
+ String text = getText();
+ return (text == null) ? null : text.toCharArray();
+ }
+
+ public int getTextCharacters(int sourceStart, char[] target,
+ int targetStart, int length)
+ throws XMLStreamException
+ {
+ char[] source = getTextCharacters();
+ int len = Math.min(source.length, length);
+ System.arraycopy(source, sourceStart, target, targetStart, len);
+ return len;
+ }
+
+ public int getTextStart()
+ {
+ return 0;
+ }
+
+ public int getTextLength()
+ {
+ String text = getText();
+ return (text == null) ? 0 : text.length();
+ }
+
+ public String getEncoding()
+ {
+ // XXX SAX doesn't provide this
+ return null;
+ }
+
+ public boolean hasText()
+ {
+ return eventType == CHARACTERS || eventType == DTD ||
+ eventType == SPACE || eventType == ENTITY_REFERENCE ||
+ eventType == COMMENT || eventType == DTD;
+ }
+
+ public Location getLocation()
+ {
+ return currentEvent.getLocation();
+ }
+
+ public QName getName()
+ {
+ switch (eventType)
+ {
+ case XMLStreamConstants.START_ELEMENT:
+ return ((StartElement) currentEvent).getName();
+ case XMLStreamConstants.END_ELEMENT:
+ return ((EndElement) currentEvent).getName();
+ case XMLStreamConstants.ATTRIBUTE:
+ return ((Attribute) currentEvent).getName();
+ }
+ return null;
+ }
+
+ public String getLocalName()
+ {
+ QName name = getName();
+ return (name == null) ? null : name.getLocalPart();
+ }
+
+ public boolean hasName()
+ {
+ return getName() != null;
+ }
+
+ public String getNamespaceURI()
+ {
+ QName name = getName();
+ return (name == null) ? null : name.getNamespaceURI();
+ }
+
+ public String getPrefix()
+ {
+ QName name = getName();
+ return (name == null) ? null : name.getPrefix();
+ }
+
+ public String getVersion()
+ {
+ StartDocument sd = (StartDocument) currentEvent;
+ return sd.getVersion();
+ }
+
+ public boolean isStandalone()
+ {
+ StartDocument sd = (StartDocument) currentEvent;
+ return sd.isStandalone();
+ }
+
+ public boolean standaloneSet()
+ {
+ StartDocument sd = (StartDocument) currentEvent;
+ return sd.standaloneSet();
+ }
+
+ public String getCharacterEncodingScheme()
+ {
+ StartDocument sd = (StartDocument) currentEvent;
+ return sd.getCharacterEncodingScheme();
+ }
+
+ public String getPITarget()
+ {
+ ProcessingInstruction pi = (ProcessingInstruction) currentEvent;
+ return pi.getTarget();
+ }
+
+ public String getPIData()
+ {
+ ProcessingInstruction pi = (ProcessingInstruction) currentEvent;
+ return pi.getData();
+ }
+
+ /**
+ * This class is used to construct the event series from SAX callbacks.
+ */
+ class CallbackHandler
+ implements ContentHandler, DTDHandler, LexicalHandler,
+ DeclHandler, EntityResolver, ErrorHandler
+ {
+
+ XMLReader reader;
+ Locator locator;
+ Location location;
+ private boolean inCDATA;
+ private LinkedList namespaces = new LinkedList();
+ private LinkedList notations;
+ private LinkedList entities;
+
+ CallbackHandler(XMLReader reader)
+ {
+ this.reader = reader;
+ }
+
+ public void setDocumentLocator(Locator locator)
+ {
+ this.locator = locator;
+ location = new LocationImpl(-1,
+ locator.getColumnNumber(),
+ locator.getLineNumber(),
+ locator.getSystemId());
+ }
+
+ public void startDocument()
+ throws SAXException
+ {
+ String version = (locator instanceof Locator2) ?
+ ((Locator2) locator).getXMLVersion() : null;
+ String encoding = (locator instanceof Locator2) ?
+ ((Locator2) locator).getEncoding() : null;
+ boolean standalone =
+ reader.getFeature("http://xml.org/sax/features/is-standalone");
+ boolean standaloneDeclared = standalone;
+ boolean encodingDeclared = (encoding != null);
+ events.add(new StartDocumentImpl(location,
+ location.getLocationURI(),
+ encoding,
+ version,
+ standalone,
+ standaloneDeclared,
+ encodingDeclared));
+ }
+
+ public void endDocument()
+ throws SAXException
+ {
+ events.add(new EndDocumentImpl(location));
+ }
+
+ public void startPrefixMapping(String prefix, String uri)
+ throws SAXException
+ {
+ namespaces.add(new NamespaceImpl(location, prefix, uri));
+ }
+
+ public void endPrefixMapping(String prefix)
+ throws SAXException
+ {
+ }
+
+ public void startElement(String namespaceURI, String localName,
+ String qName, Attributes atts)
+ throws SAXException
+ {
+ LinkedList ns = namespaces;
+ namespaces = new LinkedList();
+ int ci = qName.indexOf(':');
+ String prefix = null;
+ localName = qName;
+ if (ci != -1)
+ {
+ prefix = qName.substring(0, ci);
+ localName = qName.substring(ci + 1);
+ }
+ QName name = new QName(namespaceURI, localName, prefix);
+ LinkedList attrs = new LinkedList();
+ StartElementImpl se = new StartElementImpl(location, name,
+ attrs, ns, null);
+ events.add(se);
+ // Add namespaces
+ //for (Iterator i = ns.iterator(); i.hasNext(); )
+ // events.add(i.next());
+ // Add attributes
+ int len = atts.getLength();
+ for (int i = 0; i < len; i++)
+ {
+ String attURI = atts.getURI(i);
+ String attQName = atts.getQName(i);
+ String value = atts.getValue(i);
+ QName type = QName.valueOf(atts.getType(i));
+ boolean specified = (atts instanceof Attributes2) &&
+ ((Attributes2) atts).isSpecified(i);
+ ci = attQName.indexOf(':');
+ String attPrefix = null;
+ String attLocalName = attQName;
+ if (ci != -1)
+ {
+ attPrefix = attQName.substring(0, ci);
+ attLocalName = attQName.substring(ci + 1);
+ }
+ if ("xmlns".equals(attPrefix) || "xmlns".equals(attQName))
+ continue;
+ QName attrName = new QName(attURI, attLocalName, attPrefix);
+ AttributeImpl attr = new AttributeImpl(location, attrName,
+ value, type, specified);
+ attrs.add(attr);
+ //events.add(attr);
+ }
+ }
+
+ public void endElement(String namespaceURI, String localName,
+ String qName)
+ throws SAXException
+ {
+ int ci = qName.indexOf(':');
+ String prefix = null;
+ localName = qName;
+ if (ci != -1)
+ {
+ prefix = qName.substring(0, ci);
+ localName = qName.substring(ci + 1);
+ }
+ QName name = new QName(namespaceURI, localName, prefix);
+ events.add(new EndElementImpl(location, name, new LinkedList()));
+ // TODO namespaces out of scope
+ }
+
+ public void characters(char[] ch, int start, int length)
+ throws SAXException
+ {
+ boolean whitespace = isWhitespace(ch, start, length);
+ events.add(new CharactersImpl(location, new String(ch, start, length),
+ whitespace, inCDATA, false));
+ }
+
+ public void ignorableWhitespace(char[] ch, int start, int length)
+ throws SAXException
+ {
+ boolean whitespace = isWhitespace(ch, start, length);
+ events.add(new CharactersImpl(location, new String(ch, start, length),
+ whitespace, inCDATA, true));
+ }
+
+ boolean isWhitespace(char[] ch, int start, int len)
+ {
+ int end = start + len;
+ for (int i = start; i < end; i++)
+ {
+ char c = ch[i];
+ if (c != ' ' && c != '\t' && c != '\n' && c != '\r')
+ return false;
+ }
+ return true;
+ }
+
+ public void processingInstruction(String target, String data)
+ throws SAXException
+ {
+ events.add(new ProcessingInstructionImpl(location, target, data));
+ }
+
+ public void skippedEntity(String name)
+ throws SAXException
+ {
+ }
+
+ public void startDTD(String name, String publicId, String systemId)
+ throws SAXException
+ {
+ notations = new LinkedList();
+ entities = new LinkedList();
+ events.add(new DTDImpl(location, null, null, notations, entities));
+ }
+
+ public void endDTD()
+ throws SAXException
+ {
+ }
+
+ public void startEntity(String name)
+ throws SAXException
+ {
+ events.add(new StartEntityImpl(location, name));
+ }
+
+ public void endEntity(String name)
+ throws SAXException
+ {
+ events.add(new EndEntityImpl(location, name));
+ }
+
+ public void startCDATA()
+ throws SAXException
+ {
+ inCDATA = true;
+ }
+
+ public void endCDATA()
+ throws SAXException
+ {
+ inCDATA = false;
+ }
+
+ public void comment(char[] ch, int start, int length)
+ throws SAXException
+ {
+ events.add(new CommentImpl(location, new String(ch, start, length)));
+ }
+
+ public void notationDecl(String name, String publicId, String systemId)
+ throws SAXException
+ {
+ Object n = new NotationDeclarationImpl(location, name, publicId,
+ systemId);
+ notations.add(n);
+ //events.add(n);
+ }
+
+ public void unparsedEntityDecl(String name, String publicId,
+ String systemId, String notationName)
+ throws SAXException
+ {
+ Object e = new EntityDeclarationImpl(location, publicId, systemId,
+ name, notationName,
+ null, null);
+ entities.add(e);
+ //events.add(e);
+ }
+
+ public void elementDecl(String name, String model)
+ throws SAXException
+ {
+ }
+
+ public void attributeDecl(String eName, String aName, String type,
+ String valueDefault, String value)
+ throws SAXException
+ {
+ }
+
+ public void internalEntityDecl(String name, String value)
+ throws SAXException
+ {
+ Object e = new EntityDeclarationImpl(location, null, null,
+ name, null, value, null);
+ entities.add(e);
+ //events.add(e);
+ }
+
+ public void externalEntityDecl(String name, String publicId,
+ String systemId)
+ throws SAXException
+ {
+ Object e = new EntityDeclarationImpl(location, publicId, systemId,
+ name, null, null, null);
+ entities.add(e);
+ //events.add(e);
+ }
+
+ public void warning(SAXParseException e)
+ throws SAXException
+ {
+ if (reporter != null)
+ {
+ try
+ {
+ reporter.report(e.getMessage(), "warning", e, location);
+ }
+ catch (XMLStreamException e2)
+ {
+ SAXException e3 = new SAXException(e2.getMessage());
+ e3.initCause(e2);
+ throw e3;
+ }
+ }
+ }
+
+ public void error(SAXParseException e)
+ throws SAXException
+ {
+ if (reporter != null)
+ {
+ try
+ {
+ reporter.report(e.getMessage(), "error", e, location);
+ }
+ catch (XMLStreamException e2)
+ {
+ SAXException e3 = new SAXException(e2.getMessage());
+ e3.initCause(e2);
+ throw e3;
+ }
+ }
+ }
+
+ public void fatalError(SAXParseException e)
+ throws SAXException
+ {
+ if (reporter != null)
+ {
+ try
+ {
+ reporter.report(e.getMessage(), "fatal-error", e, location);
+ }
+ catch (XMLStreamException e2)
+ {
+ SAXException e3 = new SAXException(e2.getMessage());
+ e3.initCause(e2);
+ throw e3;
+ }
+ }
+ }
+
+ public InputSource resolveEntity(String publicId, String systemId)
+ throws SAXException, IOException
+ {
+ if (resolver != null)
+ {
+ try
+ {
+ InputStream in = resolver.resolve(systemId);
+ if (in != null)
+ {
+ InputSource ret = new InputSource(in);
+ ret.setPublicId(publicId);
+ ret.setSystemId(systemId);
+ return ret;
+ }
+ }
+ catch (XMLStreamException e)
+ {
+ SAXException e2 = new SAXException(e.getMessage());
+ e2.initCause(e);
+ throw e2;
+ }
+ }
+ return null;
+ }
+
+ }
+
+}
+
--- /dev/null
+/* XMLStreamWriterImpl.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., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 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.xml.stream;
+
+import java.io.IOException;
+import java.io.Writer;
+import java.util.LinkedList;
+
+import javax.xml.XMLConstants;
+import javax.xml.namespace.NamespaceContext;
+import javax.xml.stream.XMLStreamException;
+import javax.xml.stream.XMLStreamWriter;
+
+import org.xml.sax.helpers.NamespaceSupport;
+
+/**
+ * Simple XML stream writer.
+ *
+ * @author <a href='mailto:dog@gnu.org'>Chris Burdess</a>
+ */
+public class XMLStreamWriterImpl
+ implements XMLStreamWriter
+{
+
+ protected final Writer writer;
+ protected final String encoding;
+ protected final boolean prefixDefaulting;
+ protected NamespaceContext namespaceContext;
+
+ private LinkedList elements;
+ private boolean inStartElement;
+ private boolean emptyElement;
+ private NamespaceSupport namespaces;
+
+ protected XMLStreamWriterImpl(Writer writer, String encoding,
+ boolean prefixDefaulting)
+ {
+ this.writer = writer;
+ this.encoding = encoding;
+ this.prefixDefaulting = prefixDefaulting;
+ elements = new LinkedList();
+ namespaces = new NamespaceSupport();
+ }
+
+ private void endStartElement()
+ throws IOException
+ {
+ if (!inStartElement)
+ return;
+ if (emptyElement)
+ {
+ writer.write('/');
+ elements.removeLast();
+ namespaces.popContext();
+ emptyElement = false;
+ }
+ writer.write('>');
+ inStartElement = false;
+ }
+
+ public void writeStartElement(String localName)
+ throws XMLStreamException
+ {
+ try
+ {
+ endStartElement();
+ namespaces.pushContext();
+
+ writer.write('<');
+ writer.write(localName);
+
+ elements.addLast(new String[] { null, localName });
+ inStartElement = true;
+ }
+ catch (IOException e)
+ {
+ XMLStreamException e2 = new XMLStreamException(e);
+ e2.initCause(e);
+ throw e2;
+ }
+ }
+
+ public void writeStartElement(String namespaceURI, String localName)
+ throws XMLStreamException
+ {
+ try
+ {
+ endStartElement();
+ namespaces.pushContext();
+
+ String prefix = getPrefix(namespaceURI);
+ boolean isDeclared = (prefix != null);
+ if (!isDeclared)
+ {
+ if (prefixDefaulting)
+ prefix = XMLConstants.DEFAULT_NS_PREFIX;
+ else
+ throw new XMLStreamException("namespace " + namespaceURI +
+ " has not been declared");
+ }
+ writer.write('<');
+ if (!"".equals(prefix))
+ {
+ writer.write(prefix);
+ writer.write(':');
+ }
+ writer.write(localName);
+ if (prefixDefaulting && !isDeclared)
+ {
+ writeNamespace(prefix, namespaceURI);
+ }
+
+ elements.addLast(new String[] { prefix, localName });
+ inStartElement = true;
+ }
+ catch (IOException e)
+ {
+ XMLStreamException e2 = new XMLStreamException(e);
+ e2.initCause(e);
+ throw e2;
+ }
+ }
+
+ public void writeStartElement(String prefix, String localName,
+ String namespaceURI)
+ throws XMLStreamException
+ {
+ try
+ {
+ endStartElement();
+ namespaces.pushContext();
+
+ String currentPrefix = getPrefix(namespaceURI);
+ boolean isCurrent = prefix.equals(currentPrefix);
+ writer.write('<');
+ if (!"".equals(prefix))
+ {
+ writer.write(prefix);
+ writer.write(':');
+ }
+ writer.write(localName);
+ if (prefixDefaulting && !isCurrent)
+ {
+ writeNamespace(prefix, namespaceURI);
+ }
+
+ elements.addLast(new String[] { prefix, localName });
+ inStartElement = true;
+ }
+ catch (IOException e)
+ {
+ XMLStreamException e2 = new XMLStreamException(e);
+ e2.initCause(e);
+ throw e2;
+ }
+ }
+
+ public void writeEmptyElement(String namespaceURI, String localName)
+ throws XMLStreamException
+ {
+ writeStartElement(namespaceURI, localName);
+ emptyElement = true;
+ }
+
+ public void writeEmptyElement(String prefix, String localName,
+ String namespaceURI)
+ throws XMLStreamException
+ {
+ writeStartElement(prefix, localName, namespaceURI);
+ emptyElement = true;
+ }
+
+ public void writeEmptyElement(String localName)
+ throws XMLStreamException
+ {
+ writeStartElement(localName);
+ emptyElement = true;
+ }
+
+ public void writeEndElement()
+ throws XMLStreamException
+ {
+ try
+ {
+ endStartElement();
+ String[] element = (String[]) elements.removeLast();
+ namespaces.popContext();
+
+ writer.write('<');
+ writer.write('/');
+ if (element[0] != null && !"".equals(element[0]))
+ {
+ writer.write(element[0]);
+ writer.write(':');
+ }
+ writer.write(element[1]);
+ writer.write('>');
+ }
+ catch (IOException e)
+ {
+ XMLStreamException e2 = new XMLStreamException(e);
+ e2.initCause(e);
+ throw e2;
+ }
+ }
+
+ public void writeEndDocument()
+ throws XMLStreamException
+ {
+ while (!elements.isEmpty())
+ writeEndElement();
+ }
+
+ public void close()
+ throws XMLStreamException
+ {
+ flush();
+ }
+
+ public void flush()
+ throws XMLStreamException
+ {
+ try
+ {
+ writer.flush();
+ }
+ catch (IOException e)
+ {
+ XMLStreamException e2 = new XMLStreamException(e);
+ e2.initCause(e);
+ throw e2;
+ }
+ }
+
+ public void writeAttribute(String localName, String value)
+ throws XMLStreamException
+ {
+ if (!inStartElement)
+ throw new IllegalStateException();
+ try
+ {
+ writer.write(' ');
+ writer.write(localName);
+ writer.write('=');
+ writer.write('"');
+ writeEncoded(value, true);
+ writer.write('"');
+ }
+ catch (IOException e)
+ {
+ XMLStreamException e2 = new XMLStreamException(e);
+ e2.initCause(e);
+ throw e2;
+ }
+ }
+
+ public void writeAttribute(String prefix, String namespaceURI,
+ String localName, String value)
+ throws XMLStreamException
+ {
+ if (!inStartElement)
+ throw new IllegalStateException();
+ try
+ {
+ String currentPrefix = getPrefix(namespaceURI);
+ if (currentPrefix == null)
+ {
+ if (prefixDefaulting)
+ writeNamespace(prefix, namespaceURI);
+ else
+ throw new XMLStreamException("namespace " + namespaceURI +
+ " is not bound");
+ }
+ else if (!currentPrefix.equals(prefix))
+ throw new XMLStreamException("namespace " + namespaceURI +
+ " is bound to prefix " +
+ currentPrefix);
+ writer.write(' ');
+ if (!"".equals(prefix))
+ {
+ writer.write(prefix);
+ writer.write(':');
+ }
+ writer.write(localName);
+ writer.write('=');
+ writer.write('"');
+ writeEncoded(value, true);
+ writer.write('"');
+ }
+ catch (IOException e)
+ {
+ XMLStreamException e2 = new XMLStreamException(e);
+ e2.initCause(e);
+ throw e2;
+ }
+ }
+
+ public void writeAttribute(String namespaceURI, String localName,
+ String value)
+ throws XMLStreamException
+ {
+ if (!inStartElement)
+ throw new IllegalStateException();
+ try
+ {
+ String prefix = getPrefix(namespaceURI);
+ if (prefix == null)
+ {
+ if (prefixDefaulting)
+ {
+ prefix = XMLConstants.DEFAULT_NS_PREFIX;
+ writeNamespace(prefix, namespaceURI);
+ }
+ else
+ throw new XMLStreamException("namespace " + namespaceURI +
+ " is not bound");
+ }
+ writer.write(' ');
+ if (!"".equals(prefix))
+ {
+ writer.write(prefix);
+ writer.write(':');
+ }
+ writer.write(localName);
+ writer.write('=');
+ writer.write('"');
+ writeEncoded(value, true);
+ writer.write('"');
+ }
+ catch (IOException e)
+ {
+ XMLStreamException e2 = new XMLStreamException(e);
+ e2.initCause(e);
+ throw e2;
+ }
+ }
+
+ public void writeNamespace(String prefix, String namespaceURI)
+ throws XMLStreamException
+ {
+ if (!inStartElement)
+ throw new IllegalStateException();
+ try
+ {
+ if (prefix == null)
+ prefix = XMLConstants.DEFAULT_NS_PREFIX;
+
+ setPrefix(prefix, namespaceURI);
+
+ writer.write(' ');
+ writer.write("xmlns");
+ if (!XMLConstants.DEFAULT_NS_PREFIX.equals(prefix))
+ {
+ writer.write(':');
+ writer.write(prefix);
+ }
+ writer.write('=');
+ writer.write('"');
+ writer.write(namespaceURI);
+ writer.write('"');
+ }
+ catch (IOException e)
+ {
+ XMLStreamException e2 = new XMLStreamException(e);
+ e2.initCause(e);
+ throw e2;
+ }
+ }
+
+ public void writeDefaultNamespace(String namespaceURI)
+ throws XMLStreamException
+ {
+ writeNamespace(XMLConstants.DEFAULT_NS_PREFIX, namespaceURI);
+ }
+
+ public void writeComment(String data)
+ throws XMLStreamException
+ {
+ try
+ {
+ endStartElement();
+
+ if (data != null && data.indexOf("--") != -1)
+ throw new IllegalArgumentException(data);
+
+ writer.write("<!--");
+ if (data != null)
+ writer.write(data);
+ writer.write("-->");
+ }
+ catch (IOException e)
+ {
+ XMLStreamException e2 = new XMLStreamException(e);
+ e2.initCause(e);
+ throw e2;
+ }
+ }
+
+ public void writeProcessingInstruction(String target)
+ throws XMLStreamException
+ {
+ writeProcessingInstruction(target, null);
+ }
+
+ public void writeProcessingInstruction(String target, String data)
+ throws XMLStreamException
+ {
+ try
+ {
+ endStartElement();
+
+ writer.write('<');
+ writer.write('?');
+ writer.write(target);
+ if (data != null)
+ {
+ writer.write(' ');
+ writer.write(data);
+ }
+ writer.write('?');
+ writer.write('>');
+ }
+ catch (IOException e)
+ {
+ XMLStreamException e2 = new XMLStreamException(e);
+ e2.initCause(e);
+ throw e2;
+ }
+ }
+
+ public void writeCData(String data)
+ throws XMLStreamException
+ {
+ try
+ {
+ endStartElement();
+
+ if (data.indexOf("]]") != -1)
+ throw new IllegalArgumentException(data);
+
+ writer.write("<![CDATA[");
+ writer.write(data);
+ writer.write("]]>");
+ }
+ catch (IOException e)
+ {
+ XMLStreamException e2 = new XMLStreamException(e);
+ e2.initCause(e);
+ throw e2;
+ }
+ }
+
+ public void writeDTD(String dtd)
+ throws XMLStreamException
+ {
+ try
+ {
+ writer.write("<!DOCTYPE ");
+ writer.write(dtd);
+ writer.write('>');
+ }
+ catch (IOException e)
+ {
+ XMLStreamException e2 = new XMLStreamException(e);
+ e2.initCause(e);
+ throw e2;
+ }
+ }
+
+ public void writeEntityRef(String name)
+ throws XMLStreamException
+ {
+ try
+ {
+ endStartElement();
+
+ writer.write('&');
+ writer.write(name);
+ writer.write(';');
+ }
+ catch (IOException e)
+ {
+ XMLStreamException e2 = new XMLStreamException(e);
+ e2.initCause(e);
+ throw e2;
+ }
+ }
+
+ public void writeStartDocument()
+ throws XMLStreamException
+ {
+ writeStartDocument(null, null);
+ }
+
+ public void writeStartDocument(String version)
+ throws XMLStreamException
+ {
+ writeStartDocument(null, version);
+ }
+
+ public void writeStartDocument(String encoding, String version)
+ throws XMLStreamException
+ {
+ if (version == null)
+ version = "1.0";
+ encoding = this.encoding; // YES: the parameter must be ignored
+ if (encoding == null)
+ encoding = "UTF-8";
+ if (!"1.0".equals(version) && !"1.1".equals(version))
+ throw new IllegalArgumentException(version);
+ try
+ {
+ writer.write("<?xml version=\"");
+ writer.write(version);
+ writer.write("\" encoding=\"");
+ writer.write(encoding);
+ writer.write("\"?>");
+ writer.write(System.getProperty("line.separator"));
+ }
+ catch (IOException e)
+ {
+ XMLStreamException e2 = new XMLStreamException(e);
+ e2.initCause(e);
+ throw e2;
+ }
+ }
+
+ public void writeCharacters(String text)
+ throws XMLStreamException
+ {
+ try
+ {
+ endStartElement();
+
+ if (text != null)
+ writeEncoded(text, false);
+ }
+ catch (IOException e)
+ {
+ XMLStreamException e2 = new XMLStreamException(e);
+ e2.initCause(e);
+ throw e2;
+ }
+ }
+
+ public void writeCharacters(char[] text, int start, int len)
+ throws XMLStreamException
+ {
+ try
+ {
+ endStartElement();
+
+ int end = start + len;
+ len = 0;
+ for (int i = start; i < end; i++)
+ {
+ char c = text[i];
+ if (c == '<' || c == '>' || c == '&')
+ {
+ writer.write(text, start, len);
+ if (c == '<')
+ writer.write("<");
+ else if (c == '>')
+ writer.write(">");
+ else
+ writer.write("&");
+ start = i + 1;
+ len = 0;
+ }
+ else
+ len++;
+ }
+ if (len > 0)
+ writer.write(text, start, len);
+ }
+ catch (IOException e)
+ {
+ XMLStreamException e2 = new XMLStreamException(e);
+ e2.initCause(e);
+ throw e2;
+ }
+ }
+
+ public String getPrefix(String uri)
+ throws XMLStreamException
+ {
+ String prefix = namespaces.getPrefix(uri);
+ if (prefix == null && namespaceContext != null)
+ prefix = namespaceContext.getPrefix(uri);
+ return prefix;
+ }
+
+ public void setPrefix(String prefix, String uri)
+ throws XMLStreamException
+ {
+ if (!namespaces.declarePrefix(prefix, uri))
+ throw new XMLStreamException("illegal prefix " + prefix);
+ }
+
+ public void setDefaultNamespace(String uri)
+ throws XMLStreamException
+ {
+ if (!namespaces.declarePrefix(XMLConstants.DEFAULT_NS_PREFIX, uri))
+ throw new XMLStreamException("illegal default namespace prefix");
+ }
+
+ public void setNamespaceContext(NamespaceContext context)
+ throws XMLStreamException
+ {
+ namespaceContext = context;
+ }
+
+ public NamespaceContext getNamespaceContext()
+ {
+ return namespaceContext;
+ }
+
+ public Object getProperty(String name)
+ throws IllegalArgumentException
+ {
+ throw new IllegalArgumentException(name);
+ }
+
+ private void writeEncoded(String text, boolean inAttr)
+ throws IOException
+ {
+ char[] chars = text.toCharArray();
+ int start = 0;
+ int end = chars.length;
+ int len = 0;
+ for (int i = start; i < end; i++)
+ {
+ char c = chars[i];
+ if (c == '<' || c == '>' || c == '&')
+ {
+ writer.write(chars, start, len);
+ if (c == '<')
+ writer.write("<");
+ else if (c == '>')
+ writer.write(">");
+ else
+ writer.write("&");
+ start = i + 1;
+ len = 0;
+ }
+ else if (inAttr && (c == '"' || c == '\''))
+ {
+ writer.write(chars, start, len);
+ if (c == '"')
+ writer.write(""");
+ else
+ writer.write("'");
+ start = i + 1;
+ len = 0;
+ }
+ else
+ len++;
+ }
+ if (len > 0)
+ writer.write(chars, start, len);
+ }
+
+}
+
--- /dev/null
+/* DO NOT EDIT THIS FILE - it is machine generated */
+
+#ifndef __gnu_java_awt_peer_gtk_GtkSelection__
+#define __gnu_java_awt_peer_gtk_GtkSelection__
+
+#include <jni.h>
+
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+
+JNIEXPORT void JNICALL Java_gnu_java_awt_peer_gtk_GtkSelection_requestText (JNIEnv *env, jobject);
+JNIEXPORT void JNICALL Java_gnu_java_awt_peer_gtk_GtkSelection_requestImage (JNIEnv *env, jobject);
+JNIEXPORT void JNICALL Java_gnu_java_awt_peer_gtk_GtkSelection_requestURIs (JNIEnv *env, jobject);
+JNIEXPORT void JNICALL Java_gnu_java_awt_peer_gtk_GtkSelection_requestBytes (JNIEnv *env, jobject, jstring);
+JNIEXPORT void JNICALL Java_gnu_java_awt_peer_gtk_GtkSelection_requestMimeTypes (JNIEnv *env, jobject);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* __gnu_java_awt_peer_gtk_GtkSelection__ */
--- /dev/null
+/* DO NOT EDIT THIS FILE - it is machine generated */
+
+#ifndef __gnu_java_awt_peer_qt_MainQtThread__
+#define __gnu_java_awt_peer_qt_MainQtThread__
+
+#include <jni.h>
+
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+
+JNIEXPORT jlong JNICALL Java_gnu_java_awt_peer_qt_MainQtThread_init (JNIEnv *env, jobject, jstring, jboolean);
+JNIEXPORT void JNICALL Java_gnu_java_awt_peer_qt_MainQtThread_exec (JNIEnv *env, jobject, jlong);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* __gnu_java_awt_peer_qt_MainQtThread__ */
--- /dev/null
+/* DO NOT EDIT THIS FILE - it is machine generated */
+
+#ifndef __gnu_java_awt_peer_qt_QMatrix__
+#define __gnu_java_awt_peer_qt_QMatrix__
+
+#include <jni.h>
+
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+
+JNIEXPORT void JNICALL Java_gnu_java_awt_peer_qt_QMatrix_init (JNIEnv *env, jobject, jdouble, jdouble, jdouble, jdouble, jdouble, jdouble);
+JNIEXPORT jdoubleArray JNICALL Java_gnu_java_awt_peer_qt_QMatrix_getMatrix (JNIEnv *env, jobject);
+JNIEXPORT void JNICALL Java_gnu_java_awt_peer_qt_QMatrix_dispose (JNIEnv *env, jobject);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* __gnu_java_awt_peer_qt_QMatrix__ */
--- /dev/null
+/* DO NOT EDIT THIS FILE - it is machine generated */
+
+#ifndef __gnu_java_awt_peer_qt_QPainterPath__
+#define __gnu_java_awt_peer_qt_QPainterPath__
+
+#include <jni.h>
+
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+
+JNIEXPORT jobject JNICALL Java_gnu_java_awt_peer_qt_QPainterPath_getPath (JNIEnv *env, jobject);
+JNIEXPORT void JNICALL Java_gnu_java_awt_peer_qt_QPainterPath_init (JNIEnv *env, jobject, jint);
+JNIEXPORT void JNICALL Java_gnu_java_awt_peer_qt_QPainterPath_moveTo (JNIEnv *env, jobject, jdouble, jdouble);
+JNIEXPORT void JNICALL Java_gnu_java_awt_peer_qt_QPainterPath_close (JNIEnv *env, jobject);
+JNIEXPORT void JNICALL Java_gnu_java_awt_peer_qt_QPainterPath_lineTo (JNIEnv *env, jobject, jdouble, jdouble);
+JNIEXPORT void JNICALL Java_gnu_java_awt_peer_qt_QPainterPath_quadTo (JNIEnv *env, jobject, jdouble, jdouble, jdouble, jdouble);
+JNIEXPORT void JNICALL Java_gnu_java_awt_peer_qt_QPainterPath_cubicTo (JNIEnv *env, jobject, jdouble, jdouble, jdouble, jdouble, jdouble, jdouble);
+JNIEXPORT void JNICALL Java_gnu_java_awt_peer_qt_QPainterPath_dispose (JNIEnv *env, jobject);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* __gnu_java_awt_peer_qt_QPainterPath__ */
--- /dev/null
+/* DO NOT EDIT THIS FILE - it is machine generated */
+
+#ifndef __gnu_java_awt_peer_qt_QPen__
+#define __gnu_java_awt_peer_qt_QPen__
+
+#include <jni.h>
+
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+
+JNIEXPORT void JNICALL Java_gnu_java_awt_peer_qt_QPen_init (JNIEnv *env, jobject, jdouble, jint, jint, jdouble);
+JNIEXPORT void JNICALL Java_gnu_java_awt_peer_qt_QPen_dispose (JNIEnv *env, jobject);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* __gnu_java_awt_peer_qt_QPen__ */
--- /dev/null
+/* DO NOT EDIT THIS FILE - it is machine generated */
+
+#ifndef __gnu_java_awt_peer_qt_QtAudioClip__
+#define __gnu_java_awt_peer_qt_QtAudioClip__
+
+#include <jni.h>
+
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+
+JNIEXPORT void JNICALL Java_gnu_java_awt_peer_qt_QtAudioClip_loadClip (JNIEnv *env, jobject, jstring);
+JNIEXPORT void JNICALL Java_gnu_java_awt_peer_qt_QtAudioClip_play (JNIEnv *env, jobject, jboolean);
+JNIEXPORT jboolean JNICALL Java_gnu_java_awt_peer_qt_QtAudioClip_isAvailable (JNIEnv *env, jobject);
+JNIEXPORT void JNICALL Java_gnu_java_awt_peer_qt_QtAudioClip_stop (JNIEnv *env, jobject);
+JNIEXPORT void JNICALL Java_gnu_java_awt_peer_qt_QtAudioClip_dispose (JNIEnv *env, jobject);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* __gnu_java_awt_peer_qt_QtAudioClip__ */
--- /dev/null
+/* DO NOT EDIT THIS FILE - it is machine generated */
+
+#ifndef __gnu_java_awt_peer_qt_QtButtonPeer__
+#define __gnu_java_awt_peer_qt_QtButtonPeer__
+
+#include <jni.h>
+
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+
+JNIEXPORT void JNICALL Java_gnu_java_awt_peer_qt_QtButtonPeer_init (JNIEnv *env, jobject);
+JNIEXPORT void JNICALL Java_gnu_java_awt_peer_qt_QtButtonPeer_setLabel (JNIEnv *env, jobject, jstring);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* __gnu_java_awt_peer_qt_QtButtonPeer__ */
--- /dev/null
+/* DO NOT EDIT THIS FILE - it is machine generated */
+
+#ifndef __gnu_java_awt_peer_qt_QtCanvasPeer__
+#define __gnu_java_awt_peer_qt_QtCanvasPeer__
+
+#include <jni.h>
+
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+
+JNIEXPORT void JNICALL Java_gnu_java_awt_peer_qt_QtCanvasPeer_init (JNIEnv *env, jobject);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* __gnu_java_awt_peer_qt_QtCanvasPeer__ */
--- /dev/null
+/* DO NOT EDIT THIS FILE - it is machine generated */
+
+#ifndef __gnu_java_awt_peer_qt_QtCheckboxPeer__
+#define __gnu_java_awt_peer_qt_QtCheckboxPeer__
+
+#include <jni.h>
+
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+
+JNIEXPORT void JNICALL Java_gnu_java_awt_peer_qt_QtCheckboxPeer_init (JNIEnv *env, jobject);
+JNIEXPORT void JNICALL Java_gnu_java_awt_peer_qt_QtCheckboxPeer_setLabel (JNIEnv *env, jobject, jstring);
+JNIEXPORT void JNICALL Java_gnu_java_awt_peer_qt_QtCheckboxPeer_setState (JNIEnv *env, jobject, jboolean);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* __gnu_java_awt_peer_qt_QtCheckboxPeer__ */
--- /dev/null
+/* DO NOT EDIT THIS FILE - it is machine generated */
+
+#ifndef __gnu_java_awt_peer_qt_QtChoicePeer__
+#define __gnu_java_awt_peer_qt_QtChoicePeer__
+
+#include <jni.h>
+
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+
+JNIEXPORT void JNICALL Java_gnu_java_awt_peer_qt_QtChoicePeer_init (JNIEnv *env, jobject);
+JNIEXPORT void JNICALL Java_gnu_java_awt_peer_qt_QtChoicePeer_add (JNIEnv *env, jobject, jstring, jint);
+JNIEXPORT void JNICALL Java_gnu_java_awt_peer_qt_QtChoicePeer_remove (JNIEnv *env, jobject, jint);
+JNIEXPORT void JNICALL Java_gnu_java_awt_peer_qt_QtChoicePeer_select (JNIEnv *env, jobject, jint);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* __gnu_java_awt_peer_qt_QtChoicePeer__ */
--- /dev/null
+/* DO NOT EDIT THIS FILE - it is machine generated */
+
+#ifndef __gnu_java_awt_peer_qt_QtComponentPeer__
+#define __gnu_java_awt_peer_qt_QtComponentPeer__
+
+#include <jni.h>
+
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+
+JNIEXPORT void JNICALL Java_gnu_java_awt_peer_qt_QtComponentPeer_callInit (JNIEnv *env, jobject);
+JNIEXPORT void JNICALL Java_gnu_java_awt_peer_qt_QtComponentPeer_QtUpdate (JNIEnv *env, jobject);
+JNIEXPORT void JNICALL Java_gnu_java_awt_peer_qt_QtComponentPeer_QtUpdateArea (JNIEnv *env, jobject, jint, jint, jint, jint);
+JNIEXPORT void JNICALL Java_gnu_java_awt_peer_qt_QtComponentPeer_disposeNative (JNIEnv *env, jobject);
+JNIEXPORT void JNICALL Java_gnu_java_awt_peer_qt_QtComponentPeer_setGround (JNIEnv *env, jobject, jint, jint, jint, jboolean);
+JNIEXPORT void JNICALL Java_gnu_java_awt_peer_qt_QtComponentPeer_setBoundsNative (JNIEnv *env, jobject, jint, jint, jint, jint);
+JNIEXPORT void JNICALL Java_gnu_java_awt_peer_qt_QtComponentPeer_setCursor (JNIEnv *env, jobject, jint);
+JNIEXPORT jobject JNICALL Java_gnu_java_awt_peer_qt_QtComponentPeer_getNativeBackground (JNIEnv *env, jobject);
+JNIEXPORT void JNICALL Java_gnu_java_awt_peer_qt_QtComponentPeer_setFontNative (JNIEnv *env, jobject, jobject);
+JNIEXPORT jint JNICALL Java_gnu_java_awt_peer_qt_QtComponentPeer_whichScreen (JNIEnv *env, jobject);
+JNIEXPORT void JNICALL Java_gnu_java_awt_peer_qt_QtComponentPeer_reparentNative (JNIEnv *env, jobject, jobject);
+JNIEXPORT void JNICALL Java_gnu_java_awt_peer_qt_QtComponentPeer_getLocationOnScreenNative (JNIEnv *env, jobject, jobject);
+JNIEXPORT void JNICALL Java_gnu_java_awt_peer_qt_QtComponentPeer_getSizeNative (JNIEnv *env, jobject, jobject, jboolean);
+JNIEXPORT jboolean JNICALL Java_gnu_java_awt_peer_qt_QtComponentPeer_handlesWheelScrolling (JNIEnv *env, jobject);
+JNIEXPORT jboolean JNICALL Java_gnu_java_awt_peer_qt_QtComponentPeer_isFocusable (JNIEnv *env, jobject);
+JNIEXPORT jboolean JNICALL Java_gnu_java_awt_peer_qt_QtComponentPeer_isObscured (JNIEnv *env, jobject);
+JNIEXPORT void JNICALL Java_gnu_java_awt_peer_qt_QtComponentPeer_requestFocus (JNIEnv *env, jobject);
+JNIEXPORT void JNICALL Java_gnu_java_awt_peer_qt_QtComponentPeer_setEnabled (JNIEnv *env, jobject, jboolean);
+JNIEXPORT void JNICALL Java_gnu_java_awt_peer_qt_QtComponentPeer_setVisible (JNIEnv *env, jobject, jboolean);
+JNIEXPORT jobject JNICALL Java_gnu_java_awt_peer_qt_QtComponentPeer_getBounds (JNIEnv *env, jobject);
+#undef gnu_java_awt_peer_qt_QtComponentPeer_POPUP_TRIGGER
+#define gnu_java_awt_peer_qt_QtComponentPeer_POPUP_TRIGGER 3L
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* __gnu_java_awt_peer_qt_QtComponentPeer__ */
--- /dev/null
+/* DO NOT EDIT THIS FILE - it is machine generated */
+
+#ifndef __gnu_java_awt_peer_qt_QtContainerPeer__
+#define __gnu_java_awt_peer_qt_QtContainerPeer__
+
+#include <jni.h>
+
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* __gnu_java_awt_peer_qt_QtContainerPeer__ */
--- /dev/null
+/* DO NOT EDIT THIS FILE - it is machine generated */
+
+#ifndef __gnu_java_awt_peer_qt_QtDialogPeer__
+#define __gnu_java_awt_peer_qt_QtDialogPeer__
+
+#include <jni.h>
+
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+
+JNIEXPORT void JNICALL Java_gnu_java_awt_peer_qt_QtDialogPeer_init (JNIEnv *env, jobject);
+JNIEXPORT void JNICALL Java_gnu_java_awt_peer_qt_QtDialogPeer_setModal (JNIEnv *env, jobject, jboolean);
+JNIEXPORT void JNICALL Java_gnu_java_awt_peer_qt_QtDialogPeer_setBoundsNative (JNIEnv *env, jobject, jint, jint, jint, jint, jboolean);
+JNIEXPORT void JNICALL Java_gnu_java_awt_peer_qt_QtDialogPeer_setResizable (JNIEnv *env, jobject, jboolean);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* __gnu_java_awt_peer_qt_QtDialogPeer__ */
--- /dev/null
+/* DO NOT EDIT THIS FILE - it is machine generated */
+
+#ifndef __gnu_java_awt_peer_qt_QtEmbeddedWindowPeer__
+#define __gnu_java_awt_peer_qt_QtEmbeddedWindowPeer__
+
+#include <jni.h>
+
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+
+JNIEXPORT void JNICALL Java_gnu_java_awt_peer_qt_QtEmbeddedWindowPeer_init (JNIEnv *env, jobject);
+JNIEXPORT void JNICALL Java_gnu_java_awt_peer_qt_QtEmbeddedWindowPeer_embed (JNIEnv *env, jobject, jlong);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* __gnu_java_awt_peer_qt_QtEmbeddedWindowPeer__ */
--- /dev/null
+/* DO NOT EDIT THIS FILE - it is machine generated */
+
+#ifndef __gnu_java_awt_peer_qt_QtFileDialogPeer__
+#define __gnu_java_awt_peer_qt_QtFileDialogPeer__
+
+#include <jni.h>
+
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+
+JNIEXPORT void JNICALL Java_gnu_java_awt_peer_qt_QtFileDialogPeer_init (JNIEnv *env, jobject);
+JNIEXPORT void JNICALL Java_gnu_java_awt_peer_qt_QtFileDialogPeer_setMode (JNIEnv *env, jobject, jint);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* __gnu_java_awt_peer_qt_QtFileDialogPeer__ */
--- /dev/null
+/* DO NOT EDIT THIS FILE - it is machine generated */
+
+#ifndef __gnu_java_awt_peer_qt_QtFontMetrics__
+#define __gnu_java_awt_peer_qt_QtFontMetrics__
+
+#include <jni.h>
+
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+
+JNIEXPORT void JNICALL Java_gnu_java_awt_peer_qt_QtFontMetrics_init (JNIEnv *env, jobject, jobject);
+JNIEXPORT void JNICALL Java_gnu_java_awt_peer_qt_QtFontMetrics_initGraphics (JNIEnv *env, jobject, jobject, jobject);
+JNIEXPORT void JNICALL Java_gnu_java_awt_peer_qt_QtFontMetrics_dispose (JNIEnv *env, jobject);
+JNIEXPORT jobject JNICALL Java_gnu_java_awt_peer_qt_QtFontMetrics_getStringBounds (JNIEnv *env, jobject, jstring);
+JNIEXPORT jboolean JNICALL Java_gnu_java_awt_peer_qt_QtFontMetrics_canDisplay (JNIEnv *env, jobject, jchar);
+JNIEXPORT jint JNICALL Java_gnu_java_awt_peer_qt_QtFontMetrics_getAscent (JNIEnv *env, jobject);
+JNIEXPORT jint JNICALL Java_gnu_java_awt_peer_qt_QtFontMetrics_getDescent (JNIEnv *env, jobject);
+JNIEXPORT jint JNICALL Java_gnu_java_awt_peer_qt_QtFontMetrics_getHeight (JNIEnv *env, jobject);
+JNIEXPORT jint JNICALL Java_gnu_java_awt_peer_qt_QtFontMetrics_getLeading (JNIEnv *env, jobject);
+JNIEXPORT jint JNICALL Java_gnu_java_awt_peer_qt_QtFontMetrics_getMaxAdvance (JNIEnv *env, jobject);
+JNIEXPORT jint JNICALL Java_gnu_java_awt_peer_qt_QtFontMetrics_charWidth (JNIEnv *env, jobject, jchar);
+JNIEXPORT jint JNICALL Java_gnu_java_awt_peer_qt_QtFontMetrics_stringWidth (JNIEnv *env, jobject, jstring);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* __gnu_java_awt_peer_qt_QtFontMetrics__ */
--- /dev/null
+/* DO NOT EDIT THIS FILE - it is machine generated */
+
+#ifndef __gnu_java_awt_peer_qt_QtFontPeer__
+#define __gnu_java_awt_peer_qt_QtFontPeer__
+
+#include <jni.h>
+
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+
+JNIEXPORT void JNICALL Java_gnu_java_awt_peer_qt_QtFontPeer_create (JNIEnv *env, jobject, jstring, jint, jint);
+JNIEXPORT void JNICALL Java_gnu_java_awt_peer_qt_QtFontPeer_dispose (JNIEnv *env, jobject);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* __gnu_java_awt_peer_qt_QtFontPeer__ */
--- /dev/null
+/* DO NOT EDIT THIS FILE - it is machine generated */
+
+#ifndef __gnu_java_awt_peer_qt_QtFramePeer__
+#define __gnu_java_awt_peer_qt_QtFramePeer__
+
+#include <jni.h>
+
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+
+JNIEXPORT void JNICALL Java_gnu_java_awt_peer_qt_QtFramePeer_init (JNIEnv *env, jobject);
+JNIEXPORT void JNICALL Java_gnu_java_awt_peer_qt_QtFramePeer_setIcon (JNIEnv *env, jobject, jobject);
+JNIEXPORT void JNICALL Java_gnu_java_awt_peer_qt_QtFramePeer_setMaximizedBounds (JNIEnv *env, jobject, jint, jint);
+JNIEXPORT void JNICALL Java_gnu_java_awt_peer_qt_QtFramePeer_setMenu (JNIEnv *env, jobject, jobject);
+JNIEXPORT jint JNICALL Java_gnu_java_awt_peer_qt_QtFramePeer_menuBarHeight (JNIEnv *env, jobject);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* __gnu_java_awt_peer_qt_QtFramePeer__ */
--- /dev/null
+/* DO NOT EDIT THIS FILE - it is machine generated */
+
+#ifndef __gnu_java_awt_peer_qt_QtGraphics__
+#define __gnu_java_awt_peer_qt_QtGraphics__
+
+#include <jni.h>
+
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+
+JNIEXPORT void JNICALL Java_gnu_java_awt_peer_qt_QtGraphics_delete (JNIEnv *env, jobject);
+JNIEXPORT void JNICALL Java_gnu_java_awt_peer_qt_QtGraphics_initImage (JNIEnv *env, jobject, jobject);
+JNIEXPORT void JNICALL Java_gnu_java_awt_peer_qt_QtGraphics_initVolatileImage (JNIEnv *env, jobject, jobject);
+JNIEXPORT void JNICALL Java_gnu_java_awt_peer_qt_QtGraphics_cloneNativeContext (JNIEnv *env, jobject, jobject);
+JNIEXPORT void JNICALL Java_gnu_java_awt_peer_qt_QtGraphics_setColor (JNIEnv *env, jobject, jint, jint, jint, jint);
+JNIEXPORT void JNICALL Java_gnu_java_awt_peer_qt_QtGraphics_drawNative (JNIEnv *env, jobject, jobject);
+JNIEXPORT void JNICALL Java_gnu_java_awt_peer_qt_QtGraphics_fillNative (JNIEnv *env, jobject, jobject);
+JNIEXPORT void JNICALL Java_gnu_java_awt_peer_qt_QtGraphics_setClipNative (JNIEnv *env, jobject, jobject);
+JNIEXPORT void JNICALL Java_gnu_java_awt_peer_qt_QtGraphics_setClipRectNative (JNIEnv *env, jobject, jint, jint, jint, jint);
+JNIEXPORT void JNICALL Java_gnu_java_awt_peer_qt_QtGraphics_intersectClipNative (JNIEnv *env, jobject, jobject);
+JNIEXPORT void JNICALL Java_gnu_java_awt_peer_qt_QtGraphics_intersectClipRectNative (JNIEnv *env, jobject, jint, jint, jint, jint);
+JNIEXPORT void JNICALL Java_gnu_java_awt_peer_qt_QtGraphics_setQtTransform (JNIEnv *env, jobject, jobject);
+JNIEXPORT void JNICALL Java_gnu_java_awt_peer_qt_QtGraphics_setNativeStroke (JNIEnv *env, jobject, jobject);
+JNIEXPORT void JNICALL Java_gnu_java_awt_peer_qt_QtGraphics_setNativeComposite (JNIEnv *env, jobject, jint);
+JNIEXPORT void JNICALL Java_gnu_java_awt_peer_qt_QtGraphics_drawStringNative (JNIEnv *env, jobject, jstring, jdouble, jdouble);
+JNIEXPORT void JNICALL Java_gnu_java_awt_peer_qt_QtGraphics_setLinearGradient (JNIEnv *env, jobject, jint, jint, jint, jint, jint, jint, jdouble, jdouble, jdouble, jdouble, jboolean);
+JNIEXPORT void JNICALL Java_gnu_java_awt_peer_qt_QtGraphics_setAlphaNative (JNIEnv *env, jobject, jdouble);
+JNIEXPORT void JNICALL Java_gnu_java_awt_peer_qt_QtGraphics_setFontNative (JNIEnv *env, jobject, jobject);
+JNIEXPORT jobject JNICALL Java_gnu_java_awt_peer_qt_QtGraphics_getClipNative (JNIEnv *env, jobject);
+JNIEXPORT jobject JNICALL Java_gnu_java_awt_peer_qt_QtGraphics_getClipBounds (JNIEnv *env, jobject);
+JNIEXPORT void JNICALL Java_gnu_java_awt_peer_qt_QtGraphics_fill3DRect (JNIEnv *env, jobject, jint, jint, jint, jint, jboolean);
+JNIEXPORT void JNICALL Java_gnu_java_awt_peer_qt_QtGraphics_draw3DRect (JNIEnv *env, jobject, jint, jint, jint, jint, jboolean);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* __gnu_java_awt_peer_qt_QtGraphics__ */
--- /dev/null
+/* DO NOT EDIT THIS FILE - it is machine generated */
+
+#ifndef __gnu_java_awt_peer_qt_QtGraphicsEnvironment__
+#define __gnu_java_awt_peer_qt_QtGraphicsEnvironment__
+
+#include <jni.h>
+
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* __gnu_java_awt_peer_qt_QtGraphicsEnvironment__ */
--- /dev/null
+/* DO NOT EDIT THIS FILE - it is machine generated */
+
+#ifndef __gnu_java_awt_peer_qt_QtImage__
+#define __gnu_java_awt_peer_qt_QtImage__
+
+#include <jni.h>
+
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+
+JNIEXPORT void JNICALL Java_gnu_java_awt_peer_qt_QtImage_clear (JNIEnv *env, jobject);
+JNIEXPORT jintArray JNICALL Java_gnu_java_awt_peer_qt_QtImage_getPixels (JNIEnv *env, jobject);
+JNIEXPORT void JNICALL Java_gnu_java_awt_peer_qt_QtImage_setPixels (JNIEnv *env, jobject, jintArray);
+JNIEXPORT jboolean JNICALL Java_gnu_java_awt_peer_qt_QtImage_loadImage (JNIEnv *env, jobject, jstring);
+JNIEXPORT jboolean JNICALL Java_gnu_java_awt_peer_qt_QtImage_loadImageFromData (JNIEnv *env, jobject, jbyteArray);
+JNIEXPORT void JNICALL Java_gnu_java_awt_peer_qt_QtImage_createImage (JNIEnv *env, jobject);
+JNIEXPORT void JNICALL Java_gnu_java_awt_peer_qt_QtImage_freeImage (JNIEnv *env, jobject);
+JNIEXPORT void JNICALL Java_gnu_java_awt_peer_qt_QtImage_createScaledImage (JNIEnv *env, jobject, jobject, jint);
+JNIEXPORT void JNICALL Java_gnu_java_awt_peer_qt_QtImage_drawPixels (JNIEnv *env, jobject, jobject, jint, jint, jint, jint, jint, jboolean);
+JNIEXPORT void JNICALL Java_gnu_java_awt_peer_qt_QtImage_drawPixelsScaled (JNIEnv *env, jobject, jobject, jint, jint, jint, jint, jint, jint, jint, jboolean);
+JNIEXPORT void JNICALL Java_gnu_java_awt_peer_qt_QtImage_drawPixelsTransformed (JNIEnv *env, jobject, jobject, jobject);
+JNIEXPORT void JNICALL Java_gnu_java_awt_peer_qt_QtImage_drawPixelsScaledFlipped (JNIEnv *env, jobject, jobject, jint, jint, jint, jboolean, jboolean, jint, jint, jint, jint, jint, jint, jint, jint, jboolean);
+JNIEXPORT void JNICALL Java_gnu_java_awt_peer_qt_QtImage_copyArea (JNIEnv *env, jobject, jint, jint, jint, jint, jint, jint);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* __gnu_java_awt_peer_qt_QtImage__ */
--- /dev/null
+/* DO NOT EDIT THIS FILE - it is machine generated */
+
+#ifndef __gnu_java_awt_peer_qt_QtLabelPeer__
+#define __gnu_java_awt_peer_qt_QtLabelPeer__
+
+#include <jni.h>
+
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+
+JNIEXPORT void JNICALL Java_gnu_java_awt_peer_qt_QtLabelPeer_init (JNIEnv *env, jobject);
+JNIEXPORT void JNICALL Java_gnu_java_awt_peer_qt_QtLabelPeer_setAlignment (JNIEnv *env, jobject, jint);
+JNIEXPORT void JNICALL Java_gnu_java_awt_peer_qt_QtLabelPeer_setText (JNIEnv *env, jobject, jstring);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* __gnu_java_awt_peer_qt_QtLabelPeer__ */
--- /dev/null
+/* DO NOT EDIT THIS FILE - it is machine generated */
+
+#ifndef __gnu_java_awt_peer_qt_QtListPeer__
+#define __gnu_java_awt_peer_qt_QtListPeer__
+
+#include <jni.h>
+
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+
+JNIEXPORT void JNICALL Java_gnu_java_awt_peer_qt_QtListPeer_init (JNIEnv *env, jobject);
+JNIEXPORT void JNICALL Java_gnu_java_awt_peer_qt_QtListPeer_select (JNIEnv *env, jobject, jint, jboolean);
+JNIEXPORT void JNICALL Java_gnu_java_awt_peer_qt_QtListPeer_add (JNIEnv *env, jobject, jstring, jint);
+JNIEXPORT void JNICALL Java_gnu_java_awt_peer_qt_QtListPeer_delItems (JNIEnv *env, jobject, jint, jint);
+JNIEXPORT jintArray JNICALL Java_gnu_java_awt_peer_qt_QtListPeer_getSelectedIndexes (JNIEnv *env, jobject);
+JNIEXPORT void JNICALL Java_gnu_java_awt_peer_qt_QtListPeer_makeVisible (JNIEnv *env, jobject, jint);
+JNIEXPORT void JNICALL Java_gnu_java_awt_peer_qt_QtListPeer_setMultipleMode (JNIEnv *env, jobject, jboolean);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* __gnu_java_awt_peer_qt_QtListPeer__ */
--- /dev/null
+/* DO NOT EDIT THIS FILE - it is machine generated */
+
+#ifndef __gnu_java_awt_peer_qt_QtMenuBarPeer__
+#define __gnu_java_awt_peer_qt_QtMenuBarPeer__
+
+#include <jni.h>
+
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+
+JNIEXPORT void JNICALL Java_gnu_java_awt_peer_qt_QtMenuBarPeer_init (JNIEnv *env, jobject);
+JNIEXPORT void JNICALL Java_gnu_java_awt_peer_qt_QtMenuBarPeer_addMenu (JNIEnv *env, jobject, jobject);
+JNIEXPORT void JNICALL Java_gnu_java_awt_peer_qt_QtMenuBarPeer_addHelpMenu (JNIEnv *env, jobject, jobject);
+JNIEXPORT void JNICALL Java_gnu_java_awt_peer_qt_QtMenuBarPeer_delMenu (JNIEnv *env, jobject, jobject);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* __gnu_java_awt_peer_qt_QtMenuBarPeer__ */
--- /dev/null
+/* DO NOT EDIT THIS FILE - it is machine generated */
+
+#ifndef __gnu_java_awt_peer_qt_QtMenuComponentPeer__
+#define __gnu_java_awt_peer_qt_QtMenuComponentPeer__
+
+#include <jni.h>
+
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+
+JNIEXPORT void JNICALL Java_gnu_java_awt_peer_qt_QtMenuComponentPeer_callInit (JNIEnv *env, jobject);
+JNIEXPORT void JNICALL Java_gnu_java_awt_peer_qt_QtMenuComponentPeer_dispose (JNIEnv *env, jobject);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* __gnu_java_awt_peer_qt_QtMenuComponentPeer__ */
--- /dev/null
+/* DO NOT EDIT THIS FILE - it is machine generated */
+
+#ifndef __gnu_java_awt_peer_qt_QtMenuItemPeer__
+#define __gnu_java_awt_peer_qt_QtMenuItemPeer__
+
+#include <jni.h>
+
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+
+JNIEXPORT void JNICALL Java_gnu_java_awt_peer_qt_QtMenuItemPeer_create (JNIEnv *env, jobject, jstring, jboolean, jboolean);
+JNIEXPORT void JNICALL Java_gnu_java_awt_peer_qt_QtMenuItemPeer_dispose (JNIEnv *env, jobject);
+JNIEXPORT void JNICALL Java_gnu_java_awt_peer_qt_QtMenuItemPeer_setEnabled (JNIEnv *env, jobject, jboolean);
+JNIEXPORT void JNICALL Java_gnu_java_awt_peer_qt_QtMenuItemPeer_setLabel (JNIEnv *env, jobject, jstring);
+JNIEXPORT void JNICALL Java_gnu_java_awt_peer_qt_QtMenuItemPeer_setState (JNIEnv *env, jobject, jboolean);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* __gnu_java_awt_peer_qt_QtMenuItemPeer__ */
--- /dev/null
+/* DO NOT EDIT THIS FILE - it is machine generated */
+
+#ifndef __gnu_java_awt_peer_qt_QtMenuPeer__
+#define __gnu_java_awt_peer_qt_QtMenuPeer__
+
+#include <jni.h>
+
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+
+JNIEXPORT void JNICALL Java_gnu_java_awt_peer_qt_QtMenuPeer_init (JNIEnv *env, jobject);
+JNIEXPORT void JNICALL Java_gnu_java_awt_peer_qt_QtMenuPeer_allowTearOff (JNIEnv *env, jobject);
+JNIEXPORT void JNICALL Java_gnu_java_awt_peer_qt_QtMenuPeer_insertSeperator (JNIEnv *env, jobject);
+JNIEXPORT void JNICALL Java_gnu_java_awt_peer_qt_QtMenuPeer_insertItem (JNIEnv *env, jobject, jobject);
+JNIEXPORT void JNICALL Java_gnu_java_awt_peer_qt_QtMenuPeer_insertMenu (JNIEnv *env, jobject, jobject);
+JNIEXPORT void JNICALL Java_gnu_java_awt_peer_qt_QtMenuPeer_delItem (JNIEnv *env, jobject, jlong);
+JNIEXPORT void JNICALL Java_gnu_java_awt_peer_qt_QtMenuPeer_setEnabled (JNIEnv *env, jobject, jboolean);
+JNIEXPORT void JNICALL Java_gnu_java_awt_peer_qt_QtMenuPeer_setLabel (JNIEnv *env, jobject, jstring);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* __gnu_java_awt_peer_qt_QtMenuPeer__ */
--- /dev/null
+/* DO NOT EDIT THIS FILE - it is machine generated */
+
+#ifndef __gnu_java_awt_peer_qt_QtPanelPeer__
+#define __gnu_java_awt_peer_qt_QtPanelPeer__
+
+#include <jni.h>
+
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+
+JNIEXPORT void JNICALL Java_gnu_java_awt_peer_qt_QtPanelPeer_init (JNIEnv *env, jobject);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* __gnu_java_awt_peer_qt_QtPanelPeer__ */
--- /dev/null
+/* DO NOT EDIT THIS FILE - it is machine generated */
+
+#ifndef __gnu_java_awt_peer_qt_QtPopupMenuPeer__
+#define __gnu_java_awt_peer_qt_QtPopupMenuPeer__
+
+#include <jni.h>
+
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+
+JNIEXPORT void JNICALL Java_gnu_java_awt_peer_qt_QtPopupMenuPeer_showNative (JNIEnv *env, jobject, jint, jint);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* __gnu_java_awt_peer_qt_QtPopupMenuPeer__ */
--- /dev/null
+/* DO NOT EDIT THIS FILE - it is machine generated */
+
+#ifndef __gnu_java_awt_peer_qt_QtScreenDevice__
+#define __gnu_java_awt_peer_qt_QtScreenDevice__
+
+#include <jni.h>
+
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+
+JNIEXPORT void JNICALL Java_gnu_java_awt_peer_qt_QtScreenDevice_init (JNIEnv *env, jobject, jint);
+JNIEXPORT void JNICALL Java_gnu_java_awt_peer_qt_QtScreenDevice_dispose (JNIEnv *env, jobject);
+JNIEXPORT jobject JNICALL Java_gnu_java_awt_peer_qt_QtScreenDevice_getBounds (JNIEnv *env, jobject);
+JNIEXPORT jint JNICALL Java_gnu_java_awt_peer_qt_QtScreenDevice_getDpiX (JNIEnv *env, jobject);
+JNIEXPORT jint JNICALL Java_gnu_java_awt_peer_qt_QtScreenDevice_getDpiY (JNIEnv *env, jobject);
+JNIEXPORT jint JNICALL Java_gnu_java_awt_peer_qt_QtScreenDevice_depth (JNIEnv *env, jobject);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* __gnu_java_awt_peer_qt_QtScreenDevice__ */
--- /dev/null
+/* DO NOT EDIT THIS FILE - it is machine generated */
+
+#ifndef __gnu_java_awt_peer_qt_QtScrollPanePeer__
+#define __gnu_java_awt_peer_qt_QtScrollPanePeer__
+
+#include <jni.h>
+
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+
+JNIEXPORT void JNICALL Java_gnu_java_awt_peer_qt_QtScrollPanePeer_init (JNIEnv *env, jobject);
+JNIEXPORT void JNICALL Java_gnu_java_awt_peer_qt_QtScrollPanePeer_setPolicy (JNIEnv *env, jobject, jint);
+JNIEXPORT void JNICALL Java_gnu_java_awt_peer_qt_QtScrollPanePeer_childResized (JNIEnv *env, jobject, jint, jint);
+JNIEXPORT jint JNICALL Java_gnu_java_awt_peer_qt_QtScrollPanePeer_getHScrollbarHeight (JNIEnv *env, jobject);
+JNIEXPORT jint JNICALL Java_gnu_java_awt_peer_qt_QtScrollPanePeer_getVScrollbarWidth (JNIEnv *env, jobject);
+JNIEXPORT void JNICALL Java_gnu_java_awt_peer_qt_QtScrollPanePeer_setScrollPosition (JNIEnv *env, jobject, jint, jint);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* __gnu_java_awt_peer_qt_QtScrollPanePeer__ */
--- /dev/null
+/* DO NOT EDIT THIS FILE - it is machine generated */
+
+#ifndef __gnu_java_awt_peer_qt_QtScrollbarPeer__
+#define __gnu_java_awt_peer_qt_QtScrollbarPeer__
+
+#include <jni.h>
+
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+
+JNIEXPORT void JNICALL Java_gnu_java_awt_peer_qt_QtScrollbarPeer_init (JNIEnv *env, jobject);
+JNIEXPORT void JNICALL Java_gnu_java_awt_peer_qt_QtScrollbarPeer_setOrientation (JNIEnv *env, jobject, jint);
+JNIEXPORT void JNICALL Java_gnu_java_awt_peer_qt_QtScrollbarPeer_setLineIncrement (JNIEnv *env, jobject, jint);
+JNIEXPORT void JNICALL Java_gnu_java_awt_peer_qt_QtScrollbarPeer_setPageIncrement (JNIEnv *env, jobject, jint);
+JNIEXPORT void JNICALL Java_gnu_java_awt_peer_qt_QtScrollbarPeer_setValues (JNIEnv *env, jobject, jint, jint, jint, jint);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* __gnu_java_awt_peer_qt_QtScrollbarPeer__ */
--- /dev/null
+/* DO NOT EDIT THIS FILE - it is machine generated */
+
+#ifndef __gnu_java_awt_peer_qt_QtTextAreaPeer__
+#define __gnu_java_awt_peer_qt_QtTextAreaPeer__
+
+#include <jni.h>
+
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+
+JNIEXPORT void JNICALL Java_gnu_java_awt_peer_qt_QtTextAreaPeer_init (JNIEnv *env, jobject);
+JNIEXPORT jint JNICALL Java_gnu_java_awt_peer_qt_QtTextAreaPeer_getSelection (JNIEnv *env, jobject, jboolean);
+JNIEXPORT jint JNICALL Java_gnu_java_awt_peer_qt_QtTextAreaPeer_getCaretPosition (JNIEnv *env, jobject);
+JNIEXPORT jint JNICALL Java_gnu_java_awt_peer_qt_QtTextAreaPeer_getIndexAtPoint (JNIEnv *env, jobject, jint, jint);
+JNIEXPORT jstring JNICALL Java_gnu_java_awt_peer_qt_QtTextAreaPeer_getText (JNIEnv *env, jobject);
+JNIEXPORT void JNICALL Java_gnu_java_awt_peer_qt_QtTextAreaPeer_setText (JNIEnv *env, jobject, jstring);
+JNIEXPORT void JNICALL Java_gnu_java_awt_peer_qt_QtTextAreaPeer_select (JNIEnv *env, jobject, jint, jint);
+JNIEXPORT void JNICALL Java_gnu_java_awt_peer_qt_QtTextAreaPeer_setEditable (JNIEnv *env, jobject, jboolean);
+JNIEXPORT void JNICALL Java_gnu_java_awt_peer_qt_QtTextAreaPeer_setCaretPosition (JNIEnv *env, jobject, jint);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* __gnu_java_awt_peer_qt_QtTextAreaPeer__ */
--- /dev/null
+/* DO NOT EDIT THIS FILE - it is machine generated */
+
+#ifndef __gnu_java_awt_peer_qt_QtTextFieldPeer__
+#define __gnu_java_awt_peer_qt_QtTextFieldPeer__
+
+#include <jni.h>
+
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+
+JNIEXPORT void JNICALL Java_gnu_java_awt_peer_qt_QtTextFieldPeer_init (JNIEnv *env, jobject);
+JNIEXPORT jint JNICALL Java_gnu_java_awt_peer_qt_QtTextFieldPeer_getSelection (JNIEnv *env, jobject, jboolean);
+JNIEXPORT jobject JNICALL Java_gnu_java_awt_peer_qt_QtTextFieldPeer_getMinimumSizeNative (JNIEnv *env, jobject, jint);
+JNIEXPORT jobject JNICALL Java_gnu_java_awt_peer_qt_QtTextFieldPeer_getPreferredSizeNative (JNIEnv *env, jobject, jint);
+JNIEXPORT jint JNICALL Java_gnu_java_awt_peer_qt_QtTextFieldPeer_getCaretPosition (JNIEnv *env, jobject);
+JNIEXPORT jstring JNICALL Java_gnu_java_awt_peer_qt_QtTextFieldPeer_getText (JNIEnv *env, jobject);
+JNIEXPORT void JNICALL Java_gnu_java_awt_peer_qt_QtTextFieldPeer_select (JNIEnv *env, jobject, jint, jint);
+JNIEXPORT void JNICALL Java_gnu_java_awt_peer_qt_QtTextFieldPeer_setCaretPosition (JNIEnv *env, jobject, jint);
+JNIEXPORT void JNICALL Java_gnu_java_awt_peer_qt_QtTextFieldPeer_setEchoChar (JNIEnv *env, jobject, jchar);
+JNIEXPORT void JNICALL Java_gnu_java_awt_peer_qt_QtTextFieldPeer_setEditable (JNIEnv *env, jobject, jboolean);
+JNIEXPORT void JNICALL Java_gnu_java_awt_peer_qt_QtTextFieldPeer_setText (JNIEnv *env, jobject, jstring);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* __gnu_java_awt_peer_qt_QtTextFieldPeer__ */
--- /dev/null
+/* DO NOT EDIT THIS FILE - it is machine generated */
+
+#ifndef __gnu_java_awt_peer_qt_QtToolkit__
+#define __gnu_java_awt_peer_qt_QtToolkit__
+
+#include <jni.h>
+
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+
+JNIEXPORT jobjectArray JNICALL Java_gnu_java_awt_peer_qt_QtToolkit_nativeFontFamilies (JNIEnv *env, jobject);
+JNIEXPORT jint JNICALL Java_gnu_java_awt_peer_qt_QtToolkit_numScreens (JNIEnv *env, jobject);
+JNIEXPORT jint JNICALL Java_gnu_java_awt_peer_qt_QtToolkit_defaultScreen (JNIEnv *env, jobject);
+JNIEXPORT void JNICALL Java_gnu_java_awt_peer_qt_QtToolkit_beep (JNIEnv *env, jobject);
+JNIEXPORT jobject JNICALL Java_gnu_java_awt_peer_qt_QtToolkit_getScreenSize (JNIEnv *env, jobject);
+JNIEXPORT jint JNICALL Java_gnu_java_awt_peer_qt_QtToolkit_getScreenResolution (JNIEnv *env, jobject);
+JNIEXPORT void JNICALL Java_gnu_java_awt_peer_qt_QtToolkit_sync (JNIEnv *env, jobject);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* __gnu_java_awt_peer_qt_QtToolkit__ */
--- /dev/null
+/* DO NOT EDIT THIS FILE - it is machine generated */
+
+#ifndef __gnu_java_awt_peer_qt_QtVolatileImage__
+#define __gnu_java_awt_peer_qt_QtVolatileImage__
+
+#include <jni.h>
+
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+
+JNIEXPORT void JNICALL Java_gnu_java_awt_peer_qt_QtVolatileImage_clear (JNIEnv *env, jobject);
+JNIEXPORT jintArray JNICALL Java_gnu_java_awt_peer_qt_QtVolatileImage_getPixels (JNIEnv *env, jobject);
+JNIEXPORT void JNICALL Java_gnu_java_awt_peer_qt_QtVolatileImage_createImage (JNIEnv *env, jobject);
+JNIEXPORT void JNICALL Java_gnu_java_awt_peer_qt_QtVolatileImage_freeImage (JNIEnv *env, jobject);
+JNIEXPORT void JNICALL Java_gnu_java_awt_peer_qt_QtVolatileImage_blit__Lgnu_java_awt_peer_qt_QtImage_2 (JNIEnv *env, jobject, jobject);
+JNIEXPORT void JNICALL Java_gnu_java_awt_peer_qt_QtVolatileImage_blit__Lgnu_java_awt_peer_qt_QtImage_2IIII (JNIEnv *env, jobject, jobject, jint, jint, jint, jint);
+JNIEXPORT void JNICALL Java_gnu_java_awt_peer_qt_QtVolatileImage_createScaledImage (JNIEnv *env, jobject, jobject, jint);
+JNIEXPORT void JNICALL Java_gnu_java_awt_peer_qt_QtVolatileImage_drawPixels (JNIEnv *env, jobject, jobject, jint, jint, jint, jint, jint, jboolean);
+JNIEXPORT void JNICALL Java_gnu_java_awt_peer_qt_QtVolatileImage_drawPixelsScaled (JNIEnv *env, jobject, jobject, jint, jint, jint, jint, jint, jint, jint, jboolean);
+JNIEXPORT void JNICALL Java_gnu_java_awt_peer_qt_QtVolatileImage_drawPixelsTransformed (JNIEnv *env, jobject, jobject, jobject);
+JNIEXPORT void JNICALL Java_gnu_java_awt_peer_qt_QtVolatileImage_drawPixelsScaledFlipped (JNIEnv *env, jobject, jobject, jint, jint, jint, jboolean, jboolean, jint, jint, jint, jint, jint, jint, jint, jint, jboolean);
+JNIEXPORT void JNICALL Java_gnu_java_awt_peer_qt_QtVolatileImage_copyArea (JNIEnv *env, jobject, jint, jint, jint, jint, jint, jint);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* __gnu_java_awt_peer_qt_QtVolatileImage__ */
--- /dev/null
+/* DO NOT EDIT THIS FILE - it is machine generated */
+
+#ifndef __gnu_java_awt_peer_qt_QtWindowPeer__
+#define __gnu_java_awt_peer_qt_QtWindowPeer__
+
+#include <jni.h>
+
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+
+JNIEXPORT void JNICALL Java_gnu_java_awt_peer_qt_QtWindowPeer_init (JNIEnv *env, jobject);
+JNIEXPORT void JNICALL Java_gnu_java_awt_peer_qt_QtWindowPeer_toBack (JNIEnv *env, jobject);
+JNIEXPORT void JNICALL Java_gnu_java_awt_peer_qt_QtWindowPeer_toFront (JNIEnv *env, jobject);
+JNIEXPORT void JNICALL Java_gnu_java_awt_peer_qt_QtWindowPeer_setTitle (JNIEnv *env, jobject, jstring);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* __gnu_java_awt_peer_qt_QtWindowPeer__ */
--- /dev/null
+/* jawt.h -- the machine-independent parts of the AWT Native Interface
+ 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., 51 Franklin Street, Fifth Floor, Boston, MA
+ 02110-1301 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. */
+
+
+/*
+ * The AWT Native Interface allows direct access to native screen
+ * resources from within a Canvas's paint method.
+ */
+
+#ifndef __jawt_h__
+#define __jawt_h__
+
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+
+#define JAWT_VERSION_1_3 0x10003
+#define JAWT_VERSION_1_4 0x10004
+
+#define JAWT_LOCK_ERROR 0x1
+#define JAWT_LOCK_CLIP_CHANGED 0x2
+#define JAWT_LOCK_BOUNDS_CHANGED 0x4
+#define JAWT_LOCK_SURFACE_CHANGED 0x8
+
+struct _JAWT_Rectangle
+{
+ jint x;
+ jint y;
+ jint width;
+ jint height;
+};
+
+struct _JAWT_DrawingSurfaceInfo
+{
+ void* platformInfo;
+ struct _JAWT_DrawingSurface *ds;
+ struct _JAWT_Rectangle bounds;
+ jint clipSize;
+ struct _JAWT_Rectangle *clip;
+};
+
+struct _JAWT_DrawingSurface
+{
+ JNIEnv* env;
+ jobject target;
+ jint (JNICALL* Lock) (struct _JAWT_DrawingSurface*);
+ struct _JAWT_DrawingSurfaceInfo* (JNICALL* GetDrawingSurfaceInfo) (struct _JAWT_DrawingSurface*);
+ void (JNICALL* FreeDrawingSurfaceInfo) (struct _JAWT_DrawingSurfaceInfo*);
+ void (JNICALL* Unlock) (struct _JAWT_DrawingSurface*);
+};
+
+struct _JAWT
+{
+ jint version;
+ struct _JAWT_DrawingSurface* (JNICALL* GetDrawingSurface) (JNIEnv*, jobject);
+ void (JNICALL* FreeDrawingSurface) (struct _JAWT_DrawingSurface*);
+ void (JNICALL *Lock) (JNIEnv*);
+ void (JNICALL *Unlock) (JNIEnv*);
+ jobject (JNICALL *GetComponent)(JNIEnv*, void*);
+};
+
+typedef struct _JAWT_Rectangle JAWT_Rectangle;
+typedef struct _JAWT_DrawingSurfaceInfo JAWT_DrawingSurfaceInfo;
+typedef struct _JAWT_DrawingSurface JAWT_DrawingSurface;
+typedef struct _JAWT JAWT;
+
+JNIEXPORT jboolean JNICALL JAWT_GetAWT (JNIEnv* env, struct _JAWT* awt);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* __jawt_h__ */
--- /dev/null
+/* jawt_md.h -- the X11-dependent parts of the AWT Native Interface
+ 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., 51 Franklin Street, Fifth Floor, Boston, MA
+ 02110-1301 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. */
+
+
+#ifndef __jawt_md_h__
+#define __jawt_md_h__
+
+#include <jni.h>
+#include <jawt.h>
+#include <X11/Xlib.h>
+
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+
+struct _JAWT_X11DrawingSurfaceInfo
+{
+ Drawable drawable;
+ Display* display;
+ VisualID visualID;
+ Colormap colormapID;
+ int depth;
+ int (JNICALL *GetAWTColor)(struct _JAWT_DrawingSurface*, int, int, int);
+};
+
+typedef struct _JAWT_X11DrawingSurfaceInfo JAWT_X11DrawingSurfaceInfo;
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* __jawt_md_h__ */
--- /dev/null
+/* FlavorEvent -- Event indicating a ClipBoard has different flavors available.
+ 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., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 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 java.awt.datatransfer;
+
+import java.util.EventObject;
+
+/**
+ * Event indicating a Clipboard has different flavors available.
+ * Fired by a ClipBoard for registered FlavorListeners.
+ *
+ * @author Mark J. Wielaard (mark@klomp.org)
+ */
+public class FlavorEvent extends EventObject
+{
+ public FlavorEvent(Clipboard board)
+ {
+ super(board);
+ }
+}
--- /dev/null
+/* FlavorListener -- Interface for tagging an interest in FlavorEvents.
+ 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., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 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 java.awt.datatransfer;
+
+import java.util.EventListener;
+
+/**
+ * Interface for tagging an interest in FlavorEvents by a class. The
+ * flavorsChanged() method will be called with a FlavorEvent pointing
+ * to the Clipboard which has content in different Flavors available.
+ *
+ * @author Mark J. Wielaard (mark@klomp.org)
+ */
+public interface FlavorListener
+ extends EventListener
+{
+ void flavorsChanged(FlavorEvent event);
+}
--- /dev/null
+/* MetalInternalFrameTitlePane.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., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 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 javax.swing.plaf.metal;
+
+import java.awt.Container;
+import java.awt.Dimension;
+import java.awt.Graphics;
+import java.awt.LayoutManager;
+
+import javax.swing.Icon;
+import javax.swing.JInternalFrame;
+import javax.swing.JMenu;
+import javax.swing.plaf.basic.BasicInternalFrameTitlePane;
+
+/**
+ * The title pane for a {@link JInternalFrame}.
+ */
+public class MetalInternalFrameTitlePane extends BasicInternalFrameTitlePane
+{
+
+ protected boolean isPalette;
+
+ protected Icon paletteCloseIcon = MetalIconFactory.getInternalFrameCloseIcon(16);
+
+ protected int paletteTitleHeight = 12;
+
+ /**
+ * Creates a new title pane.
+ *
+ * @param f the internal frame.
+ */
+ public MetalInternalFrameTitlePane(JInternalFrame f)
+ {
+ super(f);
+ isPalette = false;
+ }
+
+ /**
+ * Fetches the colors used in the title pane.
+ */
+ protected void installDefaults()
+ {
+ super.installDefaults();
+ selectedTextColor = MetalLookAndFeel.getControlTextColor();
+ selectedTitleColor = MetalLookAndFeel.getWindowTitleBackground();
+ notSelectedTextColor = MetalLookAndFeel.getInactiveControlTextColor();
+ notSelectedTitleColor = MetalLookAndFeel.getWindowTitleInactiveBackground();
+ }
+
+ /**
+ * Clears the colors used for the title pane.
+ */
+ protected void uninstallDefaults()
+ {
+ super.uninstallDefaults();
+ selectedTextColor = null;
+ selectedTitleColor = null;
+ notSelectedTextColor = null;
+ notSelectedTitleColor = null;
+ }
+
+ /**
+ * Calls the super class to create the buttons, then calls
+ * <code>setBorderPainted(false)</code> and
+ * <code>setContentAreaFilled(false)</code> for each button.
+ */
+ protected void createButtons()
+ {
+ super.createButtons();
+ closeButton.setBorderPainted(false);
+ closeButton.setContentAreaFilled(false);
+ iconButton.setBorderPainted(false);
+ iconButton.setContentAreaFilled(false);
+ maxButton.setBorderPainted(false);
+ maxButton.setContentAreaFilled(false);
+ }
+
+ /**
+ * Overridden to do nothing.
+ */
+ protected void addSystemMenuItems(JMenu systemMenu)
+ {
+ // do nothing
+ }
+
+ /**
+ * Overridden to do nothing.
+ */
+ protected void showSystemMenu()
+ {
+ // do nothing
+ }
+
+ /**
+ * Creates a layout manager for the components in the title pane.
+ *
+ * @return A layout manager.
+ */
+ protected LayoutManager createLayout()
+ {
+ return new TitlePaneLayout()
+ {
+ public Dimension preferredLayoutSize(Container c)
+ {
+ return new Dimension(24, 24);
+ }
+ };
+ }
+
+ public void paintPalette(Graphics g)
+ {
+ // FIXME: needs implementing
+ // most likely this is equivalent to paintComponent(g) when the isPalette
+ // flag is true
+ }
+
+ public void paintComponent(Graphics g)
+ {
+ // probably need to check the isPalette flag here, if true pass over to
+ // paintPalette(Graphics)
+ super.paintComponent(g);
+ Dimension d = getSize();
+ if (frame.isSelected())
+ g.setColor(MetalLookAndFeel.getPrimaryControlDarkShadow());
+ else
+ g.setColor(MetalLookAndFeel.getControlDarkShadow());
+ g.drawLine(0, d.height - 1, d.width - 1, d.height - 1);
+ }
+
+ public void setPalette(boolean b)
+ {
+ isPalette = b;
+ }
+}
+
--- /dev/null
+/* MultiButtonUI.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., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 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 javax.swing.plaf.multi;
+
+import java.awt.Dimension;
+import java.awt.Graphics;
+import java.util.Iterator;
+import java.util.Vector;
+
+import javax.accessibility.Accessible;
+import javax.swing.JComponent;
+import javax.swing.LookAndFeel;
+import javax.swing.UIManager;
+import javax.swing.plaf.ButtonUI;
+import javax.swing.plaf.ComponentUI;
+
+/**
+ * A UI delegate that that coordinates multiple {@link ButtonUI} instances, one
+ * from the primary look and feel, and one or more from the auxiliary look and
+ * feel(s).
+ *
+ * @see UIManager#addAuxiliaryLookAndFeel(LookAndFeel)
+ */
+public class MultiButtonUI extends ButtonUI
+{
+
+ /** A list of references to the actual component UIs. */
+ protected Vector uis;
+
+ /**
+ * Creates a new <code>MultiButtonUI</code> instance.
+ *
+ * @see #createUI(JComponent)
+ */
+ public MultiButtonUI()
+ {
+ uis = new Vector();
+ }
+
+ /**
+ * Creates a delegate object for the specified component. If any auxiliary
+ * look and feels support this component, a <code>MultiButtonUI</code> is
+ * returned, otherwise the UI from the default look and feel is returned.
+ *
+ * @param target the component.
+ *
+ * @see MultiLookAndFeel#createUIs(ComponentUI, Vector, JComponent)
+ */
+ public static ComponentUI createUI(JComponent target)
+ {
+ MultiButtonUI mui = new MultiButtonUI();
+ return MultiLookAndFeel.createUIs(mui, mui.uis, target);
+ }
+
+ /**
+ * Calls the {@link ComponentUI#installUI(JComponent)} method for all
+ * the UI delegates managed by this <code>MultiButtonUI</code>.
+ *
+ * @param c the component.
+ */
+ public void installUI(JComponent c)
+ {
+ Iterator iterator = uis.iterator();
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ ui.installUI(c);
+ }
+ }
+
+ /**
+ * Calls the {@link ComponentUI#uninstallUI(JComponent)} method for all
+ * the UI delegates managed by this <code>MultiButtonUI</code>.
+ *
+ * @param c the component.
+ */
+ public void uninstallUI(JComponent c)
+ {
+ Iterator iterator = uis.iterator();
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ ui.uninstallUI(c);
+ }
+ }
+
+ /**
+ * Returns an array containing the UI delegates managed by this
+ * <code>MultiButtonUI</code>. The first item in the array is always
+ * the UI delegate from the installed default look and feel.
+ *
+ * @return An array of UI delegates.
+ */
+ public ComponentUI[] getUIs()
+ {
+ return MultiLookAndFeel.uisToArray(uis);
+ }
+
+ /**
+ * Calls the {@link ComponentUI#contains(JComponent, int, int)} method for all
+ * the UI delegates managed by this <code>MultiButtonUI</code>,
+ * returning the result for the UI delegate from the primary look and
+ * feel.
+ *
+ * @param c the component.
+ * @param x the x-coordinate.
+ * @param y the y-coordinate.
+ *
+ * @return <code>true</code> if the specified (x, y) coordinate falls within
+ * the bounds of the component as rendered by the UI delegate in the
+ * primary look and feel, and <code>false</code> otherwise.
+ */
+ public boolean contains(JComponent c, int x, int y)
+ {
+ boolean result = false;
+ Iterator iterator = uis.iterator();
+ // first UI delegate provides the return value
+ if (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ result = ui.contains(c, x, y);
+ }
+ // return values from auxiliary UI delegates are ignored
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ /* boolean ignored = */ ui.contains(c, x, y);
+ }
+ return result;
+ }
+
+ /**
+ * Calls the {@link ComponentUI#update(Graphics, JComponent)} method for all
+ * the UI delegates managed by this <code>MultiButtonUI</code>.
+ *
+ * @param g the graphics device.
+ * @param c the component.
+ */
+ public void update(Graphics g, JComponent c)
+ {
+ Iterator iterator = uis.iterator();
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ ui.update(g, c);
+ }
+ }
+
+ /**
+ * Calls the <code>paint(Graphics, JComponent)</code> method for all the UI
+ * delegates managed by this <code>MultiButtonUI</code>.
+ *
+ * @param g the graphics device.
+ * @param c the component.
+ */
+ public void paint(Graphics g, JComponent c)
+ {
+ Iterator iterator = uis.iterator();
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ ui.paint(g, c);
+ }
+ }
+
+ /**
+ * Calls the {@link ComponentUI#getPreferredSize(JComponent)} method for all
+ * the UI delegates managed by this <code>MultiButtonUI</code>,
+ * returning the preferred size for the UI delegate from the primary look and
+ * feel.
+ *
+ * @param c the component.
+ *
+ * @return The preferred size returned by the UI delegate from the primary
+ * look and feel.
+ */
+ public Dimension getPreferredSize(JComponent c)
+ {
+ Dimension result = null;
+ Iterator iterator = uis.iterator();
+ // first UI delegate provides the return value
+ if (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ result = ui.getPreferredSize(c);
+ }
+ // return values from auxiliary UI delegates are ignored
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ /* Dimension ignored = */ ui.getPreferredSize(c);
+ }
+ return result;
+ }
+
+ /**
+ * Calls the {@link ComponentUI#getMinimumSize(JComponent)} method for all
+ * the UI delegates managed by this <code>MultiButtonUI</code>,
+ * returning the minimum size for the UI delegate from the primary look and
+ * feel.
+ *
+ * @param c the component.
+ *
+ * @return The minimum size returned by the UI delegate from the primary
+ * look and feel.
+ */
+ public Dimension getMinimumSize(JComponent c)
+ {
+ Dimension result = null;
+ Iterator iterator = uis.iterator();
+ // first UI delegate provides the return value
+ if (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ result = ui.getMinimumSize(c);
+ }
+ // return values from auxiliary UI delegates are ignored
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ /* Dimension ignored = */ ui.getMinimumSize(c);
+ }
+ return result;
+ }
+
+ /**
+ * Calls the {@link ComponentUI#getMaximumSize(JComponent)} method for all
+ * the UI delegates managed by this <code>MultiButtonUI</code>,
+ * returning the maximum size for the UI delegate from the primary look and
+ * feel.
+ *
+ * @param c the component.
+ *
+ * @return The maximum size returned by the UI delegate from the primary
+ * look and feel.
+ */
+ public Dimension getMaximumSize(JComponent c)
+ {
+ Dimension result = null;
+ Iterator iterator = uis.iterator();
+ // first UI delegate provides the return value
+ if (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ result = ui.getMaximumSize(c);
+ }
+ // return values from auxiliary UI delegates are ignored
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ /* Dimension ignored = */ ui.getMaximumSize(c);
+ }
+ return result;
+ }
+
+ /**
+ * Calls the {@link ComponentUI#getAccessibleChildrenCount(JComponent)} method
+ * for all the UI delegates managed by this <code>MultiButtonUI</code>,
+ * returning the count for the UI delegate from the primary look and
+ * feel.
+ *
+ * @param c the component.
+ *
+ * @return The count returned by the UI delegate from the primary
+ * look and feel.
+ */
+ public int getAccessibleChildrenCount(JComponent c)
+ {
+ int result = 0;
+ Iterator iterator = uis.iterator();
+ // first UI delegate provides the return value
+ if (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ result = ui.getAccessibleChildrenCount(c);
+ }
+ // return values from auxiliary UI delegates are ignored
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ /* int ignored = */ ui.getAccessibleChildrenCount(c);
+ }
+ return result;
+ }
+
+ /**
+ * Calls the {@link ComponentUI#getAccessibleChild(JComponent, int)} method
+ * for all the UI delegates managed by this <code>MultiButtonUI</code>,
+ * returning the child for the UI delegate from the primary look and
+ * feel.
+ *
+ * @param c the component
+ * @param i the child index.
+ *
+ * @return The child returned by the UI delegate from the primary
+ * look and feel.
+ */
+ public Accessible getAccessibleChild(JComponent c, int i)
+ {
+ Accessible result = null;
+ Iterator iterator = uis.iterator();
+ // first UI delegate provides the return value
+ if (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ result = ui.getAccessibleChild(c, i);
+ }
+ // return values from auxiliary UI delegates are ignored
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ /* Accessible ignored = */ ui.getAccessibleChild(c, i);
+ }
+ return result;
+ }
+
+}
\ No newline at end of file
--- /dev/null
+/* MultiColorChooserUI.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., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 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 javax.swing.plaf.multi;
+
+import java.awt.Dimension;
+import java.awt.Graphics;
+import java.util.Iterator;
+import java.util.Vector;
+
+import javax.accessibility.Accessible;
+import javax.swing.JComponent;
+import javax.swing.LookAndFeel;
+import javax.swing.UIManager;
+import javax.swing.plaf.ColorChooserUI;
+import javax.swing.plaf.ComponentUI;
+
+/**
+ * A UI delegate that that coordinates multiple {@link ColorChooserUI}
+ * instances, one from the primary look and feel, and one or more from the
+ * auxiliary look and feel(s).
+ *
+ * @see UIManager#addAuxiliaryLookAndFeel(LookAndFeel)
+ */
+public class MultiColorChooserUI extends ColorChooserUI
+{
+
+ /** A list of references to the actual component UIs. */
+ protected Vector uis;
+
+ /**
+ * Creates a new <code>MultiColorChooserUI</code> instance.
+ *
+ * @see #createUI(JComponent)
+ */
+ public MultiColorChooserUI()
+ {
+ uis = new Vector();
+ }
+
+ /**
+ * Creates a delegate object for the specified component. If any auxiliary
+ * look and feels support this component, a <code>MultiColorChooserUI</code>
+ * is returned, otherwise the UI from the default look and feel is returned.
+ *
+ * @param target the component.
+ *
+ * @see MultiLookAndFeel#createUIs(ComponentUI, Vector, JComponent)
+ */
+ public static ComponentUI createUI(JComponent target)
+ {
+ MultiColorChooserUI mui = new MultiColorChooserUI();
+ return MultiLookAndFeel.createUIs(mui, mui.uis, target);
+ }
+
+ /**
+ * Calls the {@link ComponentUI#installUI(JComponent)} method for all
+ * the UI delegates managed by this <code>MultiColorChooserUI</code>.
+ *
+ * @param c the component.
+ */
+ public void installUI(JComponent c)
+ {
+ Iterator iterator = uis.iterator();
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ ui.installUI(c);
+ }
+ }
+
+ /**
+ * Calls the {@link ComponentUI#uninstallUI(JComponent)} method for all
+ * the UI delegates managed by this <code>MultiColorChooserUI</code>.
+ *
+ * @param c the component.
+ */
+ public void uninstallUI(JComponent c)
+ {
+ Iterator iterator = uis.iterator();
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ ui.uninstallUI(c);
+ }
+ }
+
+ /**
+ * Returns an array containing the UI delegates managed by this
+ * <code>MultiColorChooserUI</code>. The first item in the array is always
+ * the UI delegate from the installed default look and feel.
+ *
+ * @return An array of UI delegates.
+ */
+ public ComponentUI[] getUIs()
+ {
+ return MultiLookAndFeel.uisToArray(uis);
+ }
+
+ /**
+ * Calls the {@link ComponentUI#contains(JComponent, int, int)} method for all
+ * the UI delegates managed by this <code>MultiColorChooserUI</code>,
+ * returning the result for the UI delegate from the primary look and
+ * feel.
+ *
+ * @param c the component.
+ * @param x the x-coordinate.
+ * @param y the y-coordinate.
+ *
+ * @return <code>true</code> if the specified (x, y) coordinate falls within
+ * the bounds of the component as rendered by the UI delegate in the
+ * primary look and feel, and <code>false</code> otherwise.
+ */
+ public boolean contains(JComponent c, int x, int y)
+ {
+ boolean result = false;
+ Iterator iterator = uis.iterator();
+ // first UI delegate provides the return value
+ if (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ result = ui.contains(c, x, y);
+ }
+ // return values from auxiliary UI delegates are ignored
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ /* boolean ignored = */ ui.contains(c, x, y);
+ }
+ return result;
+ }
+
+ /**
+ * Calls the {@link ComponentUI#update(Graphics, JComponent)} method for all
+ * the UI delegates managed by this <code>MultiColorChooserUI</code>.
+ *
+ * @param g the graphics device.
+ * @param c the component.
+ */
+ public void update(Graphics g, JComponent c)
+ {
+ Iterator iterator = uis.iterator();
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ ui.update(g, c);
+ }
+ }
+
+ /**
+ * Calls the <code>paint(Graphics, JComponent)</code> method for all the UI
+ * delegates managed by this <code>MultiColorChooserUI</code>.
+ *
+ * @param g the graphics device.
+ * @param c the component.
+ */
+ public void paint(Graphics g, JComponent c)
+ {
+ Iterator iterator = uis.iterator();
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ ui.paint(g, c);
+ }
+ }
+
+ /**
+ * Calls the {@link ComponentUI#getPreferredSize(JComponent)} method for all
+ * the UI delegates managed by this <code>MultiColorChooserUI</code>,
+ * returning the preferred size for the UI delegate from the primary look and
+ * feel.
+ *
+ * @param c the component.
+ *
+ * @return The preferred size returned by the UI delegate from the primary
+ * look and feel.
+ */
+ public Dimension getPreferredSize(JComponent c)
+ {
+ Dimension result = null;
+ Iterator iterator = uis.iterator();
+ // first UI delegate provides the return value
+ if (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ result = ui.getPreferredSize(c);
+ }
+ // return values from auxiliary UI delegates are ignored
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ /* Dimension ignored = */ ui.getPreferredSize(c);
+ }
+ return result;
+ }
+
+ /**
+ * Calls the {@link ComponentUI#getMinimumSize(JComponent)} method for all
+ * the UI delegates managed by this <code>MultiColorChooserUI</code>,
+ * returning the minimum size for the UI delegate from the primary look and
+ * feel.
+ *
+ * @param c the component.
+ *
+ * @return The minimum size returned by the UI delegate from the primary
+ * look and feel.
+ */
+ public Dimension getMinimumSize(JComponent c)
+ {
+ Dimension result = null;
+ Iterator iterator = uis.iterator();
+ // first UI delegate provides the return value
+ if (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ result = ui.getMinimumSize(c);
+ }
+ // return values from auxiliary UI delegates are ignored
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ /* Dimension ignored = */ ui.getMinimumSize(c);
+ }
+ return result;
+ }
+
+ /**
+ * Calls the {@link ComponentUI#getMaximumSize(JComponent)} method for all
+ * the UI delegates managed by this <code>MultiColorChooserUI</code>,
+ * returning the maximum size for the UI delegate from the primary look and
+ * feel.
+ *
+ * @param c the component.
+ *
+ * @return The maximum size returned by the UI delegate from the primary
+ * look and feel.
+ */
+ public Dimension getMaximumSize(JComponent c)
+ {
+ Dimension result = null;
+ Iterator iterator = uis.iterator();
+ // first UI delegate provides the return value
+ if (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ result = ui.getMaximumSize(c);
+ }
+ // return values from auxiliary UI delegates are ignored
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ /* Dimension ignored = */ ui.getMaximumSize(c);
+ }
+ return result;
+ }
+
+ /**
+ * Calls the {@link ComponentUI#getAccessibleChildrenCount(JComponent)} method
+ * for all the UI delegates managed by this <code>MultiColorChooserUI</code>,
+ * returning the count for the UI delegate from the primary look and
+ * feel.
+ *
+ * @param c the component.
+ *
+ * @return The count returned by the UI delegate from the primary
+ * look and feel.
+ */
+ public int getAccessibleChildrenCount(JComponent c)
+ {
+ int result = 0;
+ Iterator iterator = uis.iterator();
+ // first UI delegate provides the return value
+ if (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ result = ui.getAccessibleChildrenCount(c);
+ }
+ // return values from auxiliary UI delegates are ignored
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ /* int ignored = */ ui.getAccessibleChildrenCount(c);
+ }
+ return result;
+ }
+
+ /**
+ * Calls the {@link ComponentUI#getAccessibleChild(JComponent, int)} method
+ * for all the UI delegates managed by this <code>MultiColorChooserUI</code>,
+ * returning the child for the UI delegate from the primary look and
+ * feel.
+ *
+ * @param c the component
+ * @param i the child index.
+ *
+ * @return The child returned by the UI delegate from the primary
+ * look and feel.
+ */
+ public Accessible getAccessibleChild(JComponent c, int i)
+ {
+ Accessible result = null;
+ Iterator iterator = uis.iterator();
+ // first UI delegate provides the return value
+ if (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ result = ui.getAccessibleChild(c, i);
+ }
+ // return values from auxiliary UI delegates are ignored
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ /* Accessible ignored = */ ui.getAccessibleChild(c, i);
+ }
+ return result;
+ }
+
+}
--- /dev/null
+/* MultiComboBoxUI.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., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 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 javax.swing.plaf.multi;
+
+import java.awt.Dimension;
+import java.awt.Graphics;
+import java.util.Iterator;
+import java.util.Vector;
+
+import javax.accessibility.Accessible;
+import javax.swing.JComboBox;
+import javax.swing.JComponent;
+import javax.swing.LookAndFeel;
+import javax.swing.UIManager;
+import javax.swing.plaf.ComboBoxUI;
+import javax.swing.plaf.ComponentUI;
+
+/**
+ * A UI delegate that that coordinates multiple {@link ComboBoxUI}
+ * instances, one from the primary look and feel, and one or more from the
+ * auxiliary look and feel(s).
+ *
+ * @see UIManager#addAuxiliaryLookAndFeel(LookAndFeel)
+ */
+public class MultiComboBoxUI extends ComboBoxUI
+{
+
+ /** A list of references to the actual component UIs. */
+ protected Vector uis;
+
+ /**
+ * Creates a new <code>MultiComboBoxUI</code> instance.
+ *
+ * @see #createUI(JComponent)
+ */
+ public MultiComboBoxUI()
+ {
+ uis = new Vector();
+ }
+
+ /**
+ * Creates a delegate object for the specified component. If any auxiliary
+ * look and feels support this component, a <code>MultiComboBoxUI</code>
+ * is returned, otherwise the UI from the default look and feel is returned.
+ *
+ * @param target the component.
+ *
+ * @see MultiLookAndFeel#createUIs(ComponentUI, Vector, JComponent)
+ */
+ public static ComponentUI createUI(JComponent target)
+ {
+ MultiComboBoxUI mui = new MultiComboBoxUI();
+ return MultiLookAndFeel.createUIs(mui, mui.uis, target);
+ }
+
+ /**
+ * Calls the {@link ComponentUI#installUI(JComponent)} method for all
+ * the UI delegates managed by this <code>MultiComboBoxUI</code>.
+ *
+ * @param c the component.
+ */
+ public void installUI(JComponent c)
+ {
+ Iterator iterator = uis.iterator();
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ ui.installUI(c);
+ }
+ }
+
+ /**
+ * Calls the {@link ComponentUI#uninstallUI(JComponent)} method for all
+ * the UI delegates managed by this <code>MultiComboBoxUI</code>.
+ *
+ * @param c the component.
+ */
+ public void uninstallUI(JComponent c)
+ {
+ Iterator iterator = uis.iterator();
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ ui.uninstallUI(c);
+ }
+ }
+
+ /**
+ * Returns an array containing the UI delegates managed by this
+ * <code>MultiComboBoxUI</code>. The first item in the array is always
+ * the UI delegate from the installed default look and feel.
+ *
+ * @return An array of UI delegates.
+ */
+ public ComponentUI[] getUIs()
+ {
+ return MultiLookAndFeel.uisToArray(uis);
+ }
+
+ /**
+ * Calls the {@link ComponentUI#contains(JComponent, int, int)} method for all
+ * the UI delegates managed by this <code>MultiComboBoxUI</code>,
+ * returning the result for the UI delegate from the primary look and
+ * feel.
+ *
+ * @param c the component.
+ * @param x the x-coordinate.
+ * @param y the y-coordinate.
+ *
+ * @return <code>true</code> if the specified (x, y) coordinate falls within
+ * the bounds of the component as rendered by the UI delegate in the
+ * primary look and feel, and <code>false</code> otherwise.
+ */
+ public boolean contains(JComponent c, int x, int y)
+ {
+ boolean result = false;
+ Iterator iterator = uis.iterator();
+ // first UI delegate provides the return value
+ if (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ result = ui.contains(c, x, y);
+ }
+ // return values from auxiliary UI delegates are ignored
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ /* boolean ignored = */ ui.contains(c, x, y);
+ }
+ return result;
+ }
+
+ /**
+ * Calls the {@link ComponentUI#update(Graphics, JComponent)} method for all
+ * the UI delegates managed by this <code>MultiComboBoxUI</code>.
+ *
+ * @param g the graphics device.
+ * @param c the component.
+ */
+ public void update(Graphics g, JComponent c)
+ {
+ Iterator iterator = uis.iterator();
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ ui.update(g, c);
+ }
+ }
+
+ /**
+ * Calls the <code>paint(Graphics, JComponent)</code> method for all the UI
+ * delegates managed by this <code>MultiComboBoxUI</code>.
+ *
+ * @param g the graphics device.
+ * @param c the component.
+ */
+ public void paint(Graphics g, JComponent c)
+ {
+ Iterator iterator = uis.iterator();
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ ui.paint(g, c);
+ }
+ }
+
+ /**
+ * Calls the {@link ComponentUI#getPreferredSize(JComponent)} method for all
+ * the UI delegates managed by this <code>MultiComboBoxUI</code>,
+ * returning the preferred size for the UI delegate from the primary look and
+ * feel.
+ *
+ * @param c the component.
+ *
+ * @return The preferred size returned by the UI delegate from the primary
+ * look and feel.
+ */
+ public Dimension getPreferredSize(JComponent c)
+ {
+ Dimension result = null;
+ Iterator iterator = uis.iterator();
+ // first UI delegate provides the return value
+ if (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ result = ui.getPreferredSize(c);
+ }
+ // return values from auxiliary UI delegates are ignored
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ /* Dimension ignored = */ ui.getPreferredSize(c);
+ }
+ return result;
+ }
+
+ /**
+ * Calls the {@link ComponentUI#getMinimumSize(JComponent)} method for all
+ * the UI delegates managed by this <code>MultiComboBoxUI</code>,
+ * returning the minimum size for the UI delegate from the primary look and
+ * feel.
+ *
+ * @param c the component.
+ *
+ * @return The minimum size returned by the UI delegate from the primary
+ * look and feel.
+ */
+ public Dimension getMinimumSize(JComponent c)
+ {
+ Dimension result = null;
+ Iterator iterator = uis.iterator();
+ // first UI delegate provides the return value
+ if (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ result = ui.getMinimumSize(c);
+ }
+ // return values from auxiliary UI delegates are ignored
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ /* Dimension ignored = */ ui.getMinimumSize(c);
+ }
+ return result;
+ }
+
+ /**
+ * Calls the {@link ComponentUI#getMaximumSize(JComponent)} method for all
+ * the UI delegates managed by this <code>MultiComboBoxUI</code>,
+ * returning the maximum size for the UI delegate from the primary look and
+ * feel.
+ *
+ * @param c the component.
+ *
+ * @return The maximum size returned by the UI delegate from the primary
+ * look and feel.
+ */
+ public Dimension getMaximumSize(JComponent c)
+ {
+ Dimension result = null;
+ Iterator iterator = uis.iterator();
+ // first UI delegate provides the return value
+ if (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ result = ui.getMaximumSize(c);
+ }
+ // return values from auxiliary UI delegates are ignored
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ /* Dimension ignored = */ ui.getMaximumSize(c);
+ }
+ return result;
+ }
+
+ /**
+ * Calls the {@link ComponentUI#getAccessibleChildrenCount(JComponent)} method
+ * for all the UI delegates managed by this <code>MultiComboBoxUI</code>,
+ * returning the count for the UI delegate from the primary look and
+ * feel.
+ *
+ * @param c the component.
+ *
+ * @return The count returned by the UI delegate from the primary
+ * look and feel.
+ */
+ public int getAccessibleChildrenCount(JComponent c)
+ {
+ int result = 0;
+ Iterator iterator = uis.iterator();
+ // first UI delegate provides the return value
+ if (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ result = ui.getAccessibleChildrenCount(c);
+ }
+ // return values from auxiliary UI delegates are ignored
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ /* int ignored = */ ui.getAccessibleChildrenCount(c);
+ }
+ return result;
+ }
+
+ /**
+ * Calls the {@link ComponentUI#getAccessibleChild(JComponent, int)} method
+ * for all the UI delegates managed by this <code>MultiComboBoxUI</code>,
+ * returning the child for the UI delegate from the primary look and
+ * feel.
+ *
+ * @param c the component
+ * @param i the child index.
+ *
+ * @return The child returned by the UI delegate from the primary
+ * look and feel.
+ */
+ public Accessible getAccessibleChild(JComponent c, int i)
+ {
+ Accessible result = null;
+ Iterator iterator = uis.iterator();
+ // first UI delegate provides the return value
+ if (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ result = ui.getAccessibleChild(c, i);
+ }
+ // return values from auxiliary UI delegates are ignored
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ /* Accessible ignored = */ ui.getAccessibleChild(c, i);
+ }
+ return result;
+ }
+
+ /**
+ * Calls the {@link ComboBoxUI#setPopupVisible(JComboBox, boolean)} method
+ * for all the UI delegates managed by this <code>MultiComboBoxUI</code>.
+ *
+ * @param c the component.
+ * @param visible the visible state.
+ */
+ public void setPopupVisible(JComboBox c, boolean visible) {
+ Iterator iterator = uis.iterator();
+ while (iterator.hasNext())
+ {
+ ComboBoxUI ui = (ComboBoxUI) iterator.next();
+ ui.setPopupVisible(c, visible);
+ }
+ }
+
+ /**
+ * Calls the {@link ComboBoxUI#isPopupVisible(JComboBox)} method for all
+ * the UI delegates managed by this <code>MultiComboBoxUI</code>,
+ * returning the result for the UI delegate from the primary look and
+ * feel.
+ *
+ * @param c the component.
+ *
+ * @return The result for the UI delegate from the primary look and feel.
+ */
+ public boolean isPopupVisible(JComboBox c) {
+ boolean result = false;
+ Iterator iterator = uis.iterator();
+ // first UI delegate provides the return value
+ if (iterator.hasNext())
+ {
+ ComboBoxUI ui = (ComboBoxUI) iterator.next();
+ result = ui.isPopupVisible(c);
+ }
+ // return values from auxiliary UI delegates are ignored
+ while (iterator.hasNext())
+ {
+ ComboBoxUI ui = (ComboBoxUI) iterator.next();
+ /* boolean ignored = */ ui.isPopupVisible(c);
+ }
+ return result;
+ }
+
+ /**
+ * Calls the {@link ComboBoxUI#isFocusTraversable(JComboBox)} method for all
+ * the UI delegates managed by this <code>MultiComboBoxUI</code>,
+ * returning the result for the UI delegate from the primary look and
+ * feel.
+ *
+ * @param c the component.
+ *
+ * @return <code>true</code> if the combo box is traversable according to the
+ * UI delegate in the primary look and feel, and <code>false</code>
+ * otherwise.
+ */
+ public boolean isFocusTraversable(JComboBox c) {
+ boolean result = false;
+ Iterator iterator = uis.iterator();
+ // first UI delegate provides the return value
+ if (iterator.hasNext())
+ {
+ ComboBoxUI ui = (ComboBoxUI) iterator.next();
+ result = ui.isFocusTraversable(c);
+ }
+ // return values from auxiliary UI delegates are ignored
+ while (iterator.hasNext())
+ {
+ ComboBoxUI ui = (ComboBoxUI) iterator.next();
+ /* boolean ignored = */ ui.isFocusTraversable(c);
+ }
+ return result;
+ }
+
+}
--- /dev/null
+/* MultiDesktopIconUI.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., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 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 javax.swing.plaf.multi;
+
+import java.awt.Dimension;
+import java.awt.Graphics;
+import java.util.Iterator;
+import java.util.Vector;
+
+import javax.accessibility.Accessible;
+import javax.swing.JComponent;
+import javax.swing.LookAndFeel;
+import javax.swing.UIManager;
+import javax.swing.plaf.ComponentUI;
+import javax.swing.plaf.DesktopIconUI;
+
+/**
+ * A UI delegate that that coordinates multiple {@link DesktopIconUI}
+ * instances, one from the primary look and feel, and one or more from the
+ * auxiliary look and feel(s).
+ *
+ * @see UIManager#addAuxiliaryLookAndFeel(LookAndFeel)
+ */
+public class MultiDesktopIconUI extends DesktopIconUI
+{
+
+ /** A list of references to the actual component UIs. */
+ protected Vector uis;
+
+ /**
+ * Creates a new <code>MultiDesktopIconUI</code> instance.
+ *
+ * @see #createUI(JComponent)
+ */
+ public MultiDesktopIconUI()
+ {
+ uis = new Vector();
+ }
+
+ /**
+ * Creates a delegate object for the specified component. If any auxiliary
+ * look and feels support this component, a <code>MultiDesktopIconUI</code> is
+ * returned, otherwise the UI from the default look and feel is returned.
+ *
+ * @param target the component.
+ *
+ * @see MultiLookAndFeel#createUIs(ComponentUI, Vector, JComponent)
+ */
+ public static ComponentUI createUI(JComponent target)
+ {
+ MultiDesktopIconUI mui = new MultiDesktopIconUI();
+ return MultiLookAndFeel.createUIs(mui, mui.uis, target);
+ }
+
+ /**
+ * Calls the {@link ComponentUI#installUI(JComponent)} method for all
+ * the UI delegates managed by this <code>MultiDesktopIconUI</code>.
+ *
+ * @param c the component.
+ */
+ public void installUI(JComponent c)
+ {
+ Iterator iterator = uis.iterator();
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ ui.installUI(c);
+ }
+ }
+
+ /**
+ * Calls the {@link ComponentUI#uninstallUI(JComponent)} method for all
+ * the UI delegates managed by this <code>MultiDesktopIconUI</code>.
+ *
+ * @param c the component.
+ */
+ public void uninstallUI(JComponent c)
+ {
+ Iterator iterator = uis.iterator();
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ ui.uninstallUI(c);
+ }
+ }
+
+ /**
+ * Returns an array containing the UI delegates managed by this
+ * <code>MultiDesktopIconUI</code>. The first item in the array is always
+ * the UI delegate from the installed default look and feel.
+ *
+ * @return An array of UI delegates.
+ */
+ public ComponentUI[] getUIs()
+ {
+ return MultiLookAndFeel.uisToArray(uis);
+ }
+
+ /**
+ * Calls the {@link ComponentUI#contains(JComponent, int, int)} method for all
+ * the UI delegates managed by this <code>MultiDesktopIconUI</code>,
+ * returning the result for the UI delegate from the primary look and
+ * feel.
+ *
+ * @param c the component.
+ * @param x the x-coordinate.
+ * @param y the y-coordinate.
+ *
+ * @return <code>true</code> if the specified (x, y) coordinate falls within
+ * the bounds of the component as rendered by the UI delegate in the
+ * primary look and feel, and <code>false</code> otherwise.
+ */
+ public boolean contains(JComponent c, int x, int y)
+ {
+ boolean result = false;
+ Iterator iterator = uis.iterator();
+ // first UI delegate provides the return value
+ if (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ result = ui.contains(c, x, y);
+ }
+ // return values from auxiliary UI delegates are ignored
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ /* boolean ignored = */ ui.contains(c, x, y);
+ }
+ return result;
+ }
+
+ /**
+ * Calls the {@link ComponentUI#update(Graphics, JComponent)} method for all
+ * the UI delegates managed by this <code>MultiDesktopIconUI</code>.
+ *
+ * @param g the graphics device.
+ * @param c the component.
+ */
+ public void update(Graphics g, JComponent c)
+ {
+ Iterator iterator = uis.iterator();
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ ui.update(g, c);
+ }
+ }
+
+ /**
+ * Calls the <code>paint(Graphics, JComponent)</code> method for all the UI
+ * delegates managed by this <code>MultiDesktopIconUI</code>.
+ *
+ * @param g the graphics device.
+ * @param c the component.
+ */
+ public void paint(Graphics g, JComponent c)
+ {
+ Iterator iterator = uis.iterator();
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ ui.paint(g, c);
+ }
+ }
+
+ /**
+ * Calls the {@link ComponentUI#getPreferredSize(JComponent)} method for all
+ * the UI delegates managed by this <code>MultiDesktopIconUI</code>,
+ * returning the preferred size for the UI delegate from the primary look and
+ * feel.
+ *
+ * @param c the component.
+ *
+ * @return The preferred size returned by the UI delegate from the primary
+ * look and feel.
+ */
+ public Dimension getPreferredSize(JComponent c)
+ {
+ Dimension result = null;
+ Iterator iterator = uis.iterator();
+ // first UI delegate provides the return value
+ if (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ result = ui.getPreferredSize(c);
+ }
+ // return values from auxiliary UI delegates are ignored
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ /* Dimension ignored = */ ui.getPreferredSize(c);
+ }
+ return result;
+ }
+
+ /**
+ * Calls the {@link ComponentUI#getMinimumSize(JComponent)} method for all
+ * the UI delegates managed by this <code>MultiDesktopIconUI</code>,
+ * returning the minimum size for the UI delegate from the primary look and
+ * feel.
+ *
+ * @param c the component.
+ *
+ * @return The minimum size returned by the UI delegate from the primary
+ * look and feel.
+ */
+ public Dimension getMinimumSize(JComponent c)
+ {
+ Dimension result = null;
+ Iterator iterator = uis.iterator();
+ // first UI delegate provides the return value
+ if (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ result = ui.getMinimumSize(c);
+ }
+ // return values from auxiliary UI delegates are ignored
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ /* Dimension ignored = */ ui.getMinimumSize(c);
+ }
+ return result;
+ }
+
+ /**
+ * Calls the {@link ComponentUI#getMaximumSize(JComponent)} method for all
+ * the UI delegates managed by this <code>MultiDesktopIconUI</code>,
+ * returning the maximum size for the UI delegate from the primary look and
+ * feel.
+ *
+ * @param c the component.
+ *
+ * @return The maximum size returned by the UI delegate from the primary
+ * look and feel.
+ */
+ public Dimension getMaximumSize(JComponent c)
+ {
+ Dimension result = null;
+ Iterator iterator = uis.iterator();
+ // first UI delegate provides the return value
+ if (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ result = ui.getMaximumSize(c);
+ }
+ // return values from auxiliary UI delegates are ignored
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ /* Dimension ignored = */ ui.getMaximumSize(c);
+ }
+ return result;
+ }
+
+ /**
+ * Calls the {@link ComponentUI#getAccessibleChildrenCount(JComponent)} method
+ * for all the UI delegates managed by this <code>MultiDesktopIconUI</code>,
+ * returning the count for the UI delegate from the primary look and
+ * feel.
+ *
+ * @param c the component.
+ *
+ * @return The count returned by the UI delegate from the primary
+ * look and feel.
+ */
+ public int getAccessibleChildrenCount(JComponent c)
+ {
+ int result = 0;
+ Iterator iterator = uis.iterator();
+ // first UI delegate provides the return value
+ if (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ result = ui.getAccessibleChildrenCount(c);
+ }
+ // return values from auxiliary UI delegates are ignored
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ /* int ignored = */ ui.getAccessibleChildrenCount(c);
+ }
+ return result;
+ }
+
+ /**
+ * Calls the {@link ComponentUI#getAccessibleChild(JComponent, int)} method
+ * for all the UI delegates managed by this <code>MultiDesktopIconUI</code>,
+ * returning the child for the UI delegate from the primary look and
+ * feel.
+ *
+ * @param c the component
+ * @param i the child index.
+ *
+ * @return The child returned by the UI delegate from the primary
+ * look and feel.
+ */
+ public Accessible getAccessibleChild(JComponent c, int i)
+ {
+ Accessible result = null;
+ Iterator iterator = uis.iterator();
+ // first UI delegate provides the return value
+ if (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ result = ui.getAccessibleChild(c, i);
+ }
+ // return values from auxiliary UI delegates are ignored
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ /* Accessible ignored = */ ui.getAccessibleChild(c, i);
+ }
+ return result;
+ }
+
+}
--- /dev/null
+/* MultiDesktopIconUI.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., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 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 javax.swing.plaf.multi;
+
+import java.awt.Dimension;
+import java.awt.Graphics;
+import java.util.Iterator;
+import java.util.Vector;
+
+import javax.accessibility.Accessible;
+import javax.swing.JComponent;
+import javax.swing.LookAndFeel;
+import javax.swing.UIManager;
+import javax.swing.plaf.ComponentUI;
+import javax.swing.plaf.DesktopPaneUI;
+
+/**
+ * A UI delegate that that coordinates multiple {@link DesktopPaneUI}
+ * instances, one from the primary look and feel, and one or more from the
+ * auxiliary look and feel(s).
+ *
+ * @see UIManager#addAuxiliaryLookAndFeel(LookAndFeel)
+ */
+public class MultiDesktopPaneUI extends DesktopPaneUI
+{
+
+ /** A list of references to the actual component UIs. */
+ protected Vector uis;
+
+ /**
+ * Creates a new <code>MultiDesktopPaneUI</code> instance.
+ *
+ * @see #createUI(JComponent)
+ */
+ public MultiDesktopPaneUI()
+ {
+ uis = new Vector();
+ }
+
+ /**
+ * Creates a delegate object for the specified component. If any auxiliary
+ * look and feels support this component, a <code>MultiDesktopPaneUI</code> is
+ * returned, otherwise the UI from the default look and feel is returned.
+ *
+ * @param target the component.
+ *
+ * @see MultiLookAndFeel#createUIs(ComponentUI, Vector, JComponent)
+ */
+ public static ComponentUI createUI(JComponent target)
+ {
+ MultiDesktopPaneUI mui = new MultiDesktopPaneUI();
+ return MultiLookAndFeel.createUIs(mui, mui.uis, target);
+ }
+
+ /**
+ * Calls the {@link ComponentUI#installUI(JComponent)} method for all
+ * the UI delegates managed by this <code>MultiDesktopPaneUI</code>.
+ *
+ * @param c the component.
+ */
+ public void installUI(JComponent c)
+ {
+ Iterator iterator = uis.iterator();
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ ui.installUI(c);
+ }
+ }
+
+ /**
+ * Calls the {@link ComponentUI#uninstallUI(JComponent)} method for all
+ * the UI delegates managed by this <code>MultiDesktopPaneUI</code>.
+ *
+ * @param c the component.
+ */
+ public void uninstallUI(JComponent c)
+ {
+ Iterator iterator = uis.iterator();
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ ui.uninstallUI(c);
+ }
+ }
+
+ /**
+ * Returns an array containing the UI delegates managed by this
+ * <code>MultiDesktopPaneUI</code>. The first item in the array is always
+ * the UI delegate from the installed default look and feel.
+ *
+ * @return An array of UI delegates.
+ */
+ public ComponentUI[] getUIs()
+ {
+ return MultiLookAndFeel.uisToArray(uis);
+ }
+
+ /**
+ * Calls the {@link ComponentUI#contains(JComponent, int, int)} method for all
+ * the UI delegates managed by this <code>MultiDesktopPaneUI</code>,
+ * returning the result for the UI delegate from the primary look and
+ * feel.
+ *
+ * @param c the component.
+ * @param x the x-coordinate.
+ * @param y the y-coordinate.
+ *
+ * @return <code>true</code> if the specified (x, y) coordinate falls within
+ * the bounds of the component as rendered by the UI delegate in the
+ * primary look and feel, and <code>false</code> otherwise.
+ */
+ public boolean contains(JComponent c, int x, int y)
+ {
+ boolean result = false;
+ Iterator iterator = uis.iterator();
+ // first UI delegate provides the return value
+ if (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ result = ui.contains(c, x, y);
+ }
+ // return values from auxiliary UI delegates are ignored
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ /* boolean ignored = */ ui.contains(c, x, y);
+ }
+ return result;
+ }
+
+ /**
+ * Calls the {@link ComponentUI#update(Graphics, JComponent)} method for all
+ * the UI delegates managed by this <code>MultiDesktopPaneUI</code>.
+ *
+ * @param g the graphics device.
+ * @param c the component.
+ */
+ public void update(Graphics g, JComponent c)
+ {
+ Iterator iterator = uis.iterator();
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ ui.update(g, c);
+ }
+ }
+
+ /**
+ * Calls the <code>paint(Graphics, JComponent)</code> method for all the UI
+ * delegates managed by this <code>MultiDesktopPaneUI</code>.
+ *
+ * @param g the graphics device.
+ * @param c the component.
+ */
+ public void paint(Graphics g, JComponent c)
+ {
+ Iterator iterator = uis.iterator();
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ ui.paint(g, c);
+ }
+ }
+
+ /**
+ * Calls the {@link ComponentUI#getPreferredSize(JComponent)} method for all
+ * the UI delegates managed by this <code>MultiDesktopPaneUI</code>,
+ * returning the preferred size for the UI delegate from the primary look and
+ * feel.
+ *
+ * @param c the component.
+ *
+ * @return The preferred size returned by the UI delegate from the primary
+ * look and feel.
+ */
+ public Dimension getPreferredSize(JComponent c)
+ {
+ Dimension result = null;
+ Iterator iterator = uis.iterator();
+ // first UI delegate provides the return value
+ if (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ result = ui.getPreferredSize(c);
+ }
+ // return values from auxiliary UI delegates are ignored
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ /* Dimension ignored = */ ui.getPreferredSize(c);
+ }
+ return result;
+ }
+
+ /**
+ * Calls the {@link ComponentUI#getMinimumSize(JComponent)} method for all
+ * the UI delegates managed by this <code>MultiDesktopPaneUI</code>,
+ * returning the minimum size for the UI delegate from the primary look and
+ * feel.
+ *
+ * @param c the component.
+ *
+ * @return The minimum size returned by the UI delegate from the primary
+ * look and feel.
+ */
+ public Dimension getMinimumSize(JComponent c)
+ {
+ Dimension result = null;
+ Iterator iterator = uis.iterator();
+ // first UI delegate provides the return value
+ if (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ result = ui.getMinimumSize(c);
+ }
+ // return values from auxiliary UI delegates are ignored
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ /* Dimension ignored = */ ui.getMinimumSize(c);
+ }
+ return result;
+ }
+
+ /**
+ * Calls the {@link ComponentUI#getMaximumSize(JComponent)} method for all
+ * the UI delegates managed by this <code>MultiDesktopPaneUI</code>,
+ * returning the maximum size for the UI delegate from the primary look and
+ * feel.
+ *
+ * @param c the component.
+ *
+ * @return The maximum size returned by the UI delegate from the primary
+ * look and feel.
+ */
+ public Dimension getMaximumSize(JComponent c)
+ {
+ Dimension result = null;
+ Iterator iterator = uis.iterator();
+ // first UI delegate provides the return value
+ if (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ result = ui.getMaximumSize(c);
+ }
+ // return values from auxiliary UI delegates are ignored
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ /* Dimension ignored = */ ui.getMaximumSize(c);
+ }
+ return result;
+ }
+
+ /**
+ * Calls the {@link ComponentUI#getAccessibleChildrenCount(JComponent)} method
+ * for all the UI delegates managed by this <code>MultiDesktopPaneUI</code>,
+ * returning the count for the UI delegate from the primary look and
+ * feel.
+ *
+ * @param c the component.
+ *
+ * @return The count returned by the UI delegate from the primary
+ * look and feel.
+ */
+ public int getAccessibleChildrenCount(JComponent c)
+ {
+ int result = 0;
+ Iterator iterator = uis.iterator();
+ // first UI delegate provides the return value
+ if (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ result = ui.getAccessibleChildrenCount(c);
+ }
+ // return values from auxiliary UI delegates are ignored
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ /* int ignored = */ ui.getAccessibleChildrenCount(c);
+ }
+ return result;
+ }
+
+ /**
+ * Calls the {@link ComponentUI#getAccessibleChild(JComponent, int)} method
+ * for all the UI delegates managed by this <code>MultiDesktopPaneUI</code>,
+ * returning the child for the UI delegate from the primary look and
+ * feel.
+ *
+ * @param c the component
+ * @param i the child index.
+ *
+ * @return The child returned by the UI delegate from the primary
+ * look and feel.
+ */
+ public Accessible getAccessibleChild(JComponent c, int i)
+ {
+ Accessible result = null;
+ Iterator iterator = uis.iterator();
+ // first UI delegate provides the return value
+ if (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ result = ui.getAccessibleChild(c, i);
+ }
+ // return values from auxiliary UI delegates are ignored
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ /* Accessible ignored = */ ui.getAccessibleChild(c, i);
+ }
+ return result;
+ }
+
+}
--- /dev/null
+/* MultiFileChooserUI.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., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 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 javax.swing.plaf.multi;
+
+import java.awt.Dimension;
+import java.awt.Graphics;
+import java.io.File;
+import java.util.Iterator;
+import java.util.Vector;
+
+import javax.accessibility.Accessible;
+import javax.swing.JComponent;
+import javax.swing.JFileChooser;
+import javax.swing.LookAndFeel;
+import javax.swing.UIManager;
+import javax.swing.filechooser.FileFilter;
+import javax.swing.filechooser.FileView;
+import javax.swing.plaf.ComponentUI;
+import javax.swing.plaf.FileChooserUI;
+
+/**
+ * A UI delegate that that coordinates multiple {@link FileChooserUI}
+ * instances, one from the primary look and feel, and one or more from the
+ * auxiliary look and feel(s).
+ *
+ * @see UIManager#addAuxiliaryLookAndFeel(LookAndFeel)
+ */
+public class MultiFileChooserUI extends FileChooserUI
+{
+
+ /** A list of references to the actual component UIs. */
+ protected Vector uis;
+
+ /**
+ * Creates a new <code>MultiFileChooserUI</code> instance.
+ *
+ * @see #createUI(JComponent)
+ */
+ public MultiFileChooserUI()
+ {
+ uis = new Vector();
+ }
+
+ /**
+ * Creates a delegate object for the specified component. If any auxiliary
+ * look and feels support this component, a <code>MultiFileChooserUI</code> is
+ * returned, otherwise the UI from the default look and feel is returned.
+ *
+ * @param target the component.
+ *
+ * @see MultiLookAndFeel#createUIs(ComponentUI, Vector, JComponent)
+ */
+ public static ComponentUI createUI(JComponent target)
+ {
+ MultiFileChooserUI mui = new MultiFileChooserUI();
+ return MultiLookAndFeel.createUIs(mui, mui.uis, target);
+ }
+
+ /**
+ * Calls the {@link ComponentUI#installUI(JComponent)} method for all
+ * the UI delegates managed by this <code>MultiFileChooserUI</code>.
+ *
+ * @param c the component.
+ */
+ public void installUI(JComponent c)
+ {
+ Iterator iterator = uis.iterator();
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ ui.installUI(c);
+ }
+ }
+
+ /**
+ * Calls the {@link ComponentUI#uninstallUI(JComponent)} method for all
+ * the UI delegates managed by this <code>MultiFileChooserUI</code>.
+ *
+ * @param c the component.
+ */
+ public void uninstallUI(JComponent c)
+ {
+ Iterator iterator = uis.iterator();
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ ui.uninstallUI(c);
+ }
+ }
+
+ /**
+ * Returns an array containing the UI delegates managed by this
+ * <code>MultiFileChooserUI</code>. The first item in the array is always
+ * the UI delegate from the installed default look and feel.
+ *
+ * @return An array of UI delegates.
+ */
+ public ComponentUI[] getUIs()
+ {
+ return MultiLookAndFeel.uisToArray(uis);
+ }
+
+ /**
+ * Calls the {@link ComponentUI#contains(JComponent, int, int)} method for all
+ * the UI delegates managed by this <code>MultiFileChooserUI</code>,
+ * returning the result for the UI delegate from the primary look and
+ * feel.
+ *
+ * @param c the component.
+ * @param x the x-coordinate.
+ * @param y the y-coordinate.
+ *
+ * @return <code>true</code> if the specified (x, y) coordinate falls within
+ * the bounds of the component as rendered by the UI delegate in the
+ * primary look and feel, and <code>false</code> otherwise.
+ */
+ public boolean contains(JComponent c, int x, int y)
+ {
+ boolean result = false;
+ Iterator iterator = uis.iterator();
+ // first UI delegate provides the return value
+ if (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ result = ui.contains(c, x, y);
+ }
+ // return values from auxiliary UI delegates are ignored
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ /* boolean ignored = */ ui.contains(c, x, y);
+ }
+ return result;
+ }
+
+ /**
+ * Calls the {@link ComponentUI#update(Graphics, JComponent)} method for all
+ * the UI delegates managed by this <code>MultiFileChooserUI</code>.
+ *
+ * @param g the graphics device.
+ * @param c the component.
+ */
+ public void update(Graphics g, JComponent c)
+ {
+ Iterator iterator = uis.iterator();
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ ui.update(g, c);
+ }
+ }
+
+ /**
+ * Calls the <code>paint(Graphics, JComponent)</code> method for all the UI
+ * delegates managed by this <code>MultiFileChooserUI</code>.
+ *
+ * @param g the graphics device.
+ * @param c the component.
+ */
+ public void paint(Graphics g, JComponent c)
+ {
+ Iterator iterator = uis.iterator();
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ ui.paint(g, c);
+ }
+ }
+
+ /**
+ * Calls the {@link ComponentUI#getPreferredSize(JComponent)} method for all
+ * the UI delegates managed by this <code>MultiFileChooserUI</code>,
+ * returning the preferred size for the UI delegate from the primary look and
+ * feel.
+ *
+ * @param c the component.
+ *
+ * @return The preferred size returned by the UI delegate from the primary
+ * look and feel.
+ */
+ public Dimension getPreferredSize(JComponent c)
+ {
+ Dimension result = null;
+ Iterator iterator = uis.iterator();
+ // first UI delegate provides the return value
+ if (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ result = ui.getPreferredSize(c);
+ }
+ // return values from auxiliary UI delegates are ignored
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ /* Dimension ignored = */ ui.getPreferredSize(c);
+ }
+ return result;
+ }
+
+ /**
+ * Calls the {@link ComponentUI#getMinimumSize(JComponent)} method for all
+ * the UI delegates managed by this <code>MultiFileChooserUI</code>,
+ * returning the minimum size for the UI delegate from the primary look and
+ * feel.
+ *
+ * @param c the component.
+ *
+ * @return The minimum size returned by the UI delegate from the primary
+ * look and feel.
+ */
+ public Dimension getMinimumSize(JComponent c)
+ {
+ Dimension result = null;
+ Iterator iterator = uis.iterator();
+ // first UI delegate provides the return value
+ if (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ result = ui.getMinimumSize(c);
+ }
+ // return values from auxiliary UI delegates are ignored
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ /* Dimension ignored = */ ui.getMinimumSize(c);
+ }
+ return result;
+ }
+
+ /**
+ * Calls the {@link ComponentUI#getMaximumSize(JComponent)} method for all
+ * the UI delegates managed by this <code>MultiFileChooserUI</code>,
+ * returning the maximum size for the UI delegate from the primary look and
+ * feel.
+ *
+ * @param c the component.
+ *
+ * @return The maximum size returned by the UI delegate from the primary
+ * look and feel.
+ */
+ public Dimension getMaximumSize(JComponent c)
+ {
+ Dimension result = null;
+ Iterator iterator = uis.iterator();
+ // first UI delegate provides the return value
+ if (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ result = ui.getMaximumSize(c);
+ }
+ // return values from auxiliary UI delegates are ignored
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ /* Dimension ignored = */ ui.getMaximumSize(c);
+ }
+ return result;
+ }
+
+ /**
+ * Calls the {@link ComponentUI#getAccessibleChildrenCount(JComponent)} method
+ * for all the UI delegates managed by this <code>MultiFileChooserUI</code>,
+ * returning the count for the UI delegate from the primary look and
+ * feel.
+ *
+ * @param c the component.
+ *
+ * @return The count returned by the UI delegate from the primary
+ * look and feel.
+ */
+ public int getAccessibleChildrenCount(JComponent c)
+ {
+ int result = 0;
+ Iterator iterator = uis.iterator();
+ // first UI delegate provides the return value
+ if (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ result = ui.getAccessibleChildrenCount(c);
+ }
+ // return values from auxiliary UI delegates are ignored
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ /* int ignored = */ ui.getAccessibleChildrenCount(c);
+ }
+ return result;
+ }
+
+ /**
+ * Calls the {@link ComponentUI#getAccessibleChild(JComponent, int)} method
+ * for all the UI delegates managed by this <code>MultiFileChooserUI</code>,
+ * returning the child for the UI delegate from the primary look and
+ * feel.
+ *
+ * @param c the component
+ * @param i the child index.
+ *
+ * @return The child returned by the UI delegate from the primary
+ * look and feel.
+ */
+ public Accessible getAccessibleChild(JComponent c, int i)
+ {
+ Accessible result = null;
+ Iterator iterator = uis.iterator();
+ // first UI delegate provides the return value
+ if (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ result = ui.getAccessibleChild(c, i);
+ }
+ // return values from auxiliary UI delegates are ignored
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ /* Accessible ignored = */ ui.getAccessibleChild(c, i);
+ }
+ return result;
+ }
+
+ /**
+ * Calls the {@link FileChooserUI#getAcceptAllFileFilter(JFileChooser)} method
+ * for all the UI delegates managed by this <code>MultiFileChooserUI</code>,
+ * returning the filter for the UI delegate from the primary look and
+ * feel.
+ *
+ * @param chooser the file chooser.
+ *
+ * @return The filter returned by the UI delegate from the primary
+ * look and feel.
+ */
+ public FileFilter getAcceptAllFileFilter(JFileChooser chooser) {
+ FileFilter result = null;
+ Iterator iterator = uis.iterator();
+ // first UI delegate provides the return value
+ if (iterator.hasNext())
+ {
+ FileChooserUI ui = (FileChooserUI) iterator.next();
+ result = ui.getAcceptAllFileFilter(chooser);
+ }
+ // return values from auxiliary UI delegates are ignored
+ while (iterator.hasNext())
+ {
+ FileChooserUI ui = (FileChooserUI) iterator.next();
+ /* FileFilter ignored = */ ui.getAcceptAllFileFilter(chooser);
+ }
+ return result;
+ }
+
+ /**
+ * Calls the {@link FileChooserUI#getFileView(JFileChooser)} method
+ * for all the UI delegates managed by this <code>MultiFileChooserUI</code>,
+ * returning the view for the UI delegate from the primary look and
+ * feel.
+ *
+ * @param chooser the file chooser.
+ *
+ * @return The view returned by the UI delegate from the primary
+ * look and feel.
+ */
+ public FileView getFileView(JFileChooser chooser) {
+ FileView result = null;
+ Iterator iterator = uis.iterator();
+ // first UI delegate provides the return value
+ if (iterator.hasNext())
+ {
+ FileChooserUI ui = (FileChooserUI) iterator.next();
+ result = ui.getFileView(chooser);
+ }
+ // return values from auxiliary UI delegates are ignored
+ while (iterator.hasNext())
+ {
+ FileChooserUI ui = (FileChooserUI) iterator.next();
+ /* FileView ignored = */ ui.getFileView(chooser);
+ }
+ return result;
+ }
+
+ /**
+ * Calls the {@link FileChooserUI#getApproveButtonText(JFileChooser)} method
+ * for all the UI delegates managed by this <code>MultiFileChooserUI</code>,
+ * returning the text for the UI delegate from the primary look and
+ * feel.
+ *
+ * @param chooser the file chooser.
+ *
+ * @return The text returned by the UI delegate from the primary
+ * look and feel.
+ */
+ public String getApproveButtonText(JFileChooser chooser) {
+ String result = null;
+ Iterator iterator = uis.iterator();
+ // first UI delegate provides the return value
+ if (iterator.hasNext())
+ {
+ FileChooserUI ui = (FileChooserUI) iterator.next();
+ result = ui.getApproveButtonText(chooser);
+ }
+ // return values from auxiliary UI delegates are ignored
+ while (iterator.hasNext())
+ {
+ FileChooserUI ui = (FileChooserUI) iterator.next();
+ /* String ignored = */ ui.getApproveButtonText(chooser);
+ }
+ return result;
+ }
+
+ /**
+ * Calls the {@link FileChooserUI#getDialogTitle(JFileChooser)} method
+ * for all the UI delegates managed by this <code>MultiFileChooserUI</code>,
+ * returning the title for the UI delegate from the primary look and
+ * feel.
+ *
+ * @param chooser the file chooser.
+ *
+ * @return The title returned by the UI delegate from the primary
+ * look and feel.
+ */
+ public String getDialogTitle(JFileChooser chooser) {
+ String result = null;
+ Iterator iterator = uis.iterator();
+ // first UI delegate provides the return value
+ if (iterator.hasNext())
+ {
+ FileChooserUI ui = (FileChooserUI) iterator.next();
+ result = ui.getDialogTitle(chooser);
+ }
+ // return values from auxiliary UI delegates are ignored
+ while (iterator.hasNext())
+ {
+ FileChooserUI ui = (FileChooserUI) iterator.next();
+ /* String ignored = */ ui.getDialogTitle(chooser);
+ }
+ return result;
+ }
+
+ /**
+ * Calls the {@link FileChooserUI#rescanCurrentDirectory(JFileChooser)}
+ * method for all the UI delegates managed by this
+ * <code>MultiFileChooserUI</code>.
+ *
+ * @param chooser the file chooser.
+ */
+ public void rescanCurrentDirectory(JFileChooser chooser) {
+ Iterator iterator = uis.iterator();
+ while (iterator.hasNext())
+ {
+ FileChooserUI ui = (FileChooserUI) iterator.next();
+ ui.rescanCurrentDirectory(chooser);
+ }
+ }
+
+ /**
+ * Calls the {@link FileChooserUI#ensureFileIsVisible(JFileChooser, File)}
+ * method for all the UI delegates managed by this
+ * <code>MultiFileChooserUI</code>.
+ *
+ * @param chooser the file chooser.
+ * @param file the file.
+ */
+ public void ensureFileIsVisible(JFileChooser chooser, File file) {
+ Iterator iterator = uis.iterator();
+ while (iterator.hasNext())
+ {
+ FileChooserUI ui = (FileChooserUI) iterator.next();
+ ui.ensureFileIsVisible(chooser, file);
+ }
+ }
+
+}
--- /dev/null
+/* MultiInternalFrameUI.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., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 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 javax.swing.plaf.multi;
+
+import java.awt.Dimension;
+import java.awt.Graphics;
+import java.util.Iterator;
+import java.util.Vector;
+
+import javax.accessibility.Accessible;
+import javax.swing.JComponent;
+import javax.swing.LookAndFeel;
+import javax.swing.UIManager;
+import javax.swing.plaf.ComponentUI;
+import javax.swing.plaf.InternalFrameUI;
+
+/**
+ * A UI delegate that that coordinates multiple {@link InternalFrameUI}
+ * instances, one from the primary look and feel, and one or more from the
+ * auxiliary look and feel(s).
+ *
+ * @see UIManager#addAuxiliaryLookAndFeel(LookAndFeel)
+ */
+public class MultiInternalFrameUI extends InternalFrameUI
+{
+
+ /** A list of references to the actual component UIs. */
+ protected Vector uis;
+
+ /**
+ * Creates a new <code>MultiInternalFrameUI</code> instance.
+ *
+ * @see #createUI(JComponent)
+ */
+ public MultiInternalFrameUI()
+ {
+ uis = new Vector();
+ }
+
+ /**
+ * Creates a delegate object for the specified component. If any auxiliary
+ * look and feels support this component, a <code>MultiInternalFrameUI</code>
+ * is returned, otherwise the UI from the default look and feel is returned.
+ *
+ * @param target the component.
+ *
+ * @see MultiLookAndFeel#createUIs(ComponentUI, Vector, JComponent)
+ */
+ public static ComponentUI createUI(JComponent target)
+ {
+ MultiInternalFrameUI mui = new MultiInternalFrameUI();
+ return MultiLookAndFeel.createUIs(mui, mui.uis, target);
+ }
+
+
+ /**
+ * Calls the {@link ComponentUI#installUI(JComponent)} method for all
+ * the UI delegates managed by this <code>MultiInternalFrameUI</code>.
+ *
+ * @param c the component.
+ */
+ public void installUI(JComponent c)
+ {
+ Iterator iterator = uis.iterator();
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ ui.installUI(c);
+ }
+ }
+
+ /**
+ * Calls the {@link ComponentUI#uninstallUI(JComponent)} method for all
+ * the UI delegates managed by this <code>MultiInternalFrameUI</code>.
+ *
+ * @param c the component.
+ */
+ public void uninstallUI(JComponent c)
+ {
+ Iterator iterator = uis.iterator();
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ ui.uninstallUI(c);
+ }
+ }
+
+ /**
+ * Returns an array containing the UI delegates managed by this
+ * <code>MultiInternalFrameUI</code>. The first item in the array is always
+ * the UI delegate from the installed default look and feel.
+ *
+ * @return An array of UI delegates.
+ */
+ public ComponentUI[] getUIs()
+ {
+ return MultiLookAndFeel.uisToArray(uis);
+ }
+
+ /**
+ * Calls the {@link ComponentUI#contains(JComponent, int, int)} method for all
+ * the UI delegates managed by this <code>MultiInternalFrameUI</code>,
+ * returning the result for the UI delegate from the primary look and
+ * feel.
+ *
+ * @param c the component.
+ * @param x the x-coordinate.
+ * @param y the y-coordinate.
+ *
+ * @return <code>true</code> if the specified (x, y) coordinate falls within
+ * the bounds of the component as rendered by the UI delegate in the
+ * primary look and feel, and <code>false</code> otherwise.
+ */
+ public boolean contains(JComponent c, int x, int y)
+ {
+ boolean result = false;
+ Iterator iterator = uis.iterator();
+ // first UI delegate provides the return value
+ if (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ result = ui.contains(c, x, y);
+ }
+ // return values from auxiliary UI delegates are ignored
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ /* boolean ignored = */ ui.contains(c, x, y);
+ }
+ return result;
+ }
+
+ /**
+ * Calls the {@link ComponentUI#update(Graphics, JComponent)} method for all
+ * the UI delegates managed by this <code>MultiInternalFrameUI</code>.
+ *
+ * @param g the graphics device.
+ * @param c the component.
+ */
+ public void update(Graphics g, JComponent c)
+ {
+ Iterator iterator = uis.iterator();
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ ui.update(g, c);
+ }
+ }
+
+ /**
+ * Calls the <code>paint(Graphics, JComponent)</code> method for all the UI
+ * delegates managed by this <code>MultiInternalFrameUI</code>.
+ *
+ * @param g the graphics device.
+ * @param c the component.
+ */
+ public void paint(Graphics g, JComponent c)
+ {
+ Iterator iterator = uis.iterator();
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ ui.paint(g, c);
+ }
+ }
+
+ /**
+ * Calls the {@link ComponentUI#getPreferredSize(JComponent)} method for all
+ * the UI delegates managed by this <code>MultiInternalFrameUI</code>,
+ * returning the preferred size for the UI delegate from the primary look and
+ * feel.
+ *
+ * @param c the component.
+ *
+ * @return The preferred size returned by the UI delegate from the primary
+ * look and feel.
+ */
+ public Dimension getPreferredSize(JComponent c)
+ {
+ Dimension result = null;
+ Iterator iterator = uis.iterator();
+ // first UI delegate provides the return value
+ if (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ result = ui.getPreferredSize(c);
+ }
+ // return values from auxiliary UI delegates are ignored
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ /* Dimension ignored = */ ui.getPreferredSize(c);
+ }
+ return result;
+ }
+
+ /**
+ * Calls the {@link ComponentUI#getMinimumSize(JComponent)} method for all
+ * the UI delegates managed by this <code>MultiInternalFrameUI</code>,
+ * returning the minimum size for the UI delegate from the primary look and
+ * feel.
+ *
+ * @param c the component.
+ *
+ * @return The minimum size returned by the UI delegate from the primary
+ * look and feel.
+ */
+ public Dimension getMinimumSize(JComponent c)
+ {
+ Dimension result = null;
+ Iterator iterator = uis.iterator();
+ // first UI delegate provides the return value
+ if (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ result = ui.getMinimumSize(c);
+ }
+ // return values from auxiliary UI delegates are ignored
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ /* Dimension ignored = */ ui.getMinimumSize(c);
+ }
+ return result;
+ }
+
+ /**
+ * Calls the {@link ComponentUI#getMaximumSize(JComponent)} method for all
+ * the UI delegates managed by this <code>MultiInternalFrameUI</code>,
+ * returning the maximum size for the UI delegate from the primary look and
+ * feel.
+ *
+ * @param c the component.
+ *
+ * @return The maximum size returned by the UI delegate from the primary
+ * look and feel.
+ */
+ public Dimension getMaximumSize(JComponent c)
+ {
+ Dimension result = null;
+ Iterator iterator = uis.iterator();
+ // first UI delegate provides the return value
+ if (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ result = ui.getMaximumSize(c);
+ }
+ // return values from auxiliary UI delegates are ignored
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ /* Dimension ignored = */ ui.getMaximumSize(c);
+ }
+ return result;
+ }
+
+ /**
+ * Calls the {@link ComponentUI#getAccessibleChildrenCount(JComponent)} method
+ * for all the UI delegates managed by this <code>MultiInternalFrameUI</code>,
+ * returning the count for the UI delegate from the primary look and
+ * feel.
+ *
+ * @param c the component.
+ *
+ * @return The count returned by the UI delegate from the primary
+ * look and feel.
+ */
+ public int getAccessibleChildrenCount(JComponent c)
+ {
+ int result = 0;
+ Iterator iterator = uis.iterator();
+ // first UI delegate provides the return value
+ if (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ result = ui.getAccessibleChildrenCount(c);
+ }
+ // return values from auxiliary UI delegates are ignored
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ /* int ignored = */ ui.getAccessibleChildrenCount(c);
+ }
+ return result;
+ }
+
+ /**
+ * Calls the {@link ComponentUI#getAccessibleChild(JComponent, int)} method
+ * for all the UI delegates managed by this <code>MultiInternalFrameUI</code>,
+ * returning the child for the UI delegate from the primary look and
+ * feel.
+ *
+ * @param c the component
+ * @param i the child index.
+ *
+ * @return The child returned by the UI delegate from the primary
+ * look and feel.
+ */
+ public Accessible getAccessibleChild(JComponent c, int i)
+ {
+ Accessible result = null;
+ Iterator iterator = uis.iterator();
+ // first UI delegate provides the return value
+ if (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ result = ui.getAccessibleChild(c, i);
+ }
+ // return values from auxiliary UI delegates are ignored
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ /* Accessible ignored = */ ui.getAccessibleChild(c, i);
+ }
+ return result;
+ }
+
+}
--- /dev/null
+/* MultiLabelUI.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., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 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 javax.swing.plaf.multi;
+
+import java.awt.Dimension;
+import java.awt.Graphics;
+import java.util.Iterator;
+import java.util.Vector;
+
+import javax.accessibility.Accessible;
+import javax.swing.JComponent;
+import javax.swing.LookAndFeel;
+import javax.swing.UIManager;
+import javax.swing.plaf.ComponentUI;
+import javax.swing.plaf.LabelUI;
+
+/**
+ * A UI delegate that that coordinates multiple {@link LabelUI}
+ * instances, one from the primary look and feel, and one or more from the
+ * auxiliary look and feel(s).
+ *
+ * @see UIManager#addAuxiliaryLookAndFeel(LookAndFeel)
+ */
+public class MultiLabelUI extends LabelUI
+{
+
+ /** A list of references to the actual component UIs. */
+ protected Vector uis;
+
+ /**
+ * Creates a new <code>MultiLabelUI</code> instance.
+ *
+ * @see #createUI(JComponent)
+ */
+ public MultiLabelUI()
+ {
+ uis = new Vector();
+ }
+
+ /**
+ * Creates a delegate object for the specified component. If any auxiliary
+ * look and feels support this component, a <code>MultiLabelUI</code> is
+ * returned, otherwise the UI from the default look and feel is returned.
+ *
+ * @param target the component.
+ *
+ * @see MultiLookAndFeel#createUIs(ComponentUI, Vector, JComponent)
+ */
+ public static ComponentUI createUI(JComponent target)
+ {
+ MultiLabelUI mui = new MultiLabelUI();
+ return MultiLookAndFeel.createUIs(mui, mui.uis, target);
+ }
+
+ /**
+ * Calls the {@link ComponentUI#installUI(JComponent)} method for all
+ * the UI delegates managed by this <code>MultiLabelUI</code>.
+ *
+ * @param c the component.
+ */
+ public void installUI(JComponent c)
+ {
+ Iterator iterator = uis.iterator();
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ ui.installUI(c);
+ }
+ }
+
+ /**
+ * Calls the {@link ComponentUI#uninstallUI(JComponent)} method for all
+ * the UI delegates managed by this <code>MultiLabelUI</code>.
+ *
+ * @param c the component.
+ */
+ public void uninstallUI(JComponent c)
+ {
+ Iterator iterator = uis.iterator();
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ ui.uninstallUI(c);
+ }
+ }
+
+ /**
+ * Returns an array containing the UI delegates managed by this
+ * <code>MultiLabelUI</code>. The first item in the array is always
+ * the UI delegate from the installed default look and feel.
+ *
+ * @return An array of UI delegates.
+ */
+ public ComponentUI[] getUIs()
+ {
+ return MultiLookAndFeel.uisToArray(uis);
+ }
+
+ /**
+ * Calls the {@link ComponentUI#contains(JComponent, int, int)} method for all
+ * the UI delegates managed by this <code>MultiLabelUI</code>,
+ * returning the result for the UI delegate from the primary look and
+ * feel.
+ *
+ * @param c the component.
+ * @param x the x-coordinate.
+ * @param y the y-coordinate.
+ *
+ * @return <code>true</code> if the specified (x, y) coordinate falls within
+ * the bounds of the component as rendered by the UI delegate in the
+ * primary look and feel, and <code>false</code> otherwise.
+ */
+ public boolean contains(JComponent c, int x, int y)
+ {
+ boolean result = false;
+ Iterator iterator = uis.iterator();
+ // first UI delegate provides the return value
+ if (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ result = ui.contains(c, x, y);
+ }
+ // return values from auxiliary UI delegates are ignored
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ /* boolean ignored = */ ui.contains(c, x, y);
+ }
+ return result;
+ }
+
+ /**
+ * Calls the {@link ComponentUI#update(Graphics, JComponent)} method for all
+ * the UI delegates managed by this <code>MultiLabelUI</code>.
+ *
+ * @param g the graphics device.
+ * @param c the component.
+ */
+ public void update(Graphics g, JComponent c)
+ {
+ Iterator iterator = uis.iterator();
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ ui.update(g, c);
+ }
+ }
+
+ /**
+ * Calls the <code>paint(Graphics, JComponent)</code> method for all the UI
+ * delegates managed by this <code>MultiLabelUI</code>.
+ *
+ * @param g the graphics device.
+ * @param c the component.
+ */
+ public void paint(Graphics g, JComponent c)
+ {
+ Iterator iterator = uis.iterator();
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ ui.paint(g, c);
+ }
+ }
+
+ /**
+ * Calls the {@link ComponentUI#getPreferredSize(JComponent)} method for all
+ * the UI delegates managed by this <code>MultiLabelUI</code>,
+ * returning the preferred size for the UI delegate from the primary look and
+ * feel.
+ *
+ * @param c the component.
+ *
+ * @return The preferred size returned by the UI delegate from the primary
+ * look and feel.
+ */
+ public Dimension getPreferredSize(JComponent c)
+ {
+ Dimension result = null;
+ Iterator iterator = uis.iterator();
+ // first UI delegate provides the return value
+ if (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ result = ui.getPreferredSize(c);
+ }
+ // return values from auxiliary UI delegates are ignored
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ /* Dimension ignored = */ ui.getPreferredSize(c);
+ }
+ return result;
+ }
+
+ /**
+ * Calls the {@link ComponentUI#getMinimumSize(JComponent)} method for all
+ * the UI delegates managed by this <code>MultiLabelUI</code>,
+ * returning the minimum size for the UI delegate from the primary look and
+ * feel.
+ *
+ * @param c the component.
+ *
+ * @return The minimum size returned by the UI delegate from the primary
+ * look and feel.
+ */
+ public Dimension getMinimumSize(JComponent c)
+ {
+ Dimension result = null;
+ Iterator iterator = uis.iterator();
+ // first UI delegate provides the return value
+ if (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ result = ui.getMinimumSize(c);
+ }
+ // return values from auxiliary UI delegates are ignored
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ /* Dimension ignored = */ ui.getMinimumSize(c);
+ }
+ return result;
+ }
+
+ /**
+ * Calls the {@link ComponentUI#getMaximumSize(JComponent)} method for all
+ * the UI delegates managed by this <code>MultiLabelUI</code>,
+ * returning the maximum size for the UI delegate from the primary look and
+ * feel.
+ *
+ * @param c the component.
+ *
+ * @return The maximum size returned by the UI delegate from the primary
+ * look and feel.
+ */
+ public Dimension getMaximumSize(JComponent c)
+ {
+ Dimension result = null;
+ Iterator iterator = uis.iterator();
+ // first UI delegate provides the return value
+ if (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ result = ui.getMaximumSize(c);
+ }
+ // return values from auxiliary UI delegates are ignored
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ /* Dimension ignored = */ ui.getMaximumSize(c);
+ }
+ return result;
+ }
+
+ /**
+ * Calls the {@link ComponentUI#getAccessibleChildrenCount(JComponent)} method
+ * for all the UI delegates managed by this <code>MultiLabelUI</code>,
+ * returning the count for the UI delegate from the primary look and
+ * feel.
+ *
+ * @param c the component.
+ *
+ * @return The count returned by the UI delegate from the primary
+ * look and feel.
+ */
+ public int getAccessibleChildrenCount(JComponent c)
+ {
+ int result = 0;
+ Iterator iterator = uis.iterator();
+ // first UI delegate provides the return value
+ if (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ result = ui.getAccessibleChildrenCount(c);
+ }
+ // return values from auxiliary UI delegates are ignored
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ /* int ignored = */ ui.getAccessibleChildrenCount(c);
+ }
+ return result;
+ }
+
+ /**
+ * Calls the {@link ComponentUI#getAccessibleChild(JComponent, int)} method
+ * for all the UI delegates managed by this <code>MultiLabelUI</code>,
+ * returning the child for the UI delegate from the primary look and
+ * feel.
+ *
+ * @param c the component
+ * @param i the child index.
+ *
+ * @return The child returned by the UI delegate from the primary
+ * look and feel.
+ */
+ public Accessible getAccessibleChild(JComponent c, int i)
+ {
+ Accessible result = null;
+ Iterator iterator = uis.iterator();
+ // first UI delegate provides the return value
+ if (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ result = ui.getAccessibleChild(c, i);
+ }
+ // return values from auxiliary UI delegates are ignored
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ /* Accessible ignored = */ ui.getAccessibleChild(c, i);
+ }
+ return result;
+ }
+
+}
--- /dev/null
+/* MultiListUI.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., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 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 javax.swing.plaf.multi;
+
+import java.awt.Dimension;
+import java.awt.Graphics;
+import java.awt.Point;
+import java.awt.Rectangle;
+import java.util.Iterator;
+import java.util.Vector;
+
+import javax.accessibility.Accessible;
+import javax.swing.JComponent;
+import javax.swing.JList;
+import javax.swing.LookAndFeel;
+import javax.swing.UIManager;
+import javax.swing.plaf.ComponentUI;
+import javax.swing.plaf.ListUI;
+
+/**
+ * A UI delegate that that coordinates multiple {@link ListUI}
+ * instances, one from the primary look and feel, and one or more from the
+ * auxiliary look and feel(s).
+ *
+ * @see UIManager#addAuxiliaryLookAndFeel(LookAndFeel)
+ */
+public class MultiListUI extends ListUI
+{
+
+ /** A list of references to the actual component UIs. */
+ protected Vector uis;
+
+ /**
+ * Creates a new <code>MultiListUI</code> instance.
+ *
+ * @see #createUI(JComponent)
+ */
+ public MultiListUI()
+ {
+ uis = new Vector();
+ }
+
+ /**
+ * Creates a delegate object for the specified component. If any auxiliary
+ * look and feels support this component, a <code>MultiListUI</code> is
+ * returned, otherwise the UI from the default look and feel is returned.
+ *
+ * @param target the component.
+ *
+ * @see MultiLookAndFeel#createUIs(ComponentUI, Vector, JComponent)
+ */
+ public static ComponentUI createUI(JComponent target)
+ {
+ MultiListUI mui = new MultiListUI();
+ return MultiLookAndFeel.createUIs(mui, mui.uis, target);
+ }
+
+ /**
+ * Calls the {@link ComponentUI#installUI(JComponent)} method for all
+ * the UI delegates managed by this <code>MultiListUI</code>.
+ *
+ * @param c the component.
+ */
+ public void installUI(JComponent c)
+ {
+ Iterator iterator = uis.iterator();
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ ui.installUI(c);
+ }
+ }
+
+ /**
+ * Calls the {@link ComponentUI#uninstallUI(JComponent)} method for all
+ * the UI delegates managed by this <code>MultiListUI</code>.
+ *
+ * @param c the component.
+ */
+ public void uninstallUI(JComponent c)
+ {
+ Iterator iterator = uis.iterator();
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ ui.uninstallUI(c);
+ }
+ }
+
+ /**
+ * Returns an array containing the UI delegates managed by this
+ * <code>MultiListUI</code>. The first item in the array is always
+ * the UI delegate from the installed default look and feel.
+ *
+ * @return An array of UI delegates.
+ */
+ public ComponentUI[] getUIs()
+ {
+ return MultiLookAndFeel.uisToArray(uis);
+ }
+
+ /**
+ * Calls the {@link ComponentUI#contains(JComponent, int, int)} method for all
+ * the UI delegates managed by this <code>MultiListUI</code>,
+ * returning the result for the UI delegate from the primary look and
+ * feel.
+ *
+ * @param c the component.
+ * @param x the x-coordinate.
+ * @param y the y-coordinate.
+ *
+ * @return <code>true</code> if the specified (x, y) coordinate falls within
+ * the bounds of the component as rendered by the UI delegate in the
+ * primary look and feel, and <code>false</code> otherwise.
+ */
+ public boolean contains(JComponent c, int x, int y)
+ {
+ boolean result = false;
+ Iterator iterator = uis.iterator();
+ // first UI delegate provides the return value
+ if (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ result = ui.contains(c, x, y);
+ }
+ // return values from auxiliary UI delegates are ignored
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ /* boolean ignored = */ ui.contains(c, x, y);
+ }
+ return result;
+ }
+
+ /**
+ * Calls the {@link ComponentUI#update(Graphics, JComponent)} method for all
+ * the UI delegates managed by this <code>MultiListUI</code>.
+ *
+ * @param g the graphics device.
+ * @param c the component.
+ */
+ public void update(Graphics g, JComponent c)
+ {
+ Iterator iterator = uis.iterator();
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ ui.update(g, c);
+ }
+ }
+
+ /**
+ * Calls the <code>paint(Graphics, JComponent)</code> method for all the UI
+ * delegates managed by this <code>MultiListUI</code>.
+ *
+ * @param g the graphics device.
+ * @param c the component.
+ */
+ public void paint(Graphics g, JComponent c)
+ {
+ Iterator iterator = uis.iterator();
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ ui.paint(g, c);
+ }
+ }
+
+ /**
+ * Calls the {@link ComponentUI#getPreferredSize(JComponent)} method for all
+ * the UI delegates managed by this <code>MultiListUI</code>,
+ * returning the preferred size for the UI delegate from the primary look and
+ * feel.
+ *
+ * @param c the component.
+ *
+ * @return The preferred size returned by the UI delegate from the primary
+ * look and feel.
+ */
+ public Dimension getPreferredSize(JComponent c)
+ {
+ Dimension result = null;
+ Iterator iterator = uis.iterator();
+ // first UI delegate provides the return value
+ if (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ result = ui.getPreferredSize(c);
+ }
+ // return values from auxiliary UI delegates are ignored
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ /* Dimension ignored = */ ui.getPreferredSize(c);
+ }
+ return result;
+ }
+
+ /**
+ * Calls the {@link ComponentUI#getMinimumSize(JComponent)} method for all
+ * the UI delegates managed by this <code>MultiListUI</code>,
+ * returning the minimum size for the UI delegate from the primary look and
+ * feel.
+ *
+ * @param c the component.
+ *
+ * @return The minimum size returned by the UI delegate from the primary
+ * look and feel.
+ */
+ public Dimension getMinimumSize(JComponent c)
+ {
+ Dimension result = null;
+ Iterator iterator = uis.iterator();
+ // first UI delegate provides the return value
+ if (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ result = ui.getMinimumSize(c);
+ }
+ // return values from auxiliary UI delegates are ignored
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ /* Dimension ignored = */ ui.getMinimumSize(c);
+ }
+ return result;
+ }
+
+ /**
+ * Calls the {@link ComponentUI#getMaximumSize(JComponent)} method for all
+ * the UI delegates managed by this <code>MultiListUI</code>,
+ * returning the maximum size for the UI delegate from the primary look and
+ * feel.
+ *
+ * @param c the component.
+ *
+ * @return The maximum size returned by the UI delegate from the primary
+ * look and feel.
+ */
+ public Dimension getMaximumSize(JComponent c)
+ {
+ Dimension result = null;
+ Iterator iterator = uis.iterator();
+ // first UI delegate provides the return value
+ if (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ result = ui.getMaximumSize(c);
+ }
+ // return values from auxiliary UI delegates are ignored
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ /* Dimension ignored = */ ui.getMaximumSize(c);
+ }
+ return result;
+ }
+
+ /**
+ * Calls the {@link ComponentUI#getAccessibleChildrenCount(JComponent)} method
+ * for all the UI delegates managed by this <code>MultiListUI</code>,
+ * returning the count for the UI delegate from the primary look and
+ * feel.
+ *
+ * @param c the component.
+ *
+ * @return The count returned by the UI delegate from the primary
+ * look and feel.
+ */
+ public int getAccessibleChildrenCount(JComponent c)
+ {
+ int result = 0;
+ Iterator iterator = uis.iterator();
+ // first UI delegate provides the return value
+ if (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ result = ui.getAccessibleChildrenCount(c);
+ }
+ // return values from auxiliary UI delegates are ignored
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ /* int ignored = */ ui.getAccessibleChildrenCount(c);
+ }
+ return result;
+ }
+
+ /**
+ * Calls the {@link ComponentUI#getAccessibleChild(JComponent, int)} method
+ * for all the UI delegates managed by this <code>MultiListUI</code>,
+ * returning the child for the UI delegate from the primary look and
+ * feel.
+ *
+ * @param c the component
+ * @param i the child index.
+ *
+ * @return The child returned by the UI delegate from the primary
+ * look and feel.
+ */
+ public Accessible getAccessibleChild(JComponent c, int i)
+ {
+ Accessible result = null;
+ Iterator iterator = uis.iterator();
+ // first UI delegate provides the return value
+ if (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ result = ui.getAccessibleChild(c, i);
+ }
+ // return values from auxiliary UI delegates are ignored
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ /* Accessible ignored = */ ui.getAccessibleChild(c, i);
+ }
+ return result;
+ }
+
+ /**
+ * Calls the {@link ListUI#locationToIndex(JList, Point)} method for all
+ * the UI delegates managed by this <code>MultiListUI</code>,
+ * returning the index for the UI delegate from the primary look and
+ * feel.
+ *
+ * @param list the list.
+ * @param location the location.
+ *
+ * @return The index returned by the UI delegate from the primary
+ * look and feel.
+ */
+ public int locationToIndex(JList list, Point location) {
+ int result = 0;
+ Iterator iterator = uis.iterator();
+ // first UI delegate provides the return value
+ if (iterator.hasNext())
+ {
+ ListUI ui = (ListUI) iterator.next();
+ result = ui.locationToIndex(list, location);
+ }
+ // return values from auxiliary UI delegates are ignored
+ while (iterator.hasNext())
+ {
+ ListUI ui = (ListUI) iterator.next();
+ /* int ignored = */ ui.locationToIndex(list, location);
+ }
+ return result;
+ }
+
+ /**
+ * Calls the {@link ListUI#indexToLocation(JList, int)} method for all
+ * the UI delegates managed by this <code>MultiListUI</code>,
+ * returning the location for the UI delegate from the primary look and
+ * feel.
+ *
+ * @param list the list.
+ * @param index the index.
+ *
+ * @return The location returned by the UI delegate from the primary
+ * look and feel.
+ */
+ public Point indexToLocation(JList list, int index) {
+ Point result = null;
+ Iterator iterator = uis.iterator();
+ // first UI delegate provides the return value
+ if (iterator.hasNext())
+ {
+ ListUI ui = (ListUI) iterator.next();
+ result = ui.indexToLocation(list, index);
+ }
+ // return values from auxiliary UI delegates are ignored
+ while (iterator.hasNext())
+ {
+ ListUI ui = (ListUI) iterator.next();
+ /* Point ignored = */ ui.indexToLocation(list, index);
+ }
+ return result;
+ }
+
+ /**
+ * Calls the {@link ListUI#getCellBounds(JList, int, int)} method for all
+ * the UI delegates managed by this <code>MultiListUI</code>,
+ * returning the bounds for the UI delegate from the primary look and
+ * feel.
+ *
+ * @param list the list.
+ * @param index1 the first index.
+ * @param index2 the second index.
+ *
+ * @return The bounds returned by the UI delegate from the primary
+ * look and feel.
+ */
+ public Rectangle getCellBounds(JList list, int index1, int index2) {
+ Rectangle result = null;
+ Iterator iterator = uis.iterator();
+ // first UI delegate provides the return value
+ if (iterator.hasNext())
+ {
+ ListUI ui = (ListUI) iterator.next();
+ result = ui.getCellBounds(list, index1, index2);
+ }
+ // return values from auxiliary UI delegates are ignored
+ while (iterator.hasNext())
+ {
+ ListUI ui = (ListUI) iterator.next();
+ /* Rectangle ignored = */ ui.getCellBounds(list, index1, index2);
+ }
+ return result;
+ }
+
+}
--- /dev/null
+/* MultiLookAndFeel.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., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 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 javax.swing.plaf.multi;
+
+import java.util.Vector;
+
+import javax.swing.JComponent;
+import javax.swing.LookAndFeel;
+import javax.swing.UIDefaults;
+import javax.swing.UIManager;
+import javax.swing.plaf.ComponentUI;
+
+/**
+ * A look and feel that provides the ability to use auxiliary look and feels
+ * in addition to the primary look and feel.
+ */
+public class MultiLookAndFeel extends LookAndFeel {
+
+ /**
+ * Creates a new instance of the look and feel.
+ */
+ public MultiLookAndFeel()
+ {
+ }
+
+ /**
+ * Returns the name for the look and feel.
+ *
+ * @return "Multiplexing Look and Feel".
+ */
+ public String getName()
+ {
+ return "Multiplexing Look and Feel";
+ }
+
+ /**
+ * Returns an identifier for the look and feel.
+ *
+ * @return "Multiplex".
+ */
+ public String getID()
+ {
+ return "Multiplex";
+ }
+
+ /**
+ * Returns a description of the look and feel.
+ *
+ * @return A description of the look and feel.
+ */
+ public String getDescription()
+ {
+ return "Allows multiple UI instances per component instance";
+ }
+
+ /**
+ * Returns <code>false</code> to indicate that this look and feel is not
+ * native to any platform.
+ *
+ * @return <code>false</code>.
+ */
+ public boolean isNativeLookAndFeel()
+ {
+ return false;
+ }
+
+ /**
+ * Returns <code>true</code> always, since this look and feel is supported on
+ * all platforms.
+ *
+ * @return <code>true</code>.
+ */
+ public boolean isSupportedLookAndFeel()
+ {
+ return true;
+ }
+
+ /**
+ * Creates and returns the UI defaults for this look and feel.
+ *
+ * @return The UI defaults.
+ */
+ public UIDefaults getDefaults()
+ {
+ UIDefaults defaults = new UIDefaults();
+ defaults.put("ButtonUI", "javax.swing.plaf.multi.MultiButtonUI");
+ defaults.put("CheckBoxUI", "javax.swing.plaf.multi.MultiButtonUI");
+ defaults.put("CheckBoxMenuItemUI", "javax.swing.plaf.multi.MultiMenuItemUI");
+ defaults.put("ColorChooserUI",
+ "javax.swing.plaf.multi.MultiColorChooserUI");
+ defaults.put("ComboBoxUI", "javax.swing.plaf.multi.MultiComboBoxUI");
+ defaults.put("DesktopPaneUI", "javax.swing.plaf.multi.MultiDesktopPaneUI");
+ defaults.put("DesktopIconUI", "javax.swing.plaf.multi.MultiDesktopIconUI");
+ defaults.put("EditorPaneUI", "javax.swing.plaf.multi.MultiTextUI");
+ defaults.put("FileChooserUI", "javax.swing.plaf.multi.MultiFileChooserUI");
+ defaults.put("FormattedTextFieldUI", "javax.swing.plaf.multi.MultiTextUI");
+ defaults.put("InternalFrameUI",
+ "javax.swing.plaf.multi.MultiInternalFrameUI");
+ defaults.put("LabelUI", "javax.swing.plaf.multi.MultiLabelUI");
+ defaults.put("ListUI", "javax.swing.plaf.multi.MultiListUI");
+ defaults.put("MenuItemUI", "javax.swing.plaf.multi.MultiMenuItemUI");
+ defaults.put("MenuUI", "javax.swing.plaf.multi.MultiMenuItemUI");
+ defaults.put("MenuBarUI", "javax.swing.plaf.multi.MultiMenuBarUI");
+ defaults.put("OptionPaneUI", "javax.swing.plaf.multi.MultiOptionPaneUI");
+ defaults.put("PanelUI", "javax.swing.plaf.multi.MultiPanelUI");
+ defaults.put("PasswordFieldUI", "javax.swing.plaf.multi.MultiTextUI");
+ defaults.put("PopupMenuUI", "javax.swing.plaf.multi.MultiPopupMenuUI");
+ defaults.put("PopupMenuSeparatorUI",
+ "javax.swing.plaf.multi.MultiSeparatorUI");
+ defaults.put("ProgressBarUI", "javax.swing.plaf.multi.MultiProgressBarUI");
+ defaults.put("RadioButtonUI", "javax.swing.plaf.multi.MultiButtonUI");
+ defaults.put("RadioButtonMenuItemUI",
+ "javax.swing.plaf.multi.MultiMenuItemUI");
+ defaults.put("RootPaneUI", "javax.swing.plaf.multi.MultiRootPaneUI");
+ defaults.put("ScrollBarUI", "javax.swing.plaf.multi.MultiScrollBarUI");
+ defaults.put("ScrollPaneUI", "javax.swing.plaf.multi.MultiScrollPaneUI");
+ defaults.put("SeparatorUI", "javax.swing.plaf.multi.MultiSeparatorUI");
+ defaults.put("SliderUI", "javax.swing.plaf.multi.MultiSliderUI");
+ defaults.put("SpinnerUI", "javax.swing.plaf.multi.MultiSpinnerUI");
+ defaults.put("SplitPaneUI", "javax.swing.plaf.multi.MultiSplitPaneUI");
+ defaults.put("TabbedPaneUI", "javax.swing.plaf.multi.MultiTabbedPaneUI");
+ defaults.put("TableHeaderUI", "javax.swing.plaf.multi.MultiTableHeaderUI");
+ defaults.put("TableUI", "javax.swing.plaf.multi.MultiTableUI");
+ defaults.put("TextAreaUI", "javax.swing.plaf.multi.MultiTextUI");
+ defaults.put("TextFieldUI", "javax.swing.plaf.multi.MultiTextUI");
+ defaults.put("TextPaneUI", "javax.swing.plaf.multi.MultiTextUI");
+ defaults.put("ToggleButtonUI", "javax.swing.plaf.multi.MultiButtonUI");
+ defaults.put("ToolBarSeparatorUI",
+ "javax.swing.plaf.multi.MultiSeparatorUI");
+ defaults.put("ToolBarUI", "javax.swing.plaf.multi.MultiToolBarUI");
+ defaults.put("ToolTipUI", "javax.swing.plaf.multi.MultiToolTipUI");
+ defaults.put("ViewportUI", "javax.swing.plaf.multi.MultiViewportUI");
+ return defaults;
+ }
+
+ /**
+ * Creates the UI delegates for the <code>target</code> component and
+ * returns a multiplexing UI delegate (<code>mui</code>) if there are
+ * multiple delegates.
+ *
+ * @param mui a multiplexing UI delegate appropriate for the component.
+ * @param uis a vector into which the UI delegates will be added.
+ * @param target the target component.
+ *
+ * @return A UI delegate.
+ */
+ public static ComponentUI createUIs(ComponentUI mui, Vector uis,
+ JComponent target)
+ {
+ // get primary UI delegate for 'target', and add it to uis
+ ComponentUI ui = null;
+ LookAndFeel primary = UIManager.getLookAndFeel();
+ if (primary != null)
+ {
+ ui = UIManager.getUI(target);
+ uis.add(ui);
+ }
+ // for any auxiliary look and feels in use, get the UI delegate and add
+ // it to uis
+ LookAndFeel[] auxlafs = UIManager.getAuxiliaryLookAndFeels();
+ for (int i = 0; i < auxlafs.length; i++)
+ {
+ LookAndFeel auxlaf = auxlafs[i];
+ // FIXME: here I call getDefaults() to get the UI delegate from the
+ // auxiliary look and feel. But getDefaults() creates a new set of
+ // defaults every time it is called, which is wasteful. Unfortunately
+ // I cannot find another way to get the UI delegate, so I'm doing it
+ // anyway...
+ UIDefaults defaults = auxlaf.getDefaults();
+ ui = defaults.getUI(target);
+ if (ui != null)
+ uis.add(ui);
+ }
+ // if uis contains more than 1 delegate, return mui, otherwise return
+ // the primary delegate
+ if (uis.size() > 1)
+ return mui;
+ else
+ return ui;
+ }
+
+ /**
+ * Returns an array containing the same {@link ComponentUI} instances as
+ * <code>uis</code>. If <code>uis</code> is <code>null</code>, a zero-length
+ * array is returned.
+ *
+ * @param uis a list of {@link ComponentUI} references (<code>null</code>
+ * permitted).
+ *
+ * @return An array containing the same {@link ComponentUI} instances as
+ * <code>uis</code>, or <code>null</code> if <code>uis</code> is
+ * empty.
+ */
+ protected static ComponentUI[] uisToArray(Vector uis)
+ {
+ if (uis == null)
+ return new ComponentUI[0];
+ int size = uis.size();
+ if (size == 0)
+ return null;
+ ComponentUI[] result = new ComponentUI[size];
+ uis.copyInto(result);
+ return result;
+ }
+
+}
--- /dev/null
+/* MultiMenuBarUI.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., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 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 javax.swing.plaf.multi;
+
+import java.awt.Dimension;
+import java.awt.Graphics;
+import java.util.Iterator;
+import java.util.Vector;
+
+import javax.accessibility.Accessible;
+import javax.swing.JComponent;
+import javax.swing.LookAndFeel;
+import javax.swing.UIManager;
+import javax.swing.plaf.ComponentUI;
+import javax.swing.plaf.MenuBarUI;
+
+/**
+ * A UI delegate that that coordinates multiple {@link MenuBarUI}
+ * instances, one from the primary look and feel, and one or more from the
+ * auxiliary look and feel(s).
+ *
+ * @see UIManager#addAuxiliaryLookAndFeel(LookAndFeel)
+ */
+public class MultiMenuBarUI extends MenuBarUI
+{
+
+ /** A list of references to the actual component UIs. */
+ protected Vector uis;
+
+ /**
+ * Creates a new <code>MultiMenuBarUI</code> instance.
+ *
+ * @see #createUI(JComponent)
+ */
+ public MultiMenuBarUI()
+ {
+ uis = new Vector();
+ }
+
+ /**
+ * Creates a delegate object for the specified component. If any auxiliary
+ * look and feels support this component, a <code>MultiMenuBarUI</code> is
+ * returned, otherwise the UI from the default look and feel is returned.
+ *
+ * @param target the component.
+ *
+ * @see MultiLookAndFeel#createUIs(ComponentUI, Vector, JComponent)
+ */
+ public static ComponentUI createUI(JComponent target)
+ {
+ MultiMenuBarUI mui = new MultiMenuBarUI();
+ return MultiLookAndFeel.createUIs(mui, mui.uis, target);
+ }
+
+ /**
+ * Calls the {@link ComponentUI#installUI(JComponent)} method for all
+ * the UI delegates managed by this <code>MultiMenuBarUI</code>.
+ *
+ * @param c the component.
+ */
+ public void installUI(JComponent c)
+ {
+ Iterator iterator = uis.iterator();
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ ui.installUI(c);
+ }
+ }
+
+ /**
+ * Calls the {@link ComponentUI#uninstallUI(JComponent)} method for all
+ * the UI delegates managed by this <code>MultiMenuBarUI</code>.
+ *
+ * @param c the component.
+ */
+ public void uninstallUI(JComponent c)
+ {
+ Iterator iterator = uis.iterator();
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ ui.uninstallUI(c);
+ }
+ }
+
+ /**
+ * Returns an array containing the UI delegates managed by this
+ * <code>MultiMenuBarUI</code>. The first item in the array is always
+ * the UI delegate from the installed default look and feel.
+ *
+ * @return An array of UI delegates.
+ */
+ public ComponentUI[] getUIs()
+ {
+ return MultiLookAndFeel.uisToArray(uis);
+ }
+
+ /**
+ * Calls the {@link ComponentUI#contains(JComponent, int, int)} method for all
+ * the UI delegates managed by this <code>MultiMenuBarUI</code>,
+ * returning the result for the UI delegate from the primary look and
+ * feel.
+ *
+ * @param c the component.
+ * @param x the x-coordinate.
+ * @param y the y-coordinate.
+ *
+ * @return <code>true</code> if the specified (x, y) coordinate falls within
+ * the bounds of the component as rendered by the UI delegate in the
+ * primary look and feel, and <code>false</code> otherwise.
+ */
+ public boolean contains(JComponent c, int x, int y)
+ {
+ boolean result = false;
+ Iterator iterator = uis.iterator();
+ // first UI delegate provides the return value
+ if (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ result = ui.contains(c, x, y);
+ }
+ // return values from auxiliary UI delegates are ignored
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ /* boolean ignored = */ ui.contains(c, x, y);
+ }
+ return result;
+ }
+
+ /**
+ * Calls the {@link ComponentUI#update(Graphics, JComponent)} method for all
+ * the UI delegates managed by this <code>MultiMenuBarUI</code>.
+ *
+ * @param g the graphics device.
+ * @param c the component.
+ */
+ public void update(Graphics g, JComponent c)
+ {
+ Iterator iterator = uis.iterator();
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ ui.update(g, c);
+ }
+ }
+
+ /**
+ * Calls the <code>paint(Graphics, JComponent)</code> method for all the UI
+ * delegates managed by this <code>MultiMenuBarUI</code>.
+ *
+ * @param g the graphics device.
+ * @param c the component.
+ */
+ public void paint(Graphics g, JComponent c)
+ {
+ Iterator iterator = uis.iterator();
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ ui.paint(g, c);
+ }
+ }
+
+ /**
+ * Calls the {@link ComponentUI#getPreferredSize(JComponent)} method for all
+ * the UI delegates managed by this <code>MultiMenuBarUI</code>,
+ * returning the preferred size for the UI delegate from the primary look and
+ * feel.
+ *
+ * @param c the component.
+ *
+ * @return The preferred size returned by the UI delegate from the primary
+ * look and feel.
+ */
+ public Dimension getPreferredSize(JComponent c)
+ {
+ Dimension result = null;
+ Iterator iterator = uis.iterator();
+ // first UI delegate provides the return value
+ if (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ result = ui.getPreferredSize(c);
+ }
+ // return values from auxiliary UI delegates are ignored
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ /* Dimension ignored = */ ui.getPreferredSize(c);
+ }
+ return result;
+ }
+
+ /**
+ * Calls the {@link ComponentUI#getMinimumSize(JComponent)} method for all
+ * the UI delegates managed by this <code>MultiMenuBarUI</code>,
+ * returning the minimum size for the UI delegate from the primary look and
+ * feel.
+ *
+ * @param c the component.
+ *
+ * @return The minimum size returned by the UI delegate from the primary
+ * look and feel.
+ */
+ public Dimension getMinimumSize(JComponent c)
+ {
+ Dimension result = null;
+ Iterator iterator = uis.iterator();
+ // first UI delegate provides the return value
+ if (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ result = ui.getMinimumSize(c);
+ }
+ // return values from auxiliary UI delegates are ignored
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ /* Dimension ignored = */ ui.getMinimumSize(c);
+ }
+ return result;
+ }
+
+ /**
+ * Calls the {@link ComponentUI#getMaximumSize(JComponent)} method for all
+ * the UI delegates managed by this <code>MultiMenuBarUI</code>,
+ * returning the maximum size for the UI delegate from the primary look and
+ * feel.
+ *
+ * @param c the component.
+ *
+ * @return The maximum size returned by the UI delegate from the primary
+ * look and feel.
+ */
+ public Dimension getMaximumSize(JComponent c)
+ {
+ Dimension result = null;
+ Iterator iterator = uis.iterator();
+ // first UI delegate provides the return value
+ if (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ result = ui.getMaximumSize(c);
+ }
+ // return values from auxiliary UI delegates are ignored
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ /* Dimension ignored = */ ui.getMaximumSize(c);
+ }
+ return result;
+ }
+
+ /**
+ * Calls the {@link ComponentUI#getAccessibleChildrenCount(JComponent)} method
+ * for all the UI delegates managed by this <code>MultiMenuBarUI</code>,
+ * returning the count for the UI delegate from the primary look and
+ * feel.
+ *
+ * @param c the component.
+ *
+ * @return The count returned by the UI delegate from the primary
+ * look and feel.
+ */
+ public int getAccessibleChildrenCount(JComponent c)
+ {
+ int result = 0;
+ Iterator iterator = uis.iterator();
+ // first UI delegate provides the return value
+ if (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ result = ui.getAccessibleChildrenCount(c);
+ }
+ // return values from auxiliary UI delegates are ignored
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ /* int ignored = */ ui.getAccessibleChildrenCount(c);
+ }
+ return result;
+ }
+
+ /**
+ * Calls the {@link ComponentUI#getAccessibleChild(JComponent, int)} method
+ * for all the UI delegates managed by this <code>MultiMenuBarUI</code>,
+ * returning the child for the UI delegate from the primary look and
+ * feel.
+ *
+ * @param c the component
+ * @param i the child index.
+ *
+ * @return The child returned by the UI delegate from the primary
+ * look and feel.
+ */
+ public Accessible getAccessibleChild(JComponent c, int i)
+ {
+ Accessible result = null;
+ Iterator iterator = uis.iterator();
+ // first UI delegate provides the return value
+ if (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ result = ui.getAccessibleChild(c, i);
+ }
+ // return values from auxiliary UI delegates are ignored
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ /* Accessible ignored = */ ui.getAccessibleChild(c, i);
+ }
+ return result;
+ }
+
+}
--- /dev/null
+/* MultiMenuItemUI.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., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 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 javax.swing.plaf.multi;
+
+import java.awt.Dimension;
+import java.awt.Graphics;
+import java.util.Iterator;
+import java.util.Vector;
+
+import javax.accessibility.Accessible;
+import javax.swing.JComponent;
+import javax.swing.LookAndFeel;
+import javax.swing.UIManager;
+import javax.swing.plaf.ComponentUI;
+import javax.swing.plaf.MenuItemUI;
+
+/**
+ * A UI delegate that that coordinates multiple {@link MenuItemUI}
+ * instances, one from the primary look and feel, and one or more from the
+ * auxiliary look and feel(s).
+ *
+ * @see UIManager#addAuxiliaryLookAndFeel(LookAndFeel)
+ */
+public class MultiMenuItemUI extends MenuItemUI
+{
+
+ /** A list of references to the actual component UIs. */
+ protected Vector uis;
+
+ /**
+ * Creates a new <code>MultiMenuItemUI</code> instance.
+ *
+ * @see #createUI(JComponent)
+ */
+ public MultiMenuItemUI()
+ {
+ uis = new Vector();
+ }
+
+ /**
+ * Creates a delegate object for the specified component. If any auxiliary
+ * look and feels support this component, a <code>MultiItemUI</code> is
+ * returned, otherwise the UI from the default look and feel is returned.
+ *
+ * @param target the component.
+ *
+ * @see MultiLookAndFeel#createUIs(ComponentUI, Vector, JComponent)
+ */
+ public static ComponentUI createUI(JComponent target)
+ {
+ MultiMenuItemUI mui = new MultiMenuItemUI();
+ return MultiLookAndFeel.createUIs(mui, mui.uis, target);
+ }
+
+ /**
+ * Calls the {@link ComponentUI#installUI(JComponent)} method for all
+ * the UI delegates managed by this <code>MultiMenuItemUI</code>.
+ *
+ * @param c the component.
+ */
+ public void installUI(JComponent c)
+ {
+ Iterator iterator = uis.iterator();
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ ui.installUI(c);
+ }
+ }
+
+ /**
+ * Calls the {@link ComponentUI#uninstallUI(JComponent)} method for all
+ * the UI delegates managed by this <code>MultiMenuItemUI</code>.
+ *
+ * @param c the component.
+ */
+ public void uninstallUI(JComponent c)
+ {
+ Iterator iterator = uis.iterator();
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ ui.uninstallUI(c);
+ }
+ }
+
+ /**
+ * Returns an array containing the UI delegates managed by this
+ * <code>MultiMenuItemUI</code>. The first item in the array is always
+ * the UI delegate from the installed default look and feel.
+ *
+ * @return An array of UI delegates.
+ */
+ public ComponentUI[] getUIs()
+ {
+ return MultiLookAndFeel.uisToArray(uis);
+ }
+
+ /**
+ * Calls the {@link ComponentUI#contains(JComponent, int, int)} method for all
+ * the UI delegates managed by this <code>MultiMenuItemUI</code>,
+ * returning the result for the UI delegate from the primary look and
+ * feel.
+ *
+ * @param c the component.
+ * @param x the x-coordinate.
+ * @param y the y-coordinate.
+ *
+ * @return <code>true</code> if the specified (x, y) coordinate falls within
+ * the bounds of the component as rendered by the UI delegate in the
+ * primary look and feel, and <code>false</code> otherwise.
+ */
+ public boolean contains(JComponent c, int x, int y)
+ {
+ boolean result = false;
+ Iterator iterator = uis.iterator();
+ // first UI delegate provides the return value
+ if (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ result = ui.contains(c, x, y);
+ }
+ // return values from auxiliary UI delegates are ignored
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ /* boolean ignored = */ ui.contains(c, x, y);
+ }
+ return result;
+ }
+
+ /**
+ * Calls the {@link ComponentUI#update(Graphics, JComponent)} method for all
+ * the UI delegates managed by this <code>MultiMenuItemUI</code>.
+ *
+ * @param g the graphics device.
+ * @param c the component.
+ */
+ public void update(Graphics g, JComponent c)
+ {
+ Iterator iterator = uis.iterator();
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ ui.update(g, c);
+ }
+ }
+
+ /**
+ * Calls the <code>paint(Graphics, JComponent)</code> method for all the UI
+ * delegates managed by this <code>MultiMenuItemUI</code>.
+ *
+ * @param g the graphics device.
+ * @param c the component.
+ */
+ public void paint(Graphics g, JComponent c)
+ {
+ Iterator iterator = uis.iterator();
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ ui.paint(g, c);
+ }
+ }
+
+ /**
+ * Calls the {@link ComponentUI#getPreferredSize(JComponent)} method for all
+ * the UI delegates managed by this <code>MultiMenuItemUI</code>,
+ * returning the preferred size for the UI delegate from the primary look and
+ * feel.
+ *
+ * @param c the component.
+ *
+ * @return The preferred size returned by the UI delegate from the primary
+ * look and feel.
+ */
+ public Dimension getPreferredSize(JComponent c)
+ {
+ Dimension result = null;
+ Iterator iterator = uis.iterator();
+ // first UI delegate provides the return value
+ if (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ result = ui.getPreferredSize(c);
+ }
+ // return values from auxiliary UI delegates are ignored
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ /* Dimension ignored = */ ui.getPreferredSize(c);
+ }
+ return result;
+ }
+
+ /**
+ * Calls the {@link ComponentUI#getMinimumSize(JComponent)} method for all
+ * the UI delegates managed by this <code>MultiMenuItemUI</code>,
+ * returning the minimum size for the UI delegate from the primary look and
+ * feel.
+ *
+ * @param c the component.
+ *
+ * @return The minimum size returned by the UI delegate from the primary
+ * look and feel.
+ */
+ public Dimension getMinimumSize(JComponent c)
+ {
+ Dimension result = null;
+ Iterator iterator = uis.iterator();
+ // first UI delegate provides the return value
+ if (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ result = ui.getMinimumSize(c);
+ }
+ // return values from auxiliary UI delegates are ignored
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ /* Dimension ignored = */ ui.getMinimumSize(c);
+ }
+ return result;
+ }
+
+ /**
+ * Calls the {@link ComponentUI#getMaximumSize(JComponent)} method for all
+ * the UI delegates managed by this <code>MultiMenuItemUI</code>,
+ * returning the maximum size for the UI delegate from the primary look and
+ * feel.
+ *
+ * @param c the component.
+ *
+ * @return The maximum size returned by the UI delegate from the primary
+ * look and feel.
+ */
+ public Dimension getMaximumSize(JComponent c)
+ {
+ Dimension result = null;
+ Iterator iterator = uis.iterator();
+ // first UI delegate provides the return value
+ if (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ result = ui.getMaximumSize(c);
+ }
+ // return values from auxiliary UI delegates are ignored
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ /* Dimension ignored = */ ui.getMaximumSize(c);
+ }
+ return result;
+ }
+
+ /**
+ * Calls the {@link ComponentUI#getAccessibleChildrenCount(JComponent)} method
+ * for all the UI delegates managed by this <code>MultiMenuItemUI</code>,
+ * returning the count for the UI delegate from the primary look and
+ * feel.
+ *
+ * @param c the component.
+ *
+ * @return The count returned by the UI delegate from the primary
+ * look and feel.
+ */
+ public int getAccessibleChildrenCount(JComponent c)
+ {
+ int result = 0;
+ Iterator iterator = uis.iterator();
+ // first UI delegate provides the return value
+ if (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ result = ui.getAccessibleChildrenCount(c);
+ }
+ // return values from auxiliary UI delegates are ignored
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ /* int ignored = */ ui.getAccessibleChildrenCount(c);
+ }
+ return result;
+ }
+
+ /**
+ * Calls the {@link ComponentUI#getAccessibleChild(JComponent, int)} method
+ * for all the UI delegates managed by this <code>MultiMenuItemUI</code>,
+ * returning the child for the UI delegate from the primary look and
+ * feel.
+ *
+ * @param c the component
+ * @param i the child index.
+ *
+ * @return The child returned by the UI delegate from the primary
+ * look and feel.
+ */
+ public Accessible getAccessibleChild(JComponent c, int i)
+ {
+ Accessible result = null;
+ Iterator iterator = uis.iterator();
+ // first UI delegate provides the return value
+ if (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ result = ui.getAccessibleChild(c, i);
+ }
+ // return values from auxiliary UI delegates are ignored
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ /* Accessible ignored = */ ui.getAccessibleChild(c, i);
+ }
+ return result;
+ }
+
+}
--- /dev/null
+/* MultiOptionPaneUI.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., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 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 javax.swing.plaf.multi;
+
+import java.awt.Dimension;
+import java.awt.Graphics;
+import java.util.Iterator;
+import java.util.Vector;
+
+import javax.accessibility.Accessible;
+import javax.swing.JComponent;
+import javax.swing.JOptionPane;
+import javax.swing.LookAndFeel;
+import javax.swing.UIManager;
+import javax.swing.plaf.ComponentUI;
+import javax.swing.plaf.OptionPaneUI;
+
+/**
+ * A UI delegate that that coordinates multiple {@link OptionPaneUI}
+ * instances, one from the primary look and feel, and one or more from the
+ * auxiliary look and feel(s).
+ *
+ * @see UIManager#addAuxiliaryLookAndFeel(LookAndFeel)
+ */
+public class MultiOptionPaneUI extends OptionPaneUI
+{
+
+ /** A list of references to the actual component UIs. */
+ protected Vector uis;
+
+ /**
+ * Creates a new <code>MultiOptionPaneUI</code> instance.
+ *
+ * @see #createUI(JComponent)
+ */
+ public MultiOptionPaneUI()
+ {
+ uis = new Vector();
+ }
+
+ /**
+ * Creates a delegate object for the specified component. If any auxiliary
+ * look and feels support this component, a <code>MultiOptionPaneUI</code> is
+ * returned, otherwise the UI from the default look and feel is returned.
+ *
+ * @param target the component.
+ *
+ * @see MultiLookAndFeel#createUIs(ComponentUI, Vector, JComponent)
+ */
+ public static ComponentUI createUI(JComponent target)
+ {
+ MultiOptionPaneUI mui = new MultiOptionPaneUI();
+ return MultiLookAndFeel.createUIs(mui, mui.uis, target);
+ }
+
+ /**
+ * Calls the {@link ComponentUI#installUI(JComponent)} method for all
+ * the UI delegates managed by this <code>MultiOptionPaneUI</code>.
+ *
+ * @param c the component.
+ */
+ public void installUI(JComponent c)
+ {
+ Iterator iterator = uis.iterator();
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ ui.installUI(c);
+ }
+ }
+
+ /**
+ * Calls the {@link ComponentUI#uninstallUI(JComponent)} method for all
+ * the UI delegates managed by this <code>MultiOptionPaneUI</code>.
+ *
+ * @param c the component.
+ */
+ public void uninstallUI(JComponent c)
+ {
+ Iterator iterator = uis.iterator();
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ ui.uninstallUI(c);
+ }
+ }
+
+ /**
+ * Returns an array containing the UI delegates managed by this
+ * <code>MultiOptionPaneUI</code>. The first item in the array is always
+ * the UI delegate from the installed default look and feel.
+ *
+ * @return An array of UI delegates.
+ */
+ public ComponentUI[] getUIs()
+ {
+ return MultiLookAndFeel.uisToArray(uis);
+ }
+
+ /**
+ * Calls the {@link ComponentUI#contains(JComponent, int, int)} method for all
+ * the UI delegates managed by this <code>MultiOptionPaneUI</code>,
+ * returning the result for the UI delegate from the primary look and
+ * feel.
+ *
+ * @param c the component.
+ * @param x the x-coordinate.
+ * @param y the y-coordinate.
+ *
+ * @return <code>true</code> if the specified (x, y) coordinate falls within
+ * the bounds of the component as rendered by the UI delegate in the
+ * primary look and feel, and <code>false</code> otherwise.
+ */
+ public boolean contains(JComponent c, int x, int y)
+ {
+ boolean result = false;
+ Iterator iterator = uis.iterator();
+ // first UI delegate provides the return value
+ if (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ result = ui.contains(c, x, y);
+ }
+ // return values from auxiliary UI delegates are ignored
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ /* boolean ignored = */ ui.contains(c, x, y);
+ }
+ return result;
+ }
+
+ /**
+ * Calls the {@link ComponentUI#update(Graphics, JComponent)} method for all
+ * the UI delegates managed by this <code>MultiOptionPaneUI</code>.
+ *
+ * @param g the graphics device.
+ * @param c the component.
+ */
+ public void update(Graphics g, JComponent c)
+ {
+ Iterator iterator = uis.iterator();
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ ui.update(g, c);
+ }
+ }
+
+ /**
+ * Calls the <code>paint(Graphics, JComponent)</code> method for all the UI
+ * delegates managed by this <code>MultiOptionPaneUI</code>.
+ *
+ * @param g the graphics device.
+ * @param c the component.
+ */
+ public void paint(Graphics g, JComponent c)
+ {
+ Iterator iterator = uis.iterator();
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ ui.paint(g, c);
+ }
+ }
+
+ /**
+ * Calls the {@link ComponentUI#getPreferredSize(JComponent)} method for all
+ * the UI delegates managed by this <code>MultiOptionPaneUI</code>,
+ * returning the preferred size for the UI delegate from the primary look and
+ * feel.
+ *
+ * @param c the component.
+ *
+ * @return The preferred size returned by the UI delegate from the primary
+ * look and feel.
+ */
+ public Dimension getPreferredSize(JComponent c)
+ {
+ Dimension result = null;
+ Iterator iterator = uis.iterator();
+ // first UI delegate provides the return value
+ if (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ result = ui.getPreferredSize(c);
+ }
+ // return values from auxiliary UI delegates are ignored
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ /* Dimension ignored = */ ui.getPreferredSize(c);
+ }
+ return result;
+ }
+
+ /**
+ * Calls the {@link ComponentUI#getMinimumSize(JComponent)} method for all
+ * the UI delegates managed by this <code>MultiOptionPaneUI</code>,
+ * returning the minimum size for the UI delegate from the primary look and
+ * feel.
+ *
+ * @param c the component.
+ *
+ * @return The minimum size returned by the UI delegate from the primary
+ * look and feel.
+ */
+ public Dimension getMinimumSize(JComponent c)
+ {
+ Dimension result = null;
+ Iterator iterator = uis.iterator();
+ // first UI delegate provides the return value
+ if (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ result = ui.getMinimumSize(c);
+ }
+ // return values from auxiliary UI delegates are ignored
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ /* Dimension ignored = */ ui.getMinimumSize(c);
+ }
+ return result;
+ }
+
+ /**
+ * Calls the {@link ComponentUI#getMaximumSize(JComponent)} method for all
+ * the UI delegates managed by this <code>MultiOptionPaneUI</code>,
+ * returning the maximum size for the UI delegate from the primary look and
+ * feel.
+ *
+ * @param c the component.
+ *
+ * @return The maximum size returned by the UI delegate from the primary
+ * look and feel.
+ */
+ public Dimension getMaximumSize(JComponent c)
+ {
+ Dimension result = null;
+ Iterator iterator = uis.iterator();
+ // first UI delegate provides the return value
+ if (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ result = ui.getMaximumSize(c);
+ }
+ // return values from auxiliary UI delegates are ignored
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ /* Dimension ignored = */ ui.getMaximumSize(c);
+ }
+ return result;
+ }
+
+ /**
+ * Calls the {@link ComponentUI#getAccessibleChildrenCount(JComponent)} method
+ * for all the UI delegates managed by this <code>MultiOptionPaneUI</code>,
+ * returning the count for the UI delegate from the primary look and
+ * feel.
+ *
+ * @param c the component.
+ *
+ * @return The count returned by the UI delegate from the primary
+ * look and feel.
+ */
+ public int getAccessibleChildrenCount(JComponent c)
+ {
+ int result = 0;
+ Iterator iterator = uis.iterator();
+ // first UI delegate provides the return value
+ if (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ result = ui.getAccessibleChildrenCount(c);
+ }
+ // return values from auxiliary UI delegates are ignored
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ /* int ignored = */ ui.getAccessibleChildrenCount(c);
+ }
+ return result;
+ }
+
+ /**
+ * Calls the {@link ComponentUI#getAccessibleChild(JComponent, int)} method
+ * for all the UI delegates managed by this <code>MultiOptionPaneUI</code>,
+ * returning the child for the UI delegate from the primary look and
+ * feel.
+ *
+ * @param c the component
+ * @param i the child index.
+ *
+ * @return The child returned by the UI delegate from the primary
+ * look and feel.
+ */
+ public Accessible getAccessibleChild(JComponent c, int i)
+ {
+ Accessible result = null;
+ Iterator iterator = uis.iterator();
+ // first UI delegate provides the return value
+ if (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ result = ui.getAccessibleChild(c, i);
+ }
+ // return values from auxiliary UI delegates are ignored
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ /* Accessible ignored = */ ui.getAccessibleChild(c, i);
+ }
+ return result;
+ }
+
+ /**
+ * Calls the {@link OptionPaneUI#selectInitialValue(JOptionPane)} method for
+ * all the UI delegates managed by this <code>MultiOptionPaneUI</code>.
+ *
+ * @param pane the option pane.
+ */
+ public void selectInitialValue(JOptionPane pane) {
+ Iterator iterator = uis.iterator();
+ while (iterator.hasNext())
+ {
+ OptionPaneUI ui = (OptionPaneUI) iterator.next();
+ ui.selectInitialValue(pane);
+ }
+ }
+
+ /**
+ * Calls the {@link OptionPaneUI#containsCustomComponents(JOptionPane)}
+ * method for all the UI delegates managed by this
+ * <code>MultiOptionPaneUI</code>, returning the result for the UI delegate
+ * from the primary look and feel.
+ *
+ * @param pane the option pane.
+ *
+ * @return The result for the UI delegate from the primary look and feel.
+ */
+ public boolean containsCustomComponents(JOptionPane pane) {
+ boolean result = false;
+ Iterator iterator = uis.iterator();
+ // first UI delegate provides the return value
+ if (iterator.hasNext())
+ {
+ OptionPaneUI ui = (OptionPaneUI) iterator.next();
+ result = ui.containsCustomComponents(pane);
+ }
+ // return values from auxiliary UI delegates are ignored
+ while (iterator.hasNext())
+ {
+ OptionPaneUI ui = (OptionPaneUI) iterator.next();
+ /* boolean ignored = */ ui.containsCustomComponents(pane);
+ }
+ return result;
+ }
+
+}
--- /dev/null
+/* MultiPanelUI.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., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 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 javax.swing.plaf.multi;
+
+import java.awt.Dimension;
+import java.awt.Graphics;
+import java.util.Iterator;
+import java.util.Vector;
+
+import javax.accessibility.Accessible;
+import javax.swing.JComponent;
+import javax.swing.LookAndFeel;
+import javax.swing.UIManager;
+import javax.swing.plaf.ComponentUI;
+import javax.swing.plaf.PanelUI;
+
+/**
+ * A UI delegate that that coordinates multiple {@link PanelUI}
+ * instances, one from the primary look and feel, and one or more from the
+ * auxiliary look and feel(s).
+ *
+ * @see UIManager#addAuxiliaryLookAndFeel(LookAndFeel)
+ */
+public class MultiPanelUI extends PanelUI
+{
+
+ /** A list of references to the actual component UIs. */
+ protected Vector uis;
+
+ /**
+ * Creates a new <code>MultiPanelUI</code> instance.
+ *
+ * @see #createUI(JComponent)
+ */
+ public MultiPanelUI()
+ {
+ uis = new Vector();
+ }
+
+ /**
+ * Creates a delegate object for the specified component. If any auxiliary
+ * look and feels support this component, a <code>MultiPanelUI</code> is
+ * returned, otherwise the UI from the default look and feel is returned.
+ *
+ * @param target the component.
+ *
+ * @see MultiLookAndFeel#createUIs(ComponentUI, Vector, JComponent)
+ */
+ public static ComponentUI createUI(JComponent target)
+ {
+ MultiPanelUI mui = new MultiPanelUI();
+ return MultiLookAndFeel.createUIs(mui, mui.uis, target);
+ }
+
+ /**
+ * Calls the {@link ComponentUI#installUI(JComponent)} method for all
+ * the UI delegates managed by this <code>MultiPanelUI</code>.
+ *
+ * @param c the component.
+ */
+ public void installUI(JComponent c)
+ {
+ Iterator iterator = uis.iterator();
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ ui.installUI(c);
+ }
+ }
+
+ /**
+ * Calls the {@link ComponentUI#uninstallUI(JComponent)} method for all
+ * the UI delegates managed by this <code>MultiPanelUI</code>.
+ *
+ * @param c the component.
+ */
+ public void uninstallUI(JComponent c)
+ {
+ Iterator iterator = uis.iterator();
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ ui.uninstallUI(c);
+ }
+ }
+
+ /**
+ * Returns an array containing the UI delegates managed by this
+ * <code>MultiPanelUI</code>. The first item in the array is always
+ * the UI delegate from the installed default look and feel.
+ *
+ * @return An array of UI delegates.
+ */
+ public ComponentUI[] getUIs()
+ {
+ return MultiLookAndFeel.uisToArray(uis);
+ }
+
+ /**
+ * Calls the {@link ComponentUI#contains(JComponent, int, int)} method for all
+ * the UI delegates managed by this <code>MultiPanelUI</code>,
+ * returning the result for the UI delegate from the primary look and
+ * feel.
+ *
+ * @param c the component.
+ * @param x the x-coordinate.
+ * @param y the y-coordinate.
+ *
+ * @return <code>true</code> if the specified (x, y) coordinate falls within
+ * the bounds of the component as rendered by the UI delegate in the
+ * primary look and feel, and <code>false</code> otherwise.
+ */
+ public boolean contains(JComponent c, int x, int y)
+ {
+ boolean result = false;
+ Iterator iterator = uis.iterator();
+ // first UI delegate provides the return value
+ if (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ result = ui.contains(c, x, y);
+ }
+ // return values from auxiliary UI delegates are ignored
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ /* boolean ignored = */ ui.contains(c, x, y);
+ }
+ return result;
+ }
+
+ /**
+ * Calls the {@link ComponentUI#update(Graphics, JComponent)} method for all
+ * the UI delegates managed by this <code>MultiPanelUI</code>.
+ *
+ * @param g the graphics device.
+ * @param c the component.
+ */
+ public void update(Graphics g, JComponent c)
+ {
+ Iterator iterator = uis.iterator();
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ ui.update(g, c);
+ }
+ }
+
+ /**
+ * Calls the <code>paint(Graphics, JComponent)</code> method for all the UI
+ * delegates managed by this <code>MultiPanelUI</code>.
+ *
+ * @param g the graphics device.
+ * @param c the component.
+ */
+ public void paint(Graphics g, JComponent c)
+ {
+ Iterator iterator = uis.iterator();
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ ui.paint(g, c);
+ }
+ }
+
+ /**
+ * Calls the {@link ComponentUI#getPreferredSize(JComponent)} method for all
+ * the UI delegates managed by this <code>MultiPanelUI</code>,
+ * returning the preferred size for the UI delegate from the primary look and
+ * feel.
+ *
+ * @param c the component.
+ *
+ * @return The preferred size returned by the UI delegate from the primary
+ * look and feel.
+ */
+ public Dimension getPreferredSize(JComponent c)
+ {
+ Dimension result = null;
+ Iterator iterator = uis.iterator();
+ // first UI delegate provides the return value
+ if (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ result = ui.getPreferredSize(c);
+ }
+ // return values from auxiliary UI delegates are ignored
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ /* Dimension ignored = */ ui.getPreferredSize(c);
+ }
+ return result;
+ }
+
+ /**
+ * Calls the {@link ComponentUI#getMinimumSize(JComponent)} method for all
+ * the UI delegates managed by this <code>MultiPanelUI</code>,
+ * returning the minimum size for the UI delegate from the primary look and
+ * feel.
+ *
+ * @param c the component.
+ *
+ * @return The minimum size returned by the UI delegate from the primary
+ * look and feel.
+ */
+ public Dimension getMinimumSize(JComponent c)
+ {
+ Dimension result = null;
+ Iterator iterator = uis.iterator();
+ // first UI delegate provides the return value
+ if (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ result = ui.getMinimumSize(c);
+ }
+ // return values from auxiliary UI delegates are ignored
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ /* Dimension ignored = */ ui.getMinimumSize(c);
+ }
+ return result;
+ }
+
+ /**
+ * Calls the {@link ComponentUI#getMaximumSize(JComponent)} method for all
+ * the UI delegates managed by this <code>MultiPanelUI</code>,
+ * returning the maximum size for the UI delegate from the primary look and
+ * feel.
+ *
+ * @param c the component.
+ *
+ * @return The maximum size returned by the UI delegate from the primary
+ * look and feel.
+ */
+ public Dimension getMaximumSize(JComponent c)
+ {
+ Dimension result = null;
+ Iterator iterator = uis.iterator();
+ // first UI delegate provides the return value
+ if (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ result = ui.getMaximumSize(c);
+ }
+ // return values from auxiliary UI delegates are ignored
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ /* Dimension ignored = */ ui.getMaximumSize(c);
+ }
+ return result;
+ }
+
+ /**
+ * Calls the {@link ComponentUI#getAccessibleChildrenCount(JComponent)} method
+ * for all the UI delegates managed by this <code>MultiPanelUI</code>,
+ * returning the count for the UI delegate from the primary look and
+ * feel.
+ *
+ * @param c the component.
+ *
+ * @return The count returned by the UI delegate from the primary
+ * look and feel.
+ */
+ public int getAccessibleChildrenCount(JComponent c)
+ {
+ int result = 0;
+ Iterator iterator = uis.iterator();
+ // first UI delegate provides the return value
+ if (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ result = ui.getAccessibleChildrenCount(c);
+ }
+ // return values from auxiliary UI delegates are ignored
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ /* int ignored = */ ui.getAccessibleChildrenCount(c);
+ }
+ return result;
+ }
+
+ /**
+ * Calls the {@link ComponentUI#getAccessibleChild(JComponent, int)} method
+ * for all the UI delegates managed by this <code>MultiPanelUI</code>,
+ * returning the child for the UI delegate from the primary look and
+ * feel.
+ *
+ * @param c the component
+ * @param i the child index.
+ *
+ * @return The child returned by the UI delegate from the primary
+ * look and feel.
+ */
+ public Accessible getAccessibleChild(JComponent c, int i)
+ {
+ Accessible result = null;
+ Iterator iterator = uis.iterator();
+ // first UI delegate provides the return value
+ if (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ result = ui.getAccessibleChild(c, i);
+ }
+ // return values from auxiliary UI delegates are ignored
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ /* Accessible ignored = */ ui.getAccessibleChild(c, i);
+ }
+ return result;
+ }
+
+}
--- /dev/null
+/* MultiPopupMenuUI.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., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 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 javax.swing.plaf.multi;
+
+import java.awt.Dimension;
+import java.awt.Graphics;
+import java.util.Iterator;
+import java.util.Vector;
+
+import javax.accessibility.Accessible;
+import javax.swing.JComponent;
+import javax.swing.LookAndFeel;
+import javax.swing.UIManager;
+import javax.swing.plaf.ComponentUI;
+import javax.swing.plaf.PopupMenuUI;
+
+/**
+ * A UI delegate that that coordinates multiple {@link PopupMenuUI}
+ * instances, one from the primary look and feel, and one or more from the
+ * auxiliary look and feel(s).
+ *
+ * @see UIManager#addAuxiliaryLookAndFeel(LookAndFeel)
+ */
+public class MultiPopupMenuUI extends PopupMenuUI
+{
+
+ /** A list of references to the actual component UIs. */
+ protected Vector uis;
+
+ /**
+ * Creates a new <code>MultiPopupMenuUI</code> instance.
+ *
+ * @see #createUI(JComponent)
+ */
+ public MultiPopupMenuUI()
+ {
+ uis = new Vector();
+ }
+
+ /**
+ * Creates a delegate object for the specified component. If any auxiliary
+ * look and feels support this component, a <code>MultiPopupMenuUI</code> is
+ * returned, otherwise the UI from the default look and feel is returned.
+ *
+ * @param target the component.
+ *
+ * @see MultiLookAndFeel#createUIs(ComponentUI, Vector, JComponent)
+ */
+ public static ComponentUI createUI(JComponent target)
+ {
+ MultiPopupMenuUI mui = new MultiPopupMenuUI();
+ return MultiLookAndFeel.createUIs(mui, mui.uis, target);
+ }
+
+ /**
+ * Calls the {@link ComponentUI#installUI(JComponent)} method for all
+ * the UI delegates managed by this <code>MultiPopupMenuUI</code>.
+ *
+ * @param c the component.
+ */
+ public void installUI(JComponent c)
+ {
+ Iterator iterator = uis.iterator();
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ ui.installUI(c);
+ }
+ }
+
+ /**
+ * Calls the {@link ComponentUI#uninstallUI(JComponent)} method for all
+ * the UI delegates managed by this <code>MultiPopupMenuUI</code>.
+ *
+ * @param c the component.
+ */
+ public void uninstallUI(JComponent c)
+ {
+ Iterator iterator = uis.iterator();
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ ui.uninstallUI(c);
+ }
+ }
+
+ /**
+ * Returns an array containing the UI delegates managed by this
+ * <code>MultiPopupMenuUI</code>. The first item in the array is always
+ * the UI delegate from the installed default look and feel.
+ *
+ * @return An array of UI delegates.
+ */
+ public ComponentUI[] getUIs()
+ {
+ return MultiLookAndFeel.uisToArray(uis);
+ }
+
+ /**
+ * Calls the {@link ComponentUI#contains(JComponent, int, int)} method for all
+ * the UI delegates managed by this <code>MultiPopupMenuUI</code>,
+ * returning the result for the UI delegate from the primary look and
+ * feel.
+ *
+ * @param c the component.
+ * @param x the x-coordinate.
+ * @param y the y-coordinate.
+ *
+ * @return <code>true</code> if the specified (x, y) coordinate falls within
+ * the bounds of the component as rendered by the UI delegate in the
+ * primary look and feel, and <code>false</code> otherwise.
+ */
+ public boolean contains(JComponent c, int x, int y)
+ {
+ boolean result = false;
+ Iterator iterator = uis.iterator();
+ // first UI delegate provides the return value
+ if (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ result = ui.contains(c, x, y);
+ }
+ // return values from auxiliary UI delegates are ignored
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ /* boolean ignored = */ ui.contains(c, x, y);
+ }
+ return result;
+ }
+
+ /**
+ * Calls the {@link ComponentUI#update(Graphics, JComponent)} method for all
+ * the UI delegates managed by this <code>MultiPopupMenuUI</code>.
+ *
+ * @param g the graphics device.
+ * @param c the component.
+ */
+ public void update(Graphics g, JComponent c)
+ {
+ Iterator iterator = uis.iterator();
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ ui.update(g, c);
+ }
+ }
+
+ /**
+ * Calls the <code>paint(Graphics, JComponent)</code> method for all the UI
+ * delegates managed by this <code>MultiPopupMenuUI</code>.
+ *
+ * @param g the graphics device.
+ * @param c the component.
+ */
+ public void paint(Graphics g, JComponent c)
+ {
+ Iterator iterator = uis.iterator();
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ ui.paint(g, c);
+ }
+ }
+
+ /**
+ * Calls the {@link ComponentUI#getPreferredSize(JComponent)} method for all
+ * the UI delegates managed by this <code>MultiPopupMenuUI</code>,
+ * returning the preferred size for the UI delegate from the primary look and
+ * feel.
+ *
+ * @param c the component.
+ *
+ * @return The preferred size returned by the UI delegate from the primary
+ * look and feel.
+ */
+ public Dimension getPreferredSize(JComponent c)
+ {
+ Dimension result = null;
+ Iterator iterator = uis.iterator();
+ // first UI delegate provides the return value
+ if (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ result = ui.getPreferredSize(c);
+ }
+ // return values from auxiliary UI delegates are ignored
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ /* Dimension ignored = */ ui.getPreferredSize(c);
+ }
+ return result;
+ }
+
+ /**
+ * Calls the {@link ComponentUI#getMinimumSize(JComponent)} method for all
+ * the UI delegates managed by this <code>MultiPopupMenuUI</code>,
+ * returning the minimum size for the UI delegate from the primary look and
+ * feel.
+ *
+ * @param c the component.
+ *
+ * @return The minimum size returned by the UI delegate from the primary
+ * look and feel.
+ */
+ public Dimension getMinimumSize(JComponent c)
+ {
+ Dimension result = null;
+ Iterator iterator = uis.iterator();
+ // first UI delegate provides the return value
+ if (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ result = ui.getMinimumSize(c);
+ }
+ // return values from auxiliary UI delegates are ignored
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ /* Dimension ignored = */ ui.getMinimumSize(c);
+ }
+ return result;
+ }
+
+ /**
+ * Calls the {@link ComponentUI#getMaximumSize(JComponent)} method for all
+ * the UI delegates managed by this <code>MultiPopupMenuUI</code>,
+ * returning the maximum size for the UI delegate from the primary look and
+ * feel.
+ *
+ * @param c the component.
+ *
+ * @return The maximum size returned by the UI delegate from the primary
+ * look and feel.
+ */
+ public Dimension getMaximumSize(JComponent c)
+ {
+ Dimension result = null;
+ Iterator iterator = uis.iterator();
+ // first UI delegate provides the return value
+ if (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ result = ui.getMaximumSize(c);
+ }
+ // return values from auxiliary UI delegates are ignored
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ /* Dimension ignored = */ ui.getMaximumSize(c);
+ }
+ return result;
+ }
+
+ /**
+ * Calls the {@link ComponentUI#getAccessibleChildrenCount(JComponent)} method
+ * for all the UI delegates managed by this <code>MultiPopupMenuUI</code>,
+ * returning the count for the UI delegate from the primary look and
+ * feel.
+ *
+ * @param c the component.
+ *
+ * @return The count returned by the UI delegate from the primary
+ * look and feel.
+ */
+ public int getAccessibleChildrenCount(JComponent c)
+ {
+ int result = 0;
+ Iterator iterator = uis.iterator();
+ // first UI delegate provides the return value
+ if (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ result = ui.getAccessibleChildrenCount(c);
+ }
+ // return values from auxiliary UI delegates are ignored
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ /* int ignored = */ ui.getAccessibleChildrenCount(c);
+ }
+ return result;
+ }
+
+ /**
+ * Calls the {@link ComponentUI#getAccessibleChild(JComponent, int)} method
+ * for all the UI delegates managed by this <code>MultiPopupMenuUI</code>,
+ * returning the child for the UI delegate from the primary look and
+ * feel.
+ *
+ * @param c the component
+ * @param i the child index.
+ *
+ * @return The child returned by the UI delegate from the primary
+ * look and feel.
+ */
+ public Accessible getAccessibleChild(JComponent c, int i)
+ {
+ Accessible result = null;
+ Iterator iterator = uis.iterator();
+ // first UI delegate provides the return value
+ if (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ result = ui.getAccessibleChild(c, i);
+ }
+ // return values from auxiliary UI delegates are ignored
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ /* Accessible ignored = */ ui.getAccessibleChild(c, i);
+ }
+ return result;
+ }
+
+}
--- /dev/null
+/* MultiProgressBarUI.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., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 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 javax.swing.plaf.multi;
+
+import java.awt.Dimension;
+import java.awt.Graphics;
+import java.util.Iterator;
+import java.util.Vector;
+
+import javax.accessibility.Accessible;
+import javax.swing.JComponent;
+import javax.swing.LookAndFeel;
+import javax.swing.UIManager;
+import javax.swing.plaf.ComponentUI;
+import javax.swing.plaf.ProgressBarUI;
+
+/**
+ * A UI delegate that that coordinates multiple {@link ProgressBarUI}
+ * instances, one from the primary look and feel, and one or more from the
+ * auxiliary look and feel(s).
+ *
+ * @see UIManager#addAuxiliaryLookAndFeel(LookAndFeel)
+ */
+public class MultiProgressBarUI extends ProgressBarUI
+{
+
+ /** A list of references to the actual component UIs. */
+ protected Vector uis;
+
+ /**
+ * Creates a new <code>MultiProgressBarUI</code> instance.
+ *
+ * @see #createUI(JComponent)
+ */
+ public MultiProgressBarUI()
+ {
+ uis = new Vector();
+ }
+
+ /**
+ * Creates a delegate object for the specified component. If any auxiliary
+ * look and feels support this component, a <code>MultiProgressBarUI</code> is
+ * returned, otherwise the UI from the default look and feel is returned.
+ *
+ * @param target the component.
+ *
+ * @see MultiLookAndFeel#createUIs(ComponentUI, Vector, JComponent)
+ */
+ public static ComponentUI createUI(JComponent target)
+ {
+ MultiProgressBarUI mui = new MultiProgressBarUI();
+ return MultiLookAndFeel.createUIs(mui, mui.uis, target);
+ }
+
+ /**
+ * Calls the {@link ComponentUI#installUI(JComponent)} method for all
+ * the UI delegates managed by this <code>MultiProgressBarUI</code>.
+ *
+ * @param c the component.
+ */
+ public void installUI(JComponent c)
+ {
+ Iterator iterator = uis.iterator();
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ ui.installUI(c);
+ }
+ }
+
+ /**
+ * Calls the {@link ComponentUI#uninstallUI(JComponent)} method for all
+ * the UI delegates managed by this <code>MultiProgressBarUI</code>.
+ *
+ * @param c the component.
+ */
+ public void uninstallUI(JComponent c)
+ {
+ Iterator iterator = uis.iterator();
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ ui.uninstallUI(c);
+ }
+ }
+
+ /**
+ * Returns an array containing the UI delegates managed by this
+ * <code>MultiProgressBarUI</code>. The first item in the array is always
+ * the UI delegate from the installed default look and feel.
+ *
+ * @return An array of UI delegates.
+ */
+ public ComponentUI[] getUIs()
+ {
+ return MultiLookAndFeel.uisToArray(uis);
+ }
+
+ /**
+ * Calls the {@link ComponentUI#contains(JComponent, int, int)} method for all
+ * the UI delegates managed by this <code>MultiProgressBarUI</code>,
+ * returning the result for the UI delegate from the primary look and
+ * feel.
+ *
+ * @param c the component.
+ * @param x the x-coordinate.
+ * @param y the y-coordinate.
+ *
+ * @return <code>true</code> if the specified (x, y) coordinate falls within
+ * the bounds of the component as rendered by the UI delegate in the
+ * primary look and feel, and <code>false</code> otherwise.
+ */
+ public boolean contains(JComponent c, int x, int y)
+ {
+ boolean result = false;
+ Iterator iterator = uis.iterator();
+ // first UI delegate provides the return value
+ if (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ result = ui.contains(c, x, y);
+ }
+ // return values from auxiliary UI delegates are ignored
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ /* boolean ignored = */ ui.contains(c, x, y);
+ }
+ return result;
+ }
+
+ /**
+ * Calls the {@link ComponentUI#update(Graphics, JComponent)} method for all
+ * the UI delegates managed by this <code>MultiProgressBarUI</code>.
+ *
+ * @param g the graphics device.
+ * @param c the component.
+ */
+ public void update(Graphics g, JComponent c)
+ {
+ Iterator iterator = uis.iterator();
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ ui.update(g, c);
+ }
+ }
+
+ /**
+ * Calls the <code>paint(Graphics, JComponent)</code> method for all the UI
+ * delegates managed by this <code>MultiProgressBarUI</code>.
+ *
+ * @param g the graphics device.
+ * @param c the component.
+ */
+ public void paint(Graphics g, JComponent c)
+ {
+ Iterator iterator = uis.iterator();
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ ui.paint(g, c);
+ }
+ }
+
+ /**
+ * Calls the {@link ComponentUI#getPreferredSize(JComponent)} method for all
+ * the UI delegates managed by this <code>MultiProgressBarUI</code>,
+ * returning the preferred size for the UI delegate from the primary look and
+ * feel.
+ *
+ * @param c the component.
+ *
+ * @return The preferred size returned by the UI delegate from the primary
+ * look and feel.
+ */
+ public Dimension getPreferredSize(JComponent c)
+ {
+ Dimension result = null;
+ Iterator iterator = uis.iterator();
+ // first UI delegate provides the return value
+ if (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ result = ui.getPreferredSize(c);
+ }
+ // return values from auxiliary UI delegates are ignored
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ /* Dimension ignored = */ ui.getPreferredSize(c);
+ }
+ return result;
+ }
+
+ /**
+ * Calls the {@link ComponentUI#getMinimumSize(JComponent)} method for all
+ * the UI delegates managed by this <code>MultiProgressBarUI</code>,
+ * returning the minimum size for the UI delegate from the primary look and
+ * feel.
+ *
+ * @param c the component.
+ *
+ * @return The minimum size returned by the UI delegate from the primary
+ * look and feel.
+ */
+ public Dimension getMinimumSize(JComponent c)
+ {
+ Dimension result = null;
+ Iterator iterator = uis.iterator();
+ // first UI delegate provides the return value
+ if (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ result = ui.getMinimumSize(c);
+ }
+ // return values from auxiliary UI delegates are ignored
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ /* Dimension ignored = */ ui.getMinimumSize(c);
+ }
+ return result;
+ }
+
+ /**
+ * Calls the {@link ComponentUI#getMaximumSize(JComponent)} method for all
+ * the UI delegates managed by this <code>MultiProgressBarUI</code>,
+ * returning the maximum size for the UI delegate from the primary look and
+ * feel.
+ *
+ * @param c the component.
+ *
+ * @return The maximum size returned by the UI delegate from the primary
+ * look and feel.
+ */
+ public Dimension getMaximumSize(JComponent c)
+ {
+ Dimension result = null;
+ Iterator iterator = uis.iterator();
+ // first UI delegate provides the return value
+ if (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ result = ui.getMaximumSize(c);
+ }
+ // return values from auxiliary UI delegates are ignored
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ /* Dimension ignored = */ ui.getMaximumSize(c);
+ }
+ return result;
+ }
+
+ /**
+ * Calls the {@link ComponentUI#getAccessibleChildrenCount(JComponent)} method
+ * for all the UI delegates managed by this <code>MultiProgressBarUI</code>,
+ * returning the count for the UI delegate from the primary look and
+ * feel.
+ *
+ * @param c the component.
+ *
+ * @return The count returned by the UI delegate from the primary
+ * look and feel.
+ */
+ public int getAccessibleChildrenCount(JComponent c)
+ {
+ int result = 0;
+ Iterator iterator = uis.iterator();
+ // first UI delegate provides the return value
+ if (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ result = ui.getAccessibleChildrenCount(c);
+ }
+ // return values from auxiliary UI delegates are ignored
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ /* int ignored = */ ui.getAccessibleChildrenCount(c);
+ }
+ return result;
+ }
+
+ /**
+ * Calls the {@link ComponentUI#getAccessibleChild(JComponent, int)} method
+ * for all the UI delegates managed by this <code>MultiProgressBarUI</code>,
+ * returning the child for the UI delegate from the primary look and
+ * feel.
+ *
+ * @param c the component
+ * @param i the child index.
+ *
+ * @return The child returned by the UI delegate from the primary
+ * look and feel.
+ */
+ public Accessible getAccessibleChild(JComponent c, int i)
+ {
+ Accessible result = null;
+ Iterator iterator = uis.iterator();
+ // first UI delegate provides the return value
+ if (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ result = ui.getAccessibleChild(c, i);
+ }
+ // return values from auxiliary UI delegates are ignored
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ /* Accessible ignored = */ ui.getAccessibleChild(c, i);
+ }
+ return result;
+ }
+
+}
--- /dev/null
+/* MultiRootPaneUI.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., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 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 javax.swing.plaf.multi;
+
+import java.awt.Dimension;
+import java.awt.Graphics;
+import java.util.Iterator;
+import java.util.Vector;
+
+import javax.accessibility.Accessible;
+import javax.swing.JComponent;
+import javax.swing.LookAndFeel;
+import javax.swing.UIManager;
+import javax.swing.plaf.ComponentUI;
+import javax.swing.plaf.RootPaneUI;
+
+/**
+ * A UI delegate that that coordinates multiple {@link RootPaneUI}
+ * instances, one from the primary look and feel, and one or more from the
+ * auxiliary look and feel(s).
+ *
+ * @see UIManager#addAuxiliaryLookAndFeel(LookAndFeel)
+ */
+public class MultiRootPaneUI extends RootPaneUI
+{
+
+ /** A list of references to the actual component UIs. */
+ protected Vector uis;
+
+ /**
+ * Creates a new <code>MultiRootPanelUI</code> instance.
+ *
+ * @see #createUI(JComponent)
+ */
+ public MultiRootPaneUI()
+ {
+ uis = new Vector();
+ }
+
+ /**
+ * Creates a delegate object for the specified component. If any auxiliary
+ * look and feels support this component, a <code>MultiRootPaneUI</code> is
+ * returned, otherwise the UI from the default look and feel is returned.
+ *
+ * @param target the component.
+ *
+ * @see MultiLookAndFeel#createUIs(ComponentUI, Vector, JComponent)
+ */
+ public static ComponentUI createUI(JComponent target)
+ {
+ MultiRootPaneUI mui = new MultiRootPaneUI();
+ return MultiLookAndFeel.createUIs(mui, mui.uis, target);
+ }
+
+ /**
+ * Calls the {@link ComponentUI#installUI(JComponent)} method for all
+ * the UI delegates managed by this <code>MultiRootPaneUI</code>.
+ *
+ * @param c the component.
+ */
+ public void installUI(JComponent c)
+ {
+ Iterator iterator = uis.iterator();
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ ui.installUI(c);
+ }
+ }
+
+ /**
+ * Calls the {@link ComponentUI#uninstallUI(JComponent)} method for all
+ * the UI delegates managed by this <code>MultiRootPaneUI</code>.
+ *
+ * @param c the component.
+ */
+ public void uninstallUI(JComponent c)
+ {
+ Iterator iterator = uis.iterator();
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ ui.uninstallUI(c);
+ }
+ }
+
+ /**
+ * Returns an array containing the UI delegates managed by this
+ * <code>MultiRootPaneUI</code>. The first item in the array is always
+ * the UI delegate from the installed default look and feel.
+ *
+ * @return An array of UI delegates.
+ */
+ public ComponentUI[] getUIs()
+ {
+ return MultiLookAndFeel.uisToArray(uis);
+ }
+
+ /**
+ * Calls the {@link ComponentUI#contains(JComponent, int, int)} method for all
+ * the UI delegates managed by this <code>MultiRootPaneUI</code>,
+ * returning the result for the UI delegate from the primary look and
+ * feel.
+ *
+ * @param c the component.
+ * @param x the x-coordinate.
+ * @param y the y-coordinate.
+ *
+ * @return <code>true</code> if the specified (x, y) coordinate falls within
+ * the bounds of the component as rendered by the UI delegate in the
+ * primary look and feel, and <code>false</code> otherwise.
+ */
+ public boolean contains(JComponent c, int x, int y)
+ {
+ boolean result = false;
+ Iterator iterator = uis.iterator();
+ // first UI delegate provides the return value
+ if (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ result = ui.contains(c, x, y);
+ }
+ // return values from auxiliary UI delegates are ignored
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ /* boolean ignored = */ ui.contains(c, x, y);
+ }
+ return result;
+ }
+
+ /**
+ * Calls the {@link ComponentUI#update(Graphics, JComponent)} method for all
+ * the UI delegates managed by this <code>MultiRootPaneUI</code>.
+ *
+ * @param g the graphics device.
+ * @param c the component.
+ */
+ public void update(Graphics g, JComponent c)
+ {
+ Iterator iterator = uis.iterator();
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ ui.update(g, c);
+ }
+ }
+
+ /**
+ * Calls the <code>paint(Graphics, JComponent)</code> method for all the UI
+ * delegates managed by this <code>MultiRootPaneUI</code>.
+ *
+ * @param g the graphics device.
+ * @param c the component.
+ */
+ public void paint(Graphics g, JComponent c)
+ {
+ Iterator iterator = uis.iterator();
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ ui.paint(g, c);
+ }
+ }
+
+ /**
+ * Calls the {@link ComponentUI#getPreferredSize(JComponent)} method for all
+ * the UI delegates managed by this <code>MultiRootPaneUI</code>,
+ * returning the preferred size for the UI delegate from the primary look and
+ * feel.
+ *
+ * @param c the component.
+ *
+ * @return The preferred size returned by the UI delegate from the primary
+ * look and feel.
+ */
+ public Dimension getPreferredSize(JComponent c)
+ {
+ Dimension result = null;
+ Iterator iterator = uis.iterator();
+ // first UI delegate provides the return value
+ if (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ result = ui.getPreferredSize(c);
+ }
+ // return values from auxiliary UI delegates are ignored
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ /* Dimension ignored = */ ui.getPreferredSize(c);
+ }
+ return result;
+ }
+
+ /**
+ * Calls the {@link ComponentUI#getMinimumSize(JComponent)} method for all
+ * the UI delegates managed by this <code>MultiRootPaneUI</code>,
+ * returning the minimum size for the UI delegate from the primary look and
+ * feel.
+ *
+ * @param c the component.
+ *
+ * @return The minimum size returned by the UI delegate from the primary
+ * look and feel.
+ */
+ public Dimension getMinimumSize(JComponent c)
+ {
+ Dimension result = null;
+ Iterator iterator = uis.iterator();
+ // first UI delegate provides the return value
+ if (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ result = ui.getMinimumSize(c);
+ }
+ // return values from auxiliary UI delegates are ignored
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ /* Dimension ignored = */ ui.getMinimumSize(c);
+ }
+ return result;
+ }
+
+ /**
+ * Calls the {@link ComponentUI#getMaximumSize(JComponent)} method for all
+ * the UI delegates managed by this <code>MultiRootPaneUI</code>,
+ * returning the maximum size for the UI delegate from the primary look and
+ * feel.
+ *
+ * @param c the component.
+ *
+ * @return The maximum size returned by the UI delegate from the primary
+ * look and feel.
+ */
+ public Dimension getMaximumSize(JComponent c)
+ {
+ Dimension result = null;
+ Iterator iterator = uis.iterator();
+ // first UI delegate provides the return value
+ if (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ result = ui.getMaximumSize(c);
+ }
+ // return values from auxiliary UI delegates are ignored
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ /* Dimension ignored = */ ui.getMaximumSize(c);
+ }
+ return result;
+ }
+
+ /**
+ * Calls the {@link ComponentUI#getAccessibleChildrenCount(JComponent)} method
+ * for all the UI delegates managed by this <code>MultiRootPaneUI</code>,
+ * returning the count for the UI delegate from the primary look and
+ * feel.
+ *
+ * @param c the component.
+ *
+ * @return The count returned by the UI delegate from the primary
+ * look and feel.
+ */
+ public int getAccessibleChildrenCount(JComponent c)
+ {
+ int result = 0;
+ Iterator iterator = uis.iterator();
+ // first UI delegate provides the return value
+ if (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ result = ui.getAccessibleChildrenCount(c);
+ }
+ // return values from auxiliary UI delegates are ignored
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ /* int ignored = */ ui.getAccessibleChildrenCount(c);
+ }
+ return result;
+ }
+
+ /**
+ * Calls the {@link ComponentUI#getAccessibleChild(JComponent, int)} method
+ * for all the UI delegates managed by this <code>MultiRootPaneUI</code>,
+ * returning the child for the UI delegate from the primary look and
+ * feel.
+ *
+ * @param c the component
+ * @param i the child index.
+ *
+ * @return The child returned by the UI delegate from the primary
+ * look and feel.
+ */
+ public Accessible getAccessibleChild(JComponent c, int i)
+ {
+ Accessible result = null;
+ Iterator iterator = uis.iterator();
+ // first UI delegate provides the return value
+ if (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ result = ui.getAccessibleChild(c, i);
+ }
+ // return values from auxiliary UI delegates are ignored
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ /* Accessible ignored = */ ui.getAccessibleChild(c, i);
+ }
+ return result;
+ }
+
+}
--- /dev/null
+/* MultiScrollBarUI.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., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 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 javax.swing.plaf.multi;
+
+import java.awt.Dimension;
+import java.awt.Graphics;
+import java.util.Iterator;
+import java.util.Vector;
+
+import javax.accessibility.Accessible;
+import javax.swing.JComponent;
+import javax.swing.LookAndFeel;
+import javax.swing.UIManager;
+import javax.swing.plaf.ComponentUI;
+import javax.swing.plaf.ScrollBarUI;
+
+/**
+ * A UI delegate that that coordinates multiple {@link ScrollBarUI}
+ * instances, one from the primary look and feel, and one or more from the
+ * auxiliary look and feel(s).
+ *
+ * @see UIManager#addAuxiliaryLookAndFeel(LookAndFeel)
+ */
+public class MultiScrollBarUI extends ScrollBarUI
+{
+
+ /** A list of references to the actual component UIs. */
+ protected Vector uis;
+
+ /**
+ * Creates a new <code>MultiScrollBarUI</code> instance.
+ *
+ * @see #createUI(JComponent)
+ */
+ public MultiScrollBarUI()
+ {
+ uis = new Vector();
+ }
+
+ /**
+ * Creates a delegate object for the specified component. If any auxiliary
+ * look and feels support this component, a <code>MultiScrollBarUI</code> is
+ * returned, otherwise the UI from the default look and feel is returned.
+ *
+ * @param target the component.
+ *
+ * @see MultiLookAndFeel#createUIs(ComponentUI, Vector, JComponent)
+ */
+ public static ComponentUI createUI(JComponent target)
+ {
+ MultiScrollBarUI mui = new MultiScrollBarUI();
+ return MultiLookAndFeel.createUIs(mui, mui.uis, target);
+ }
+
+ /**
+ * Calls the {@link ComponentUI#installUI(JComponent)} method for all
+ * the UI delegates managed by this <code>MultiScrollBarUI</code>.
+ *
+ * @param c the component.
+ */
+ public void installUI(JComponent c)
+ {
+ Iterator iterator = uis.iterator();
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ ui.installUI(c);
+ }
+ }
+
+ /**
+ * Calls the {@link ComponentUI#uninstallUI(JComponent)} method for all
+ * the UI delegates managed by this <code>MultiScrollBarUI</code>.
+ *
+ * @param c the component.
+ */
+ public void uninstallUI(JComponent c)
+ {
+ Iterator iterator = uis.iterator();
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ ui.uninstallUI(c);
+ }
+ }
+
+ /**
+ * Returns an array containing the UI delegates managed by this
+ * <code>MultiScrollBarUI</code>. The first item in the array is always
+ * the UI delegate from the installed default look and feel.
+ *
+ * @return An array of UI delegates.
+ */
+ public ComponentUI[] getUIs()
+ {
+ return MultiLookAndFeel.uisToArray(uis);
+ }
+
+ /**
+ * Calls the {@link ComponentUI#contains(JComponent, int, int)} method for all
+ * the UI delegates managed by this <code>MultiScrollBarUI</code>,
+ * returning the result for the UI delegate from the primary look and
+ * feel.
+ *
+ * @param c the component.
+ * @param x the x-coordinate.
+ * @param y the y-coordinate.
+ *
+ * @return <code>true</code> if the specified (x, y) coordinate falls within
+ * the bounds of the component as rendered by the UI delegate in the
+ * primary look and feel, and <code>false</code> otherwise.
+ */
+ public boolean contains(JComponent c, int x, int y)
+ {
+ boolean result = false;
+ Iterator iterator = uis.iterator();
+ // first UI delegate provides the return value
+ if (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ result = ui.contains(c, x, y);
+ }
+ // return values from auxiliary UI delegates are ignored
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ /* boolean ignored = */ ui.contains(c, x, y);
+ }
+ return result;
+ }
+
+ /**
+ * Calls the {@link ComponentUI#update(Graphics, JComponent)} method for all
+ * the UI delegates managed by this <code>MultiScrollBarUI</code>.
+ *
+ * @param g the graphics device.
+ * @param c the component.
+ */
+ public void update(Graphics g, JComponent c)
+ {
+ Iterator iterator = uis.iterator();
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ ui.update(g, c);
+ }
+ }
+
+ /**
+ * Calls the <code>paint(Graphics, JComponent)</code> method for all the UI
+ * delegates managed by this <code>MultiScrollBarUI</code>.
+ *
+ * @param g the graphics device.
+ * @param c the component.
+ */
+ public void paint(Graphics g, JComponent c)
+ {
+ Iterator iterator = uis.iterator();
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ ui.paint(g, c);
+ }
+ }
+
+ /**
+ * Calls the {@link ComponentUI#getPreferredSize(JComponent)} method for all
+ * the UI delegates managed by this <code>MultiScrollBarUI</code>,
+ * returning the preferred size for the UI delegate from the primary look and
+ * feel.
+ *
+ * @param c the component.
+ *
+ * @return The preferred size returned by the UI delegate from the primary
+ * look and feel.
+ */
+ public Dimension getPreferredSize(JComponent c)
+ {
+ Dimension result = null;
+ Iterator iterator = uis.iterator();
+ // first UI delegate provides the return value
+ if (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ result = ui.getPreferredSize(c);
+ }
+ // return values from auxiliary UI delegates are ignored
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ /* Dimension ignored = */ ui.getPreferredSize(c);
+ }
+ return result;
+ }
+
+ /**
+ * Calls the {@link ComponentUI#getMinimumSize(JComponent)} method for all
+ * the UI delegates managed by this <code>MultiScrollBarUI</code>,
+ * returning the minimum size for the UI delegate from the primary look and
+ * feel.
+ *
+ * @param c the component.
+ *
+ * @return The minimum size returned by the UI delegate from the primary
+ * look and feel.
+ */
+ public Dimension getMinimumSize(JComponent c)
+ {
+ Dimension result = null;
+ Iterator iterator = uis.iterator();
+ // first UI delegate provides the return value
+ if (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ result = ui.getMinimumSize(c);
+ }
+ // return values from auxiliary UI delegates are ignored
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ /* Dimension ignored = */ ui.getMinimumSize(c);
+ }
+ return result;
+ }
+
+ /**
+ * Calls the {@link ComponentUI#getMaximumSize(JComponent)} method for all
+ * the UI delegates managed by this <code>MultiScrollBarUI</code>,
+ * returning the maximum size for the UI delegate from the primary look and
+ * feel.
+ *
+ * @param c the component.
+ *
+ * @return The maximum size returned by the UI delegate from the primary
+ * look and feel.
+ */
+ public Dimension getMaximumSize(JComponent c)
+ {
+ Dimension result = null;
+ Iterator iterator = uis.iterator();
+ // first UI delegate provides the return value
+ if (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ result = ui.getMaximumSize(c);
+ }
+ // return values from auxiliary UI delegates are ignored
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ /* Dimension ignored = */ ui.getMaximumSize(c);
+ }
+ return result;
+ }
+
+ /**
+ * Calls the {@link ComponentUI#getAccessibleChildrenCount(JComponent)} method
+ * for all the UI delegates managed by this <code>MultiScrollBarUI</code>,
+ * returning the count for the UI delegate from the primary look and
+ * feel.
+ *
+ * @param c the component.
+ *
+ * @return The count returned by the UI delegate from the primary
+ * look and feel.
+ */
+ public int getAccessibleChildrenCount(JComponent c)
+ {
+ int result = 0;
+ Iterator iterator = uis.iterator();
+ // first UI delegate provides the return value
+ if (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ result = ui.getAccessibleChildrenCount(c);
+ }
+ // return values from auxiliary UI delegates are ignored
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ /* int ignored = */ ui.getAccessibleChildrenCount(c);
+ }
+ return result;
+ }
+
+ /**
+ * Calls the {@link ComponentUI#getAccessibleChild(JComponent, int)} method
+ * for all the UI delegates managed by this <code>MultiScrollBarUI</code>,
+ * returning the child for the UI delegate from the primary look and
+ * feel.
+ *
+ * @param c the component
+ * @param i the child index.
+ *
+ * @return The child returned by the UI delegate from the primary
+ * look and feel.
+ */
+ public Accessible getAccessibleChild(JComponent c, int i)
+ {
+ Accessible result = null;
+ Iterator iterator = uis.iterator();
+ // first UI delegate provides the return value
+ if (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ result = ui.getAccessibleChild(c, i);
+ }
+ // return values from auxiliary UI delegates are ignored
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ /* Accessible ignored = */ ui.getAccessibleChild(c, i);
+ }
+ return result;
+ }
+
+}
--- /dev/null
+/* MultiScrollPaneUI.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., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 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 javax.swing.plaf.multi;
+
+import java.awt.Dimension;
+import java.awt.Graphics;
+import java.util.Iterator;
+import java.util.Vector;
+
+import javax.accessibility.Accessible;
+import javax.swing.JComponent;
+import javax.swing.LookAndFeel;
+import javax.swing.UIManager;
+import javax.swing.plaf.ComponentUI;
+import javax.swing.plaf.ScrollPaneUI;
+
+/**
+ * A UI delegate that that coordinates multiple {@link ScrollPaneUI}
+ * instances, one from the primary look and feel, and one or more from the
+ * auxiliary look and feel(s).
+ *
+ * @see UIManager#addAuxiliaryLookAndFeel(LookAndFeel)
+ */
+public class MultiScrollPaneUI extends ScrollPaneUI
+{
+
+ /** A list of references to the actual component UIs. */
+ protected Vector uis;
+
+ /**
+ * Creates a new <code>MultiScrollPaneUI</code> instance.
+ *
+ * @see #createUI(JComponent)
+ */
+ public MultiScrollPaneUI()
+ {
+ uis = new Vector();
+ }
+
+ /**
+ * Creates a delegate object for the specified component. If any auxiliary
+ * look and feels support this component, a <code>MultiScrollPaneUI</code> is
+ * returned, otherwise the UI from the default look and feel is returned.
+ *
+ * @param target the component.
+ *
+ * @see MultiLookAndFeel#createUIs(ComponentUI, Vector, JComponent)
+ */
+ public static ComponentUI createUI(JComponent target)
+ {
+ MultiScrollPaneUI mui = new MultiScrollPaneUI();
+ return MultiLookAndFeel.createUIs(mui, mui.uis, target);
+ }
+
+ /**
+ * Calls the {@link ComponentUI#installUI(JComponent)} method for all
+ * the UI delegates managed by this <code>MultiScrollPaneUI</code>.
+ *
+ * @param c the component.
+ */
+ public void installUI(JComponent c)
+ {
+ Iterator iterator = uis.iterator();
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ ui.installUI(c);
+ }
+ }
+
+ /**
+ * Calls the {@link ComponentUI#uninstallUI(JComponent)} method for all
+ * the UI delegates managed by this <code>MultiScrollPaneUI</code>.
+ *
+ * @param c the component.
+ */
+ public void uninstallUI(JComponent c)
+ {
+ Iterator iterator = uis.iterator();
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ ui.uninstallUI(c);
+ }
+ }
+
+ /**
+ * Returns an array containing the UI delegates managed by this
+ * <code>MultiScrollPaneUI</code>. The first item in the array is always
+ * the UI delegate from the installed default look and feel.
+ *
+ * @return An array of UI delegates.
+ */
+ public ComponentUI[] getUIs()
+ {
+ return MultiLookAndFeel.uisToArray(uis);
+ }
+
+ /**
+ * Calls the {@link ComponentUI#contains(JComponent, int, int)} method for all
+ * the UI delegates managed by this <code>MultiScrollPaneUI</code>,
+ * returning the result for the UI delegate from the primary look and
+ * feel.
+ *
+ * @param c the component.
+ * @param x the x-coordinate.
+ * @param y the y-coordinate.
+ *
+ * @return <code>true</code> if the specified (x, y) coordinate falls within
+ * the bounds of the component as rendered by the UI delegate in the
+ * primary look and feel, and <code>false</code> otherwise.
+ */
+ public boolean contains(JComponent c, int x, int y)
+ {
+ boolean result = false;
+ Iterator iterator = uis.iterator();
+ // first UI delegate provides the return value
+ if (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ result = ui.contains(c, x, y);
+ }
+ // return values from auxiliary UI delegates are ignored
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ /* boolean ignored = */ ui.contains(c, x, y);
+ }
+ return result;
+ }
+
+ /**
+ * Calls the {@link ComponentUI#update(Graphics, JComponent)} method for all
+ * the UI delegates managed by this <code>MultiScrollPaneUI</code>.
+ *
+ * @param g the graphics device.
+ * @param c the component.
+ */
+ public void update(Graphics g, JComponent c)
+ {
+ Iterator iterator = uis.iterator();
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ ui.update(g, c);
+ }
+ }
+
+ /**
+ * Calls the <code>paint(Graphics, JComponent)</code> method for all the UI
+ * delegates managed by this <code>MultiScrollPaneUI</code>.
+ *
+ * @param g the graphics device.
+ * @param c the component.
+ */
+ public void paint(Graphics g, JComponent c)
+ {
+ Iterator iterator = uis.iterator();
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ ui.paint(g, c);
+ }
+ }
+
+ /**
+ * Calls the {@link ComponentUI#getPreferredSize(JComponent)} method for all
+ * the UI delegates managed by this <code>MultiScrollPaneUI</code>,
+ * returning the preferred size for the UI delegate from the primary look and
+ * feel.
+ *
+ * @param c the component.
+ *
+ * @return The preferred size returned by the UI delegate from the primary
+ * look and feel.
+ */
+ public Dimension getPreferredSize(JComponent c)
+ {
+ Dimension result = null;
+ Iterator iterator = uis.iterator();
+ // first UI delegate provides the return value
+ if (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ result = ui.getPreferredSize(c);
+ }
+ // return values from auxiliary UI delegates are ignored
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ /* Dimension ignored = */ ui.getPreferredSize(c);
+ }
+ return result;
+ }
+
+ /**
+ * Calls the {@link ComponentUI#getMinimumSize(JComponent)} method for all
+ * the UI delegates managed by this <code>MultiScrollPaneUI</code>,
+ * returning the minimum size for the UI delegate from the primary look and
+ * feel.
+ *
+ * @param c the component.
+ *
+ * @return The minimum size returned by the UI delegate from the primary
+ * look and feel.
+ */
+ public Dimension getMinimumSize(JComponent c)
+ {
+ Dimension result = null;
+ Iterator iterator = uis.iterator();
+ // first UI delegate provides the return value
+ if (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ result = ui.getMinimumSize(c);
+ }
+ // return values from auxiliary UI delegates are ignored
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ /* Dimension ignored = */ ui.getMinimumSize(c);
+ }
+ return result;
+ }
+
+ /**
+ * Calls the {@link ComponentUI#getMaximumSize(JComponent)} method for all
+ * the UI delegates managed by this <code>MultiScrollPaneUI</code>,
+ * returning the maximum size for the UI delegate from the primary look and
+ * feel.
+ *
+ * @param c the component.
+ *
+ * @return The maximum size returned by the UI delegate from the primary
+ * look and feel.
+ */
+ public Dimension getMaximumSize(JComponent c)
+ {
+ Dimension result = null;
+ Iterator iterator = uis.iterator();
+ // first UI delegate provides the return value
+ if (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ result = ui.getMaximumSize(c);
+ }
+ // return values from auxiliary UI delegates are ignored
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ /* Dimension ignored = */ ui.getMaximumSize(c);
+ }
+ return result;
+ }
+
+ /**
+ * Calls the {@link ComponentUI#getAccessibleChildrenCount(JComponent)} method
+ * for all the UI delegates managed by this <code>MultiScrollPaneUI</code>,
+ * returning the count for the UI delegate from the primary look and
+ * feel.
+ *
+ * @param c the component.
+ *
+ * @return The count returned by the UI delegate from the primary
+ * look and feel.
+ */
+ public int getAccessibleChildrenCount(JComponent c)
+ {
+ int result = 0;
+ Iterator iterator = uis.iterator();
+ // first UI delegate provides the return value
+ if (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ result = ui.getAccessibleChildrenCount(c);
+ }
+ // return values from auxiliary UI delegates are ignored
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ /* int ignored = */ ui.getAccessibleChildrenCount(c);
+ }
+ return result;
+ }
+
+ /**
+ * Calls the {@link ComponentUI#getAccessibleChild(JComponent, int)} method
+ * for all the UI delegates managed by this <code>MultiScrollPaneUI</code>,
+ * returning the child for the UI delegate from the primary look and
+ * feel.
+ *
+ * @param c the component
+ * @param i the child index.
+ *
+ * @return The child returned by the UI delegate from the primary
+ * look and feel.
+ */
+ public Accessible getAccessibleChild(JComponent c, int i)
+ {
+ Accessible result = null;
+ Iterator iterator = uis.iterator();
+ // first UI delegate provides the return value
+ if (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ result = ui.getAccessibleChild(c, i);
+ }
+ // return values from auxiliary UI delegates are ignored
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ /* Accessible ignored = */ ui.getAccessibleChild(c, i);
+ }
+ return result;
+ }
+
+}
--- /dev/null
+/* MultiSeparatorUI.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., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 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 javax.swing.plaf.multi;
+
+import java.awt.Dimension;
+import java.awt.Graphics;
+import java.util.Iterator;
+import java.util.Vector;
+
+import javax.accessibility.Accessible;
+import javax.swing.JComponent;
+import javax.swing.LookAndFeel;
+import javax.swing.UIManager;
+import javax.swing.plaf.ComponentUI;
+import javax.swing.plaf.SeparatorUI;
+
+/**
+ * A UI delegate that that coordinates multiple {@link MultiSeparatorUI}
+ * instances, one from the primary look and feel, and one or more from the
+ * auxiliary look and feel(s).
+ *
+ * @see UIManager#addAuxiliaryLookAndFeel(LookAndFeel)
+ */
+public class MultiSeparatorUI extends SeparatorUI
+{
+
+ /** A list of references to the actual component UIs. */
+ protected Vector uis;
+
+ /**
+ * Creates a new <code>MultiSeparatorUI</code> instance.
+ *
+ * @see #createUI(JComponent)
+ */
+ public MultiSeparatorUI()
+ {
+ uis = new Vector();
+ }
+
+ /**
+ * Creates a delegate object for the specified component. If any auxiliary
+ * look and feels support this component, a <code>MultiSeparatorUI</code> is
+ * returned, otherwise the UI from the default look and feel is returned.
+ *
+ * @param target the component.
+ *
+ * @see MultiLookAndFeel#createUIs(ComponentUI, Vector, JComponent)
+ */
+ public static ComponentUI createUI(JComponent target)
+ {
+ MultiSeparatorUI mui = new MultiSeparatorUI();
+ return MultiLookAndFeel.createUIs(mui, mui.uis, target);
+ }
+
+ /**
+ * Calls the {@link ComponentUI#installUI(JComponent)} method for all
+ * the UI delegates managed by this <code>MultiSeparatorUI</code>.
+ *
+ * @param c the component.
+ */
+ public void installUI(JComponent c)
+ {
+ Iterator iterator = uis.iterator();
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ ui.installUI(c);
+ }
+ }
+
+ /**
+ * Calls the {@link ComponentUI#uninstallUI(JComponent)} method for all
+ * the UI delegates managed by this <code>MultiSeparatorUI</code>.
+ *
+ * @param c the component.
+ */
+ public void uninstallUI(JComponent c)
+ {
+ Iterator iterator = uis.iterator();
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ ui.uninstallUI(c);
+ }
+ }
+
+ /**
+ * Returns an array containing the UI delegates managed by this
+ * <code>MultiSeparatorUI</code>. The first item in the array is always
+ * the UI delegate from the installed default look and feel.
+ *
+ * @return An array of UI delegates.
+ */
+ public ComponentUI[] getUIs()
+ {
+ return MultiLookAndFeel.uisToArray(uis);
+ }
+
+ /**
+ * Calls the {@link ComponentUI#contains(JComponent, int, int)} method for all
+ * the UI delegates managed by this <code>MultiSeparatorUI</code>,
+ * returning the result for the UI delegate from the primary look and
+ * feel.
+ *
+ * @param c the component.
+ * @param x the x-coordinate.
+ * @param y the y-coordinate.
+ *
+ * @return <code>true</code> if the specified (x, y) coordinate falls within
+ * the bounds of the component as rendered by the UI delegate in the
+ * primary look and feel, and <code>false</code> otherwise.
+ */
+ public boolean contains(JComponent c, int x, int y)
+ {
+ boolean result = false;
+ Iterator iterator = uis.iterator();
+ // first UI delegate provides the return value
+ if (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ result = ui.contains(c, x, y);
+ }
+ // return values from auxiliary UI delegates are ignored
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ /* boolean ignored = */ ui.contains(c, x, y);
+ }
+ return result;
+ }
+
+ /**
+ * Calls the {@link ComponentUI#update(Graphics, JComponent)} method for all
+ * the UI delegates managed by this <code>MultiSeparatorUI</code>.
+ *
+ * @param g the graphics device.
+ * @param c the component.
+ */
+ public void update(Graphics g, JComponent c)
+ {
+ Iterator iterator = uis.iterator();
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ ui.update(g, c);
+ }
+ }
+
+ /**
+ * Calls the <code>paint(Graphics, JComponent)</code> method for all the UI
+ * delegates managed by this <code>MultiSeparatorUI</code>.
+ *
+ * @param g the graphics device.
+ * @param c the component.
+ */
+ public void paint(Graphics g, JComponent c)
+ {
+ Iterator iterator = uis.iterator();
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ ui.paint(g, c);
+ }
+ }
+
+ /**
+ * Calls the {@link ComponentUI#getPreferredSize(JComponent)} method for all
+ * the UI delegates managed by this <code>MultiSeparatorUI</code>,
+ * returning the preferred size for the UI delegate from the primary look and
+ * feel.
+ *
+ * @param c the component.
+ *
+ * @return The preferred size returned by the UI delegate from the primary
+ * look and feel.
+ */
+ public Dimension getPreferredSize(JComponent c)
+ {
+ Dimension result = null;
+ Iterator iterator = uis.iterator();
+ // first UI delegate provides the return value
+ if (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ result = ui.getPreferredSize(c);
+ }
+ // return values from auxiliary UI delegates are ignored
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ /* Dimension ignored = */ ui.getPreferredSize(c);
+ }
+ return result;
+ }
+
+ /**
+ * Calls the {@link ComponentUI#getMinimumSize(JComponent)} method for all
+ * the UI delegates managed by this <code>MultiSeparatorUI</code>,
+ * returning the minimum size for the UI delegate from the primary look and
+ * feel.
+ *
+ * @param c the component.
+ *
+ * @return The minimum size returned by the UI delegate from the primary
+ * look and feel.
+ */
+ public Dimension getMinimumSize(JComponent c)
+ {
+ Dimension result = null;
+ Iterator iterator = uis.iterator();
+ // first UI delegate provides the return value
+ if (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ result = ui.getMinimumSize(c);
+ }
+ // return values from auxiliary UI delegates are ignored
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ /* Dimension ignored = */ ui.getMinimumSize(c);
+ }
+ return result;
+ }
+
+ /**
+ * Calls the {@link ComponentUI#getMaximumSize(JComponent)} method for all
+ * the UI delegates managed by this <code>MultiSeparatorUI</code>,
+ * returning the maximum size for the UI delegate from the primary look and
+ * feel.
+ *
+ * @param c the component.
+ *
+ * @return The maximum size returned by the UI delegate from the primary
+ * look and feel.
+ */
+ public Dimension getMaximumSize(JComponent c)
+ {
+ Dimension result = null;
+ Iterator iterator = uis.iterator();
+ // first UI delegate provides the return value
+ if (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ result = ui.getMaximumSize(c);
+ }
+ // return values from auxiliary UI delegates are ignored
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ /* Dimension ignored = */ ui.getMaximumSize(c);
+ }
+ return result;
+ }
+
+ /**
+ * Calls the {@link ComponentUI#getAccessibleChildrenCount(JComponent)} method
+ * for all the UI delegates managed by this <code>MultiSeparatorUI</code>,
+ * returning the count for the UI delegate from the primary look and
+ * feel.
+ *
+ * @param c the component.
+ *
+ * @return The count returned by the UI delegate from the primary
+ * look and feel.
+ */
+ public int getAccessibleChildrenCount(JComponent c)
+ {
+ int result = 0;
+ Iterator iterator = uis.iterator();
+ // first UI delegate provides the return value
+ if (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ result = ui.getAccessibleChildrenCount(c);
+ }
+ // return values from auxiliary UI delegates are ignored
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ /* int ignored = */ ui.getAccessibleChildrenCount(c);
+ }
+ return result;
+ }
+
+ /**
+ * Calls the {@link ComponentUI#getAccessibleChild(JComponent, int)} method
+ * for all the UI delegates managed by this <code>MultiSeparatorUI</code>,
+ * returning the child for the UI delegate from the primary look and
+ * feel.
+ *
+ * @param c the component
+ * @param i the child index.
+ *
+ * @return The child returned by the UI delegate from the primary
+ * look and feel.
+ */
+ public Accessible getAccessibleChild(JComponent c, int i)
+ {
+ Accessible result = null;
+ Iterator iterator = uis.iterator();
+ // first UI delegate provides the return value
+ if (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ result = ui.getAccessibleChild(c, i);
+ }
+ // return values from auxiliary UI delegates are ignored
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ /* Accessible ignored = */ ui.getAccessibleChild(c, i);
+ }
+ return result;
+ }
+
+}
--- /dev/null
+/* MultiSliderUI.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., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 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 javax.swing.plaf.multi;
+
+import java.awt.Dimension;
+import java.awt.Graphics;
+import java.util.Iterator;
+import java.util.Vector;
+
+import javax.accessibility.Accessible;
+import javax.swing.JComponent;
+import javax.swing.LookAndFeel;
+import javax.swing.UIManager;
+import javax.swing.plaf.ComponentUI;
+import javax.swing.plaf.SliderUI;
+
+/**
+ * A UI delegate that that coordinates multiple {@link SliderUI}
+ * instances, one from the primary look and feel, and one or more from the
+ * auxiliary look and feel(s).
+ *
+ * @see UIManager#addAuxiliaryLookAndFeel(LookAndFeel)
+ */
+public class MultiSliderUI extends SliderUI
+{
+
+ /** A list of references to the actual component UIs. */
+ protected Vector uis;
+
+ /**
+ * Creates a new <code>MultiSliderUI</code> instance.
+ *
+ * @see #createUI(JComponent)
+ */
+ public MultiSliderUI()
+ {
+ uis = new Vector();
+ }
+
+ /**
+ * Creates a delegate object for the specified component. If any auxiliary
+ * look and feels support this component, a <code>MultiSliderUI</code> is
+ * returned, otherwise the UI from the default look and feel is returned.
+ *
+ * @param target the component.
+ *
+ * @see MultiLookAndFeel#createUIs(ComponentUI, Vector, JComponent)
+ */
+ public static ComponentUI createUI(JComponent target)
+ {
+ MultiSliderUI mui = new MultiSliderUI();
+ return MultiLookAndFeel.createUIs(mui, mui.uis, target);
+ }
+
+ /**
+ * Calls the {@link ComponentUI#installUI(JComponent)} method for all
+ * the UI delegates managed by this <code>MultiSliderUI</code>.
+ *
+ * @param c the component.
+ */
+ public void installUI(JComponent c)
+ {
+ Iterator iterator = uis.iterator();
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ ui.installUI(c);
+ }
+ }
+
+ /**
+ * Calls the {@link ComponentUI#uninstallUI(JComponent)} method for all
+ * the UI delegates managed by this <code>MultiSliderUI</code>.
+ *
+ * @param c the component.
+ */
+ public void uninstallUI(JComponent c)
+ {
+ Iterator iterator = uis.iterator();
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ ui.uninstallUI(c);
+ }
+ }
+
+ /**
+ * Returns an array containing the UI delegates managed by this
+ * <code>MultiSliderUI</code>. The first item in the array is always
+ * the UI delegate from the installed default look and feel.
+ *
+ * @return An array of UI delegates.
+ */
+ public ComponentUI[] getUIs()
+ {
+ return MultiLookAndFeel.uisToArray(uis);
+ }
+
+ /**
+ * Calls the {@link ComponentUI#contains(JComponent, int, int)} method for all
+ * the UI delegates managed by this <code>MultiSliderUI</code>,
+ * returning the result for the UI delegate from the primary look and
+ * feel.
+ *
+ * @param c the component.
+ * @param x the x-coordinate.
+ * @param y the y-coordinate.
+ *
+ * @return <code>true</code> if the specified (x, y) coordinate falls within
+ * the bounds of the component as rendered by the UI delegate in the
+ * primary look and feel, and <code>false</code> otherwise.
+ */
+ public boolean contains(JComponent c, int x, int y)
+ {
+ boolean result = false;
+ Iterator iterator = uis.iterator();
+ // first UI delegate provides the return value
+ if (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ result = ui.contains(c, x, y);
+ }
+ // return values from auxiliary UI delegates are ignored
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ /* boolean ignored = */ ui.contains(c, x, y);
+ }
+ return result;
+ }
+
+ /**
+ * Calls the {@link ComponentUI#update(Graphics, JComponent)} method for all
+ * the UI delegates managed by this <code>MultiSliderUI</code>.
+ *
+ * @param g the graphics device.
+ * @param c the component.
+ */
+ public void update(Graphics g, JComponent c)
+ {
+ Iterator iterator = uis.iterator();
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ ui.update(g, c);
+ }
+ }
+
+ /**
+ * Calls the <code>paint(Graphics, JComponent)</code> method for all the UI
+ * delegates managed by this <code>MultiSliderUI</code>.
+ *
+ * @param g the graphics device.
+ * @param c the component.
+ */
+ public void paint(Graphics g, JComponent c)
+ {
+ Iterator iterator = uis.iterator();
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ ui.paint(g, c);
+ }
+ }
+
+ /**
+ * Calls the {@link ComponentUI#getPreferredSize(JComponent)} method for all
+ * the UI delegates managed by this <code>MultiSliderUI</code>,
+ * returning the preferred size for the UI delegate from the primary look and
+ * feel.
+ *
+ * @param c the component.
+ *
+ * @return The preferred size returned by the UI delegate from the primary
+ * look and feel.
+ */
+ public Dimension getPreferredSize(JComponent c)
+ {
+ Dimension result = null;
+ Iterator iterator = uis.iterator();
+ // first UI delegate provides the return value
+ if (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ result = ui.getPreferredSize(c);
+ }
+ // return values from auxiliary UI delegates are ignored
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ /* Dimension ignored = */ ui.getPreferredSize(c);
+ }
+ return result;
+ }
+
+ /**
+ * Calls the {@link ComponentUI#getMinimumSize(JComponent)} method for all
+ * the UI delegates managed by this <code>MultiSliderUI</code>,
+ * returning the minimum size for the UI delegate from the primary look and
+ * feel.
+ *
+ * @param c the component.
+ *
+ * @return The minimum size returned by the UI delegate from the primary
+ * look and feel.
+ */
+ public Dimension getMinimumSize(JComponent c)
+ {
+ Dimension result = null;
+ Iterator iterator = uis.iterator();
+ // first UI delegate provides the return value
+ if (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ result = ui.getMinimumSize(c);
+ }
+ // return values from auxiliary UI delegates are ignored
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ /* Dimension ignored = */ ui.getMinimumSize(c);
+ }
+ return result;
+ }
+
+ /**
+ * Calls the {@link ComponentUI#getMaximumSize(JComponent)} method for all
+ * the UI delegates managed by this <code>MultiSliderUI</code>,
+ * returning the maximum size for the UI delegate from the primary look and
+ * feel.
+ *
+ * @param c the component.
+ *
+ * @return The maximum size returned by the UI delegate from the primary
+ * look and feel.
+ */
+ public Dimension getMaximumSize(JComponent c)
+ {
+ Dimension result = null;
+ Iterator iterator = uis.iterator();
+ // first UI delegate provides the return value
+ if (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ result = ui.getMaximumSize(c);
+ }
+ // return values from auxiliary UI delegates are ignored
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ /* Dimension ignored = */ ui.getMaximumSize(c);
+ }
+ return result;
+ }
+
+ /**
+ * Calls the {@link ComponentUI#getAccessibleChildrenCount(JComponent)} method
+ * for all the UI delegates managed by this <code>MultiSliderUI</code>,
+ * returning the count for the UI delegate from the primary look and
+ * feel.
+ *
+ * @param c the component.
+ *
+ * @return The count returned by the UI delegate from the primary
+ * look and feel.
+ */
+ public int getAccessibleChildrenCount(JComponent c)
+ {
+ int result = 0;
+ Iterator iterator = uis.iterator();
+ // first UI delegate provides the return value
+ if (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ result = ui.getAccessibleChildrenCount(c);
+ }
+ // return values from auxiliary UI delegates are ignored
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ /* int ignored = */ ui.getAccessibleChildrenCount(c);
+ }
+ return result;
+ }
+
+ /**
+ * Calls the {@link ComponentUI#getAccessibleChild(JComponent, int)} method
+ * for all the UI delegates managed by this <code>MultiSliderUI</code>,
+ * returning the child for the UI delegate from the primary look and
+ * feel.
+ *
+ * @param c the component
+ * @param i the child index.
+ *
+ * @return The child returned by the UI delegate from the primary
+ * look and feel.
+ */
+ public Accessible getAccessibleChild(JComponent c, int i)
+ {
+ Accessible result = null;
+ Iterator iterator = uis.iterator();
+ // first UI delegate provides the return value
+ if (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ result = ui.getAccessibleChild(c, i);
+ }
+ // return values from auxiliary UI delegates are ignored
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ /* Accessible ignored = */ ui.getAccessibleChild(c, i);
+ }
+ return result;
+ }
+
+}
--- /dev/null
+/* MultiSpinnerUI.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., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 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 javax.swing.plaf.multi;
+
+import java.awt.Dimension;
+import java.awt.Graphics;
+import java.util.Iterator;
+import java.util.Vector;
+
+import javax.accessibility.Accessible;
+import javax.swing.JComponent;
+import javax.swing.LookAndFeel;
+import javax.swing.UIManager;
+import javax.swing.plaf.ComponentUI;
+import javax.swing.plaf.SpinnerUI;
+
+/**
+ * A UI delegate that that coordinates multiple {@link SpinnerUI}
+ * instances, one from the primary look and feel, and one or more from the
+ * auxiliary look and feel(s).
+ *
+ * @see UIManager#addAuxiliaryLookAndFeel(LookAndFeel)
+ */
+public class MultiSpinnerUI extends SpinnerUI
+{
+
+ /** A list of references to the actual component UIs. */
+ protected Vector uis;
+
+ /**
+ * Creates a new <code>MultiSpinnerUI</code> instance.
+ *
+ * @see #createUI(JComponent)
+ */
+ public MultiSpinnerUI()
+ {
+ uis = new Vector();
+ }
+
+ /**
+ * Creates a delegate object for the specified component. If any auxiliary
+ * look and feels support this component, a <code>MultiSpinnerUI</code> is
+ * returned, otherwise the UI from the default look and feel is returned.
+ *
+ * @param target the component.
+ *
+ * @see MultiLookAndFeel#createUIs(ComponentUI, Vector, JComponent)
+ */
+ public static ComponentUI createUI(JComponent target)
+ {
+ MultiSpinnerUI mui = new MultiSpinnerUI();
+ return MultiLookAndFeel.createUIs(mui, mui.uis, target);
+ }
+
+ /**
+ * Calls the {@link ComponentUI#installUI(JComponent)} method for all
+ * the UI delegates managed by this <code>MultiSpinnerUI</code>.
+ *
+ * @param c the component.
+ */
+ public void installUI(JComponent c)
+ {
+ Iterator iterator = uis.iterator();
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ ui.installUI(c);
+ }
+ }
+
+ /**
+ * Calls the {@link ComponentUI#uninstallUI(JComponent)} method for all
+ * the UI delegates managed by this <code>MultiSpinnerUI</code>.
+ *
+ * @param c the component.
+ */
+ public void uninstallUI(JComponent c)
+ {
+ Iterator iterator = uis.iterator();
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ ui.uninstallUI(c);
+ }
+ }
+
+ /**
+ * Returns an array containing the UI delegates managed by this
+ * <code>MultiSpinnerUI</code>. The first item in the array is always
+ * the UI delegate from the installed default look and feel.
+ *
+ * @return An array of UI delegates.
+ */
+ public ComponentUI[] getUIs()
+ {
+ return MultiLookAndFeel.uisToArray(uis);
+ }
+
+ /**
+ * Calls the {@link ComponentUI#contains(JComponent, int, int)} method for all
+ * the UI delegates managed by this <code>MultiSpinnerUI</code>,
+ * returning the result for the UI delegate from the primary look and
+ * feel.
+ *
+ * @param c the component.
+ * @param x the x-coordinate.
+ * @param y the y-coordinate.
+ *
+ * @return <code>true</code> if the specified (x, y) coordinate falls within
+ * the bounds of the component as rendered by the UI delegate in the
+ * primary look and feel, and <code>false</code> otherwise.
+ */
+ public boolean contains(JComponent c, int x, int y)
+ {
+ boolean result = false;
+ Iterator iterator = uis.iterator();
+ // first UI delegate provides the return value
+ if (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ result = ui.contains(c, x, y);
+ }
+ // return values from auxiliary UI delegates are ignored
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ /* boolean ignored = */ ui.contains(c, x, y);
+ }
+ return result;
+ }
+
+ /**
+ * Calls the {@link ComponentUI#update(Graphics, JComponent)} method for all
+ * the UI delegates managed by this <code>MultiSpinnerUI</code>.
+ *
+ * @param g the graphics device.
+ * @param c the component.
+ */
+ public void update(Graphics g, JComponent c)
+ {
+ Iterator iterator = uis.iterator();
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ ui.update(g, c);
+ }
+ }
+
+ /**
+ * Calls the <code>paint(Graphics, JComponent)</code> method for all the UI
+ * delegates managed by this <code>MultiSpinnerUI</code>.
+ *
+ * @param g the graphics device.
+ * @param c the component.
+ */
+ public void paint(Graphics g, JComponent c)
+ {
+ Iterator iterator = uis.iterator();
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ ui.paint(g, c);
+ }
+ }
+
+ /**
+ * Calls the {@link ComponentUI#getPreferredSize(JComponent)} method for all
+ * the UI delegates managed by this <code>MultiSpinnerUI</code>,
+ * returning the preferred size for the UI delegate from the primary look and
+ * feel.
+ *
+ * @param c the component.
+ *
+ * @return The preferred size returned by the UI delegate from the primary
+ * look and feel.
+ */
+ public Dimension getPreferredSize(JComponent c)
+ {
+ Dimension result = null;
+ Iterator iterator = uis.iterator();
+ // first UI delegate provides the return value
+ if (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ result = ui.getPreferredSize(c);
+ }
+ // return values from auxiliary UI delegates are ignored
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ /* Dimension ignored = */ ui.getPreferredSize(c);
+ }
+ return result;
+ }
+
+ /**
+ * Calls the {@link ComponentUI#getMinimumSize(JComponent)} method for all
+ * the UI delegates managed by this <code>MultiSpinnerUI</code>,
+ * returning the minimum size for the UI delegate from the primary look and
+ * feel.
+ *
+ * @param c the component.
+ *
+ * @return The minimum size returned by the UI delegate from the primary
+ * look and feel.
+ */
+ public Dimension getMinimumSize(JComponent c)
+ {
+ Dimension result = null;
+ Iterator iterator = uis.iterator();
+ // first UI delegate provides the return value
+ if (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ result = ui.getMinimumSize(c);
+ }
+ // return values from auxiliary UI delegates are ignored
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ /* Dimension ignored = */ ui.getMinimumSize(c);
+ }
+ return result;
+ }
+
+ /**
+ * Calls the {@link ComponentUI#getMaximumSize(JComponent)} method for all
+ * the UI delegates managed by this <code>MultiSpinnerUI</code>,
+ * returning the maximum size for the UI delegate from the primary look and
+ * feel.
+ *
+ * @param c the component.
+ *
+ * @return The maximum size returned by the UI delegate from the primary
+ * look and feel.
+ */
+ public Dimension getMaximumSize(JComponent c)
+ {
+ Dimension result = null;
+ Iterator iterator = uis.iterator();
+ // first UI delegate provides the return value
+ if (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ result = ui.getMaximumSize(c);
+ }
+ // return values from auxiliary UI delegates are ignored
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ /* Dimension ignored = */ ui.getMaximumSize(c);
+ }
+ return result;
+ }
+
+ /**
+ * Calls the {@link ComponentUI#getAccessibleChildrenCount(JComponent)} method
+ * for all the UI delegates managed by this <code>MultiSpinnerUI</code>,
+ * returning the count for the UI delegate from the primary look and
+ * feel.
+ *
+ * @param c the component.
+ *
+ * @return The count returned by the UI delegate from the primary
+ * look and feel.
+ */
+ public int getAccessibleChildrenCount(JComponent c)
+ {
+ int result = 0;
+ Iterator iterator = uis.iterator();
+ // first UI delegate provides the return value
+ if (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ result = ui.getAccessibleChildrenCount(c);
+ }
+ // return values from auxiliary UI delegates are ignored
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ /* int ignored = */ ui.getAccessibleChildrenCount(c);
+ }
+ return result;
+ }
+
+ /**
+ * Calls the {@link ComponentUI#getAccessibleChild(JComponent, int)} method
+ * for all the UI delegates managed by this <code>MultiSpinnerUI</code>,
+ * returning the child for the UI delegate from the primary look and
+ * feel.
+ *
+ * @param c the component
+ * @param i the child index.
+ *
+ * @return The child returned by the UI delegate from the primary
+ * look and feel.
+ */
+ public Accessible getAccessibleChild(JComponent c, int i)
+ {
+ Accessible result = null;
+ Iterator iterator = uis.iterator();
+ // first UI delegate provides the return value
+ if (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ result = ui.getAccessibleChild(c, i);
+ }
+ // return values from auxiliary UI delegates are ignored
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ /* Accessible ignored = */ ui.getAccessibleChild(c, i);
+ }
+ return result;
+ }
+
+}
--- /dev/null
+/* MultiSplitPaneUI.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., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 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 javax.swing.plaf.multi;
+
+import java.awt.Dimension;
+import java.awt.Graphics;
+import java.util.Iterator;
+import java.util.Vector;
+
+import javax.accessibility.Accessible;
+import javax.swing.JComponent;
+import javax.swing.JSplitPane;
+import javax.swing.LookAndFeel;
+import javax.swing.UIManager;
+import javax.swing.plaf.ComponentUI;
+import javax.swing.plaf.SplitPaneUI;
+
+/**
+ * A UI delegate that that coordinates multiple {@link SplitPaneUI}
+ * instances, one from the primary look and feel, and one or more from the
+ * auxiliary look and feel(s).
+ *
+ * @see UIManager#addAuxiliaryLookAndFeel(LookAndFeel)
+ */
+public class MultiSplitPaneUI extends SplitPaneUI
+{
+
+ /** A list of references to the actual component UIs. */
+ protected Vector uis;
+
+ /**
+ * Creates a new <code>MultiSplitPaneUI</code> instance.
+ *
+ * @see #createUI(JComponent)
+ */
+ public MultiSplitPaneUI()
+ {
+ uis = new Vector();
+ }
+
+ /**
+ * Creates a delegate object for the specified component. If any auxiliary
+ * look and feels support this component, a <code>MultiSplitPaneUI</code> is
+ * returned, otherwise the UI from the default look and feel is returned.
+ *
+ * @param target the component.
+ *
+ * @see MultiLookAndFeel#createUIs(ComponentUI, Vector, JComponent)
+ */
+ public static ComponentUI createUI(JComponent target)
+ {
+ MultiSplitPaneUI mui = new MultiSplitPaneUI();
+ return MultiLookAndFeel.createUIs(mui, mui.uis, target);
+ }
+
+ /**
+ * Calls the {@link ComponentUI#installUI(JComponent)} method for all
+ * the UI delegates managed by this <code>MultiSplitPaneUI</code>.
+ *
+ * @param c the component.
+ */
+ public void installUI(JComponent c)
+ {
+ Iterator iterator = uis.iterator();
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ ui.installUI(c);
+ }
+ }
+
+ /**
+ * Calls the {@link ComponentUI#uninstallUI(JComponent)} method for all
+ * the UI delegates managed by this <code>MultiSplitPaneUI</code>.
+ *
+ * @param c the component.
+ */
+ public void uninstallUI(JComponent c)
+ {
+ Iterator iterator = uis.iterator();
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ ui.uninstallUI(c);
+ }
+ }
+
+ /**
+ * Returns an array containing the UI delegates managed by this
+ * <code>MultiSplitPaneUI</code>. The first item in the array is always
+ * the UI delegate from the installed default look and feel.
+ *
+ * @return An array of UI delegates.
+ */
+ public ComponentUI[] getUIs()
+ {
+ return MultiLookAndFeel.uisToArray(uis);
+ }
+
+ /**
+ * Calls the {@link ComponentUI#contains(JComponent, int, int)} method for all
+ * the UI delegates managed by this <code>MultiSplitPaneUI</code>,
+ * returning the result for the UI delegate from the primary look and
+ * feel.
+ *
+ * @param c the component.
+ * @param x the x-coordinate.
+ * @param y the y-coordinate.
+ *
+ * @return <code>true</code> if the specified (x, y) coordinate falls within
+ * the bounds of the component as rendered by the UI delegate in the
+ * primary look and feel, and <code>false</code> otherwise.
+ */
+ public boolean contains(JComponent c, int x, int y)
+ {
+ boolean result = false;
+ Iterator iterator = uis.iterator();
+ // first UI delegate provides the return value
+ if (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ result = ui.contains(c, x, y);
+ }
+ // return values from auxiliary UI delegates are ignored
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ /* boolean ignored = */ ui.contains(c, x, y);
+ }
+ return result;
+ }
+
+ /**
+ * Calls the {@link ComponentUI#update(Graphics, JComponent)} method for all
+ * the UI delegates managed by this <code>MultiSplitPaneUI</code>.
+ *
+ * @param g the graphics device.
+ * @param c the component.
+ */
+ public void update(Graphics g, JComponent c)
+ {
+ Iterator iterator = uis.iterator();
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ ui.update(g, c);
+ }
+ }
+
+ /**
+ * Calls the <code>paint(Graphics, JComponent)</code> method for all the UI
+ * delegates managed by this <code>MultiSplitPaneUI</code>.
+ *
+ * @param g the graphics device.
+ * @param c the component.
+ */
+ public void paint(Graphics g, JComponent c)
+ {
+ Iterator iterator = uis.iterator();
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ ui.paint(g, c);
+ }
+ }
+
+ /**
+ * Calls the {@link ComponentUI#getPreferredSize(JComponent)} method for all
+ * the UI delegates managed by this <code>MultiSplitPaneUI</code>,
+ * returning the preferred size for the UI delegate from the primary look and
+ * feel.
+ *
+ * @param c the component.
+ *
+ * @return The preferred size returned by the UI delegate from the primary
+ * look and feel.
+ */
+ public Dimension getPreferredSize(JComponent c)
+ {
+ Dimension result = null;
+ Iterator iterator = uis.iterator();
+ // first UI delegate provides the return value
+ if (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ result = ui.getPreferredSize(c);
+ }
+ // return values from auxiliary UI delegates are ignored
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ /* Dimension ignored = */ ui.getPreferredSize(c);
+ }
+ return result;
+ }
+
+ /**
+ * Calls the {@link ComponentUI#getMinimumSize(JComponent)} method for all
+ * the UI delegates managed by this <code>MultiSplitPaneUI</code>,
+ * returning the minimum size for the UI delegate from the primary look and
+ * feel.
+ *
+ * @param c the component.
+ *
+ * @return The minimum size returned by the UI delegate from the primary
+ * look and feel.
+ */
+ public Dimension getMinimumSize(JComponent c)
+ {
+ Dimension result = null;
+ Iterator iterator = uis.iterator();
+ // first UI delegate provides the return value
+ if (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ result = ui.getMinimumSize(c);
+ }
+ // return values from auxiliary UI delegates are ignored
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ /* Dimension ignored = */ ui.getMinimumSize(c);
+ }
+ return result;
+ }
+
+ /**
+ * Calls the {@link ComponentUI#getMaximumSize(JComponent)} method for all
+ * the UI delegates managed by this <code>MultiSplitPaneUI</code>,
+ * returning the maximum size for the UI delegate from the primary look and
+ * feel.
+ *
+ * @param c the component.
+ *
+ * @return The maximum size returned by the UI delegate from the primary
+ * look and feel.
+ */
+ public Dimension getMaximumSize(JComponent c)
+ {
+ Dimension result = null;
+ Iterator iterator = uis.iterator();
+ // first UI delegate provides the return value
+ if (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ result = ui.getMaximumSize(c);
+ }
+ // return values from auxiliary UI delegates are ignored
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ /* Dimension ignored = */ ui.getMaximumSize(c);
+ }
+ return result;
+ }
+
+ /**
+ * Calls the {@link ComponentUI#getAccessibleChildrenCount(JComponent)} method
+ * for all the UI delegates managed by this <code>MultiSplitPaneUI</code>,
+ * returning the count for the UI delegate from the primary look and
+ * feel.
+ *
+ * @param c the component.
+ *
+ * @return The count returned by the UI delegate from the primary
+ * look and feel.
+ */
+ public int getAccessibleChildrenCount(JComponent c)
+ {
+ int result = 0;
+ Iterator iterator = uis.iterator();
+ // first UI delegate provides the return value
+ if (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ result = ui.getAccessibleChildrenCount(c);
+ }
+ // return values from auxiliary UI delegates are ignored
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ /* int ignored = */ ui.getAccessibleChildrenCount(c);
+ }
+ return result;
+ }
+
+ /**
+ * Calls the {@link ComponentUI#getAccessibleChild(JComponent, int)} method
+ * for all the UI delegates managed by this <code>MultiSplitPaneUI</code>,
+ * returning the child for the UI delegate from the primary look and
+ * feel.
+ *
+ * @param c the component
+ * @param i the child index.
+ *
+ * @return The child returned by the UI delegate from the primary
+ * look and feel.
+ */
+ public Accessible getAccessibleChild(JComponent c, int i)
+ {
+ Accessible result = null;
+ Iterator iterator = uis.iterator();
+ // first UI delegate provides the return value
+ if (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ result = ui.getAccessibleChild(c, i);
+ }
+ // return values from auxiliary UI delegates are ignored
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ /* Accessible ignored = */ ui.getAccessibleChild(c, i);
+ }
+ return result;
+ }
+
+ /**
+ * Calls the {@link SplitPaneUI#resetToPreferredSizes(JSplitPane)} method
+ * for all the UI delegates managed by this <code>MultiSplitPaneUI</code>.
+ *
+ * @param pane the component.
+ */
+ public void resetToPreferredSizes(JSplitPane pane) {
+ Iterator iterator = uis.iterator();
+ while (iterator.hasNext())
+ {
+ SplitPaneUI ui = (SplitPaneUI) iterator.next();
+ ui.resetToPreferredSizes(pane);
+ }
+ }
+
+ /**
+ * Calls the {@link SplitPaneUI#setDividerLocation(JSplitPane, int)} method
+ * for all the UI delegates managed by this <code>MultiSplitPaneUI</code>.
+ *
+ * @param pane the component.
+ * @param location the location.
+ */
+ public void setDividerLocation(JSplitPane pane, int location) {
+ Iterator iterator = uis.iterator();
+ while (iterator.hasNext())
+ {
+ SplitPaneUI ui = (SplitPaneUI) iterator.next();
+ ui.setDividerLocation(pane, location);
+ }
+ }
+
+ /**
+ * Calls the {@link SplitPaneUI#getDividerLocation(JSplitPane)} method for all
+ * the UI delegates managed by this <code>MultiSplitPaneUI</code>,
+ * returning the location for the UI delegate from the primary look and
+ * feel.
+ *
+ * @param pane the component.
+ *
+ * @return The location returned by the UI delegate from the primary
+ * look and feel.
+ */
+ public int getDividerLocation(JSplitPane pane) {
+ int result = 0;
+ Iterator iterator = uis.iterator();
+ // first UI delegate provides the return value
+ if (iterator.hasNext())
+ {
+ SplitPaneUI ui = (SplitPaneUI) iterator.next();
+ result = ui.getDividerLocation(pane);
+ }
+ // return values from auxiliary UI delegates are ignored
+ while (iterator.hasNext())
+ {
+ SplitPaneUI ui = (SplitPaneUI) iterator.next();
+ /* int ignored = */ ui.getDividerLocation(pane);
+ }
+ return result;
+ }
+
+ /**
+ * Calls the {@link SplitPaneUI#getMinimumDividerLocation(JSplitPane)} method
+ * for all the UI delegates managed by this <code>MultiSplitPaneUI</code>,
+ * returning the location for the UI delegate from the primary look and
+ * feel.
+ *
+ * @param pane the component.
+ *
+ * @return The location returned by the UI delegate from the primary
+ * look and feel.
+ */
+ public int getMinimumDividerLocation(JSplitPane pane) {
+ int result = 0;
+ Iterator iterator = uis.iterator();
+ // first UI delegate provides the return value
+ if (iterator.hasNext())
+ {
+ SplitPaneUI ui = (SplitPaneUI) iterator.next();
+ result = ui.getMinimumDividerLocation(pane);
+ }
+ // return values from auxiliary UI delegates are ignored
+ while (iterator.hasNext())
+ {
+ SplitPaneUI ui = (SplitPaneUI) iterator.next();
+ /* int ignored = */ ui.getMinimumDividerLocation(pane);
+ }
+ return result;
+ }
+
+ /**
+ * Calls the {@link SplitPaneUI#getMaximumDividerLocation(JSplitPane)} method
+ * for all the UI delegates managed by this <code>MultiSplitPaneUI</code>,
+ * returning the location for the UI delegate from the primary look and
+ * feel.
+ *
+ * @param pane the component.
+ *
+ * @return The location returned by the UI delegate from the primary
+ * look and feel.
+ */
+ public int getMaximumDividerLocation(JSplitPane pane) {
+ int result = 0;
+ Iterator iterator = uis.iterator();
+ // first UI delegate provides the return value
+ if (iterator.hasNext())
+ {
+ SplitPaneUI ui = (SplitPaneUI) iterator.next();
+ result = ui.getMaximumDividerLocation(pane);
+ }
+ // return values from auxiliary UI delegates are ignored
+ while (iterator.hasNext())
+ {
+ SplitPaneUI ui = (SplitPaneUI) iterator.next();
+ /* int ignored = */ ui.getMaximumDividerLocation(pane);
+ }
+ return result;
+ }
+
+ /**
+ * Calls the {@link SplitPaneUI#finishedPaintingChildren(JSplitPane,
+ * Graphics)} method for all the UI delegates managed by this
+ * <code>MultiSplitPaneUI</code>.
+ *
+ * @param pane the component.
+ * @param g the graphics device.
+ */
+ public void finishedPaintingChildren(JSplitPane pane, Graphics g) {
+ Iterator iterator = uis.iterator();
+ while (iterator.hasNext())
+ {
+ SplitPaneUI ui = (SplitPaneUI) iterator.next();
+ ui.finishedPaintingChildren(pane, g);
+ }
+ }
+
+}
--- /dev/null
+/* MultiTabbedPaneUI.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., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 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 javax.swing.plaf.multi;
+
+import java.awt.Dimension;
+import java.awt.Graphics;
+import java.awt.Rectangle;
+import java.util.Iterator;
+import java.util.Vector;
+
+import javax.accessibility.Accessible;
+import javax.swing.JComponent;
+import javax.swing.JTabbedPane;
+import javax.swing.LookAndFeel;
+import javax.swing.UIManager;
+import javax.swing.plaf.ComponentUI;
+import javax.swing.plaf.TabbedPaneUI;
+
+/**
+ * A UI delegate that that coordinates multiple {@link TabbedPaneUI}
+ * instances, one from the primary look and feel, and one or more from the
+ * auxiliary look and feel(s).
+ *
+ * @see UIManager#addAuxiliaryLookAndFeel(LookAndFeel)
+ */
+public class MultiTabbedPaneUI extends TabbedPaneUI
+{
+
+ /** A list of references to the actual component UIs. */
+ protected Vector uis;
+
+ /**
+ * Creates a new <code>MultiTabbedPaneUI</code> instance.
+ *
+ * @see #createUI(JComponent)
+ */
+ public MultiTabbedPaneUI()
+ {
+ uis = new Vector();
+ }
+
+ /**
+ * Creates a delegate object for the specified component. If any auxiliary
+ * look and feels support this component, a <code>MultiTabbedPaneUI</code> is
+ * returned, otherwise the UI from the default look and feel is returned.
+ *
+ * @param target the component.
+ *
+ * @see MultiLookAndFeel#createUIs(ComponentUI, Vector, JComponent)
+ */
+ public static ComponentUI createUI(JComponent target)
+ {
+ MultiTabbedPaneUI mui = new MultiTabbedPaneUI();
+ return MultiLookAndFeel.createUIs(mui, mui.uis, target);
+ }
+
+ /**
+ * Calls the {@link ComponentUI#installUI(JComponent)} method for all
+ * the UI delegates managed by this <code>MultiTabbedPaneUI</code>.
+ *
+ * @param c the component.
+ */
+ public void installUI(JComponent c)
+ {
+ Iterator iterator = uis.iterator();
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ ui.installUI(c);
+ }
+ }
+
+ /**
+ * Calls the {@link ComponentUI#uninstallUI(JComponent)} method for all
+ * the UI delegates managed by this <code>MultiTabbedPaneUI</code>.
+ *
+ * @param c the component.
+ */
+ public void uninstallUI(JComponent c)
+ {
+ Iterator iterator = uis.iterator();
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ ui.uninstallUI(c);
+ }
+ }
+
+ /**
+ * Returns an array containing the UI delegates managed by this
+ * <code>MultiTabbedPaneUI</code>. The first item in the array is always
+ * the UI delegate from the installed default look and feel.
+ *
+ * @return An array of UI delegates.
+ */
+ public ComponentUI[] getUIs()
+ {
+ return MultiLookAndFeel.uisToArray(uis);
+ }
+
+ /**
+ * Calls the {@link ComponentUI#contains(JComponent, int, int)} method for all
+ * the UI delegates managed by this <code>MultiTabbedPaneUI</code>,
+ * returning the result for the UI delegate from the primary look and
+ * feel.
+ *
+ * @param c the component.
+ * @param x the x-coordinate.
+ * @param y the y-coordinate.
+ *
+ * @return <code>true</code> if the specified (x, y) coordinate falls within
+ * the bounds of the component as rendered by the UI delegate in the
+ * primary look and feel, and <code>false</code> otherwise.
+ */
+ public boolean contains(JComponent c, int x, int y)
+ {
+ boolean result = false;
+ Iterator iterator = uis.iterator();
+ // first UI delegate provides the return value
+ if (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ result = ui.contains(c, x, y);
+ }
+ // return values from auxiliary UI delegates are ignored
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ /* boolean ignored = */ ui.contains(c, x, y);
+ }
+ return result;
+ }
+
+ /**
+ * Calls the {@link ComponentUI#update(Graphics, JComponent)} method for all
+ * the UI delegates managed by this <code>MultiTabbedPaneUI</code>.
+ *
+ * @param g the graphics device.
+ * @param c the component.
+ */
+ public void update(Graphics g, JComponent c)
+ {
+ Iterator iterator = uis.iterator();
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ ui.update(g, c);
+ }
+ }
+
+ /**
+ * Calls the <code>paint(Graphics, JComponent)</code> method for all the UI
+ * delegates managed by this <code>MultiTabbedPaneUI</code>.
+ *
+ * @param g the graphics device.
+ * @param c the component.
+ */
+ public void paint(Graphics g, JComponent c)
+ {
+ Iterator iterator = uis.iterator();
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ ui.paint(g, c);
+ }
+ }
+
+ /**
+ * Calls the {@link ComponentUI#getPreferredSize(JComponent)} method for all
+ * the UI delegates managed by this <code>MultiTabbedPaneUI</code>,
+ * returning the preferred size for the UI delegate from the primary look and
+ * feel.
+ *
+ * @param c the component.
+ *
+ * @return The preferred size returned by the UI delegate from the primary
+ * look and feel.
+ */
+ public Dimension getPreferredSize(JComponent c)
+ {
+ Dimension result = null;
+ Iterator iterator = uis.iterator();
+ // first UI delegate provides the return value
+ if (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ result = ui.getPreferredSize(c);
+ }
+ // return values from auxiliary UI delegates are ignored
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ /* Dimension ignored = */ ui.getPreferredSize(c);
+ }
+ return result;
+ }
+
+ /**
+ * Calls the {@link ComponentUI#getMinimumSize(JComponent)} method for all
+ * the UI delegates managed by this <code>MultiTabbedPaneUI</code>,
+ * returning the minimum size for the UI delegate from the primary look and
+ * feel.
+ *
+ * @param c the component.
+ *
+ * @return The minimum size returned by the UI delegate from the primary
+ * look and feel.
+ */
+ public Dimension getMinimumSize(JComponent c)
+ {
+ Dimension result = null;
+ Iterator iterator = uis.iterator();
+ // first UI delegate provides the return value
+ if (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ result = ui.getMinimumSize(c);
+ }
+ // return values from auxiliary UI delegates are ignored
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ /* Dimension ignored = */ ui.getMinimumSize(c);
+ }
+ return result;
+ }
+
+ /**
+ * Calls the {@link ComponentUI#getMaximumSize(JComponent)} method for all
+ * the UI delegates managed by this <code>MultiTabbedPaneUI</code>,
+ * returning the maximum size for the UI delegate from the primary look and
+ * feel.
+ *
+ * @param c the component.
+ *
+ * @return The maximum size returned by the UI delegate from the primary
+ * look and feel.
+ */
+ public Dimension getMaximumSize(JComponent c)
+ {
+ Dimension result = null;
+ Iterator iterator = uis.iterator();
+ // first UI delegate provides the return value
+ if (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ result = ui.getMaximumSize(c);
+ }
+ // return values from auxiliary UI delegates are ignored
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ /* Dimension ignored = */ ui.getMaximumSize(c);
+ }
+ return result;
+ }
+
+ /**
+ * Calls the {@link ComponentUI#getAccessibleChildrenCount(JComponent)} method
+ * for all the UI delegates managed by this <code>MultiTabbedPaneUI</code>,
+ * returning the count for the UI delegate from the primary look and
+ * feel.
+ *
+ * @param c the component.
+ *
+ * @return The count returned by the UI delegate from the primary
+ * look and feel.
+ */
+ public int getAccessibleChildrenCount(JComponent c)
+ {
+ int result = 0;
+ Iterator iterator = uis.iterator();
+ // first UI delegate provides the return value
+ if (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ result = ui.getAccessibleChildrenCount(c);
+ }
+ // return values from auxiliary UI delegates are ignored
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ /* int ignored = */ ui.getAccessibleChildrenCount(c);
+ }
+ return result;
+ }
+
+ /**
+ * Calls the {@link ComponentUI#getAccessibleChild(JComponent, int)} method
+ * for all the UI delegates managed by this <code>MultiTabbedPaneUI</code>,
+ * returning the child for the UI delegate from the primary look and
+ * feel.
+ *
+ * @param c the component
+ * @param i the child index.
+ *
+ * @return The child returned by the UI delegate from the primary
+ * look and feel.
+ */
+ public Accessible getAccessibleChild(JComponent c, int i)
+ {
+ Accessible result = null;
+ Iterator iterator = uis.iterator();
+ // first UI delegate provides the return value
+ if (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ result = ui.getAccessibleChild(c, i);
+ }
+ // return values from auxiliary UI delegates are ignored
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ /* Accessible ignored = */ ui.getAccessibleChild(c, i);
+ }
+ return result;
+ }
+
+ /**
+ * Calls the {@link TabbedPaneUI#tabForCoordinate(JTabbedPane, int, int)}
+ * method for all the UI delegates managed by this
+ * <code>MultiTabbedPaneUI</code>, returning the tab index for the UI
+ * delegate from the primary look and feel.
+ *
+ * @param pane the tabbed pane.
+ * @param x the x-coordinate.
+ * @param y the y-coordinate.
+ *
+ * @return The tab index returned by the UI delegate from the primary
+ * look and feel.
+ */
+ public int tabForCoordinate(JTabbedPane pane, int x, int y) {
+ int result = 0;
+ Iterator iterator = uis.iterator();
+ // first UI delegate provides the return value
+ if (iterator.hasNext())
+ {
+ TabbedPaneUI ui = (TabbedPaneUI) iterator.next();
+ result = ui.tabForCoordinate(pane, x, y);
+ }
+ // return values from auxiliary UI delegates are ignored
+ while (iterator.hasNext())
+ {
+ TabbedPaneUI ui = (TabbedPaneUI) iterator.next();
+ /* int ignored = */ ui.tabForCoordinate(pane, x, y);
+ }
+ return result;
+ }
+
+ /**
+ * Calls the {@link TabbedPaneUI#getTabBounds(JTabbedPane, int)}
+ * method for all the UI delegates managed by this
+ * <code>MultiTabbedPaneUI</code>, returning the bounds for the UI
+ * delegate from the primary look and feel.
+ *
+ * @param pane the tabbed pane.
+ * @param index the index.
+ *
+ * @return The bounds returned by the UI delegate from the primary
+ * look and feel.
+ */
+ public Rectangle getTabBounds(JTabbedPane pane, int index) {
+ Rectangle result = null;
+ Iterator iterator = uis.iterator();
+ // first UI delegate provides the return value
+ if (iterator.hasNext())
+ {
+ TabbedPaneUI ui = (TabbedPaneUI) iterator.next();
+ result = ui.getTabBounds(pane, index);
+ }
+ // return values from auxiliary UI delegates are ignored
+ while (iterator.hasNext())
+ {
+ TabbedPaneUI ui = (TabbedPaneUI) iterator.next();
+ /* int ignored = */ ui.getTabRunCount(pane);
+ }
+ return result;
+ }
+
+ /**
+ * Calls the {@link TabbedPaneUI#getTabRunCount(JTabbedPane)}
+ * method for all the UI delegates managed by this
+ * <code>MultiTabbedPaneUI</code>, returning the nt for the UI
+ * delegate from the primary look and feel.
+ *
+ * @param pane the tabbed pane.
+ *
+ * @return The count returned by the UI delegate from the primary
+ * look and feel.
+ */
+ public int getTabRunCount(JTabbedPane pane) {
+ int result = 0;
+ Iterator iterator = uis.iterator();
+ // first UI delegate provides the return value
+ if (iterator.hasNext())
+ {
+ TabbedPaneUI ui = (TabbedPaneUI) iterator.next();
+ result = ui.getTabRunCount(pane);
+ }
+ // return values from auxiliary UI delegates are ignored
+ while (iterator.hasNext())
+ {
+ TabbedPaneUI ui = (TabbedPaneUI) iterator.next();
+ /* int ignored = */ ui.getTabRunCount(pane);
+ }
+ return result;
+ }
+
+}
--- /dev/null
+/* MultiTableHeaderUI.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., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 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 javax.swing.plaf.multi;
+
+import java.awt.Dimension;
+import java.awt.Graphics;
+import java.util.Iterator;
+import java.util.Vector;
+
+import javax.accessibility.Accessible;
+import javax.swing.JComponent;
+import javax.swing.LookAndFeel;
+import javax.swing.UIManager;
+import javax.swing.plaf.ComponentUI;
+import javax.swing.plaf.TableHeaderUI;
+
+/**
+ * A UI delegate that that coordinates multiple {@link TableHeaderUI}
+ * instances, one from the primary look and feel, and one or more from the
+ * auxiliary look and feel(s).
+ *
+ * @see UIManager#addAuxiliaryLookAndFeel(LookAndFeel)
+ */
+public class MultiTableHeaderUI extends TableHeaderUI
+{
+
+ /** A list of references to the actual component UIs. */
+ protected Vector uis;
+
+ /**
+ * Creates a new <code>MultiTableHeaderUI</code> instance.
+ *
+ * @see #createUI(JComponent)
+ */
+ public MultiTableHeaderUI()
+ {
+ uis = new Vector();
+ }
+
+ /**
+ * Creates a delegate object for the specified component. If any auxiliary
+ * look and feels support this component, a <code>MultiTableHeaderUI</code> is
+ * returned, otherwise the UI from the default look and feel is returned.
+ *
+ * @param target the component.
+ *
+ * @see MultiLookAndFeel#createUIs(ComponentUI, Vector, JComponent)
+ */
+ public static ComponentUI createUI(JComponent target)
+ {
+ MultiTableHeaderUI mui = new MultiTableHeaderUI();
+ return MultiLookAndFeel.createUIs(mui, mui.uis, target);
+ }
+
+ /**
+ * Calls the {@link ComponentUI#installUI(JComponent)} method for all
+ * the UI delegates managed by this <code>MultiTableHeaderUI</code>.
+ *
+ * @param c the component.
+ */
+ public void installUI(JComponent c)
+ {
+ Iterator iterator = uis.iterator();
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ ui.installUI(c);
+ }
+ }
+
+ /**
+ * Calls the {@link ComponentUI#uninstallUI(JComponent)} method for all
+ * the UI delegates managed by this <code>MultiTableHeaderUI</code>.
+ *
+ * @param c the component.
+ */
+ public void uninstallUI(JComponent c)
+ {
+ Iterator iterator = uis.iterator();
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ ui.uninstallUI(c);
+ }
+ }
+
+ /**
+ * Returns an array containing the UI delegates managed by this
+ * <code>MultiTableHeaderUI</code>. The first item in the array is always
+ * the UI delegate from the installed default look and feel.
+ *
+ * @return An array of UI delegates.
+ */
+ public ComponentUI[] getUIs()
+ {
+ return MultiLookAndFeel.uisToArray(uis);
+ }
+
+ /**
+ * Calls the {@link ComponentUI#contains(JComponent, int, int)} method for all
+ * the UI delegates managed by this <code>MultiTableHeaderUI</code>,
+ * returning the result for the UI delegate from the primary look and
+ * feel.
+ *
+ * @param c the component.
+ * @param x the x-coordinate.
+ * @param y the y-coordinate.
+ *
+ * @return <code>true</code> if the specified (x, y) coordinate falls within
+ * the bounds of the component as rendered by the UI delegate in the
+ * primary look and feel, and <code>false</code> otherwise.
+ */
+ public boolean contains(JComponent c, int x, int y)
+ {
+ boolean result = false;
+ Iterator iterator = uis.iterator();
+ // first UI delegate provides the return value
+ if (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ result = ui.contains(c, x, y);
+ }
+ // return values from auxiliary UI delegates are ignored
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ /* boolean ignored = */ ui.contains(c, x, y);
+ }
+ return result;
+ }
+
+ /**
+ * Calls the {@link ComponentUI#update(Graphics, JComponent)} method for all
+ * the UI delegates managed by this <code>MultiTableHeaderUI</code>.
+ *
+ * @param g the graphics device.
+ * @param c the component.
+ */
+ public void update(Graphics g, JComponent c)
+ {
+ Iterator iterator = uis.iterator();
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ ui.update(g, c);
+ }
+ }
+
+ /**
+ * Calls the <code>paint(Graphics, JComponent)</code> method for all the UI
+ * delegates managed by this <code>MultiTableHeaderUI</code>.
+ *
+ * @param g the graphics device.
+ * @param c the component.
+ */
+ public void paint(Graphics g, JComponent c)
+ {
+ Iterator iterator = uis.iterator();
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ ui.paint(g, c);
+ }
+ }
+
+ /**
+ * Calls the {@link ComponentUI#getPreferredSize(JComponent)} method for all
+ * the UI delegates managed by this <code>MultiTableHeaderUI</code>,
+ * returning the preferred size for the UI delegate from the primary look and
+ * feel.
+ *
+ * @param c the component.
+ *
+ * @return The preferred size returned by the UI delegate from the primary
+ * look and feel.
+ */
+ public Dimension getPreferredSize(JComponent c)
+ {
+ Dimension result = null;
+ Iterator iterator = uis.iterator();
+ // first UI delegate provides the return value
+ if (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ result = ui.getPreferredSize(c);
+ }
+ // return values from auxiliary UI delegates are ignored
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ /* Dimension ignored = */ ui.getPreferredSize(c);
+ }
+ return result;
+ }
+
+ /**
+ * Calls the {@link ComponentUI#getMinimumSize(JComponent)} method for all
+ * the UI delegates managed by this <code>MultiTableHeaderUI</code>,
+ * returning the minimum size for the UI delegate from the primary look and
+ * feel.
+ *
+ * @param c the component.
+ *
+ * @return The minimum size returned by the UI delegate from the primary
+ * look and feel.
+ */
+ public Dimension getMinimumSize(JComponent c)
+ {
+ Dimension result = null;
+ Iterator iterator = uis.iterator();
+ // first UI delegate provides the return value
+ if (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ result = ui.getMinimumSize(c);
+ }
+ // return values from auxiliary UI delegates are ignored
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ /* Dimension ignored = */ ui.getMinimumSize(c);
+ }
+ return result;
+ }
+
+ /**
+ * Calls the {@link ComponentUI#getMaximumSize(JComponent)} method for all
+ * the UI delegates managed by this <code>MultiTableHeaderUI</code>,
+ * returning the maximum size for the UI delegate from the primary look and
+ * feel.
+ *
+ * @param c the component.
+ *
+ * @return The maximum size returned by the UI delegate from the primary
+ * look and feel.
+ */
+ public Dimension getMaximumSize(JComponent c)
+ {
+ Dimension result = null;
+ Iterator iterator = uis.iterator();
+ // first UI delegate provides the return value
+ if (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ result = ui.getMaximumSize(c);
+ }
+ // return values from auxiliary UI delegates are ignored
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ /* Dimension ignored = */ ui.getMaximumSize(c);
+ }
+ return result;
+ }
+
+ /**
+ * Calls the {@link ComponentUI#getAccessibleChildrenCount(JComponent)} method
+ * for all the UI delegates managed by this <code>MultiTableHeaderUI</code>,
+ * returning the count for the UI delegate from the primary look and
+ * feel.
+ *
+ * @param c the component.
+ *
+ * @return The count returned by the UI delegate from the primary
+ * look and feel.
+ */
+ public int getAccessibleChildrenCount(JComponent c)
+ {
+ int result = 0;
+ Iterator iterator = uis.iterator();
+ // first UI delegate provides the return value
+ if (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ result = ui.getAccessibleChildrenCount(c);
+ }
+ // return values from auxiliary UI delegates are ignored
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ /* int ignored = */ ui.getAccessibleChildrenCount(c);
+ }
+ return result;
+ }
+
+ /**
+ * Calls the {@link ComponentUI#getAccessibleChild(JComponent, int)} method
+ * for all the UI delegates managed by this <code>MultiTableHeaderUI</code>,
+ * returning the child for the UI delegate from the primary look and
+ * feel.
+ *
+ * @param c the component
+ * @param i the child index.
+ *
+ * @return The child returned by the UI delegate from the primary
+ * look and feel.
+ */
+ public Accessible getAccessibleChild(JComponent c, int i)
+ {
+ Accessible result = null;
+ Iterator iterator = uis.iterator();
+ // first UI delegate provides the return value
+ if (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ result = ui.getAccessibleChild(c, i);
+ }
+ // return values from auxiliary UI delegates are ignored
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ /* Accessible ignored = */ ui.getAccessibleChild(c, i);
+ }
+ return result;
+ }
+
+}
--- /dev/null
+/* MultiTableUI.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., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 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 javax.swing.plaf.multi;
+
+import java.awt.Dimension;
+import java.awt.Graphics;
+import java.util.Iterator;
+import java.util.Vector;
+
+import javax.accessibility.Accessible;
+import javax.swing.JComponent;
+import javax.swing.LookAndFeel;
+import javax.swing.UIManager;
+import javax.swing.plaf.ComponentUI;
+import javax.swing.plaf.TableUI;
+
+/**
+ * A UI delegate that that coordinates multiple {@link TableUI}
+ * instances, one from the primary look and feel, and one or more from the
+ * auxiliary look and feel(s).
+ *
+ * @see UIManager#addAuxiliaryLookAndFeel(LookAndFeel)
+ */
+public class MultiTableUI extends TableUI
+{
+
+ /** A list of references to the actual component UIs. */
+ protected Vector uis;
+
+ /**
+ * Creates a new <code>MultiTableUI</code> instance.
+ *
+ * @see #createUI(JComponent)
+ */
+ public MultiTableUI()
+ {
+ uis = new Vector();
+ }
+
+ /**
+ * Creates a delegate object for the specified component. If any auxiliary
+ * look and feels support this component, a <code>MultiTableUI</code> is
+ * returned, otherwise the UI from the default look and feel is returned.
+ *
+ * @param target the component.
+ *
+ * @see MultiLookAndFeel#createUIs(ComponentUI, Vector, JComponent)
+ */
+ public static ComponentUI createUI(JComponent target)
+ {
+ MultiTableUI mui = new MultiTableUI();
+ return MultiLookAndFeel.createUIs(mui, mui.uis, target);
+ }
+
+ /**
+ * Calls the {@link ComponentUI#installUI(JComponent)} method for all
+ * the UI delegates managed by this <code>MultiTableUI</code>.
+ *
+ * @param c the component.
+ */
+ public void installUI(JComponent c)
+ {
+ Iterator iterator = uis.iterator();
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ ui.installUI(c);
+ }
+ }
+
+ /**
+ * Calls the {@link ComponentUI#uninstallUI(JComponent)} method for all
+ * the UI delegates managed by this <code>MultiTableUI</code>.
+ *
+ * @param c the component.
+ */
+ public void uninstallUI(JComponent c)
+ {
+ Iterator iterator = uis.iterator();
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ ui.uninstallUI(c);
+ }
+ }
+
+ /**
+ * Returns an array containing the UI delegates managed by this
+ * <code>MultiTableUI</code>. The first item in the array is always
+ * the UI delegate from the installed default look and feel.
+ *
+ * @return An array of UI delegates.
+ */
+ public ComponentUI[] getUIs()
+ {
+ return MultiLookAndFeel.uisToArray(uis);
+ }
+
+ /**
+ * Calls the {@link ComponentUI#contains(JComponent, int, int)} method for all
+ * the UI delegates managed by this <code>MultiTableUI</code>,
+ * returning the result for the UI delegate from the primary look and
+ * feel.
+ *
+ * @param c the component.
+ * @param x the x-coordinate.
+ * @param y the y-coordinate.
+ *
+ * @return <code>true</code> if the specified (x, y) coordinate falls within
+ * the bounds of the component as rendered by the UI delegate in the
+ * primary look and feel, and <code>false</code> otherwise.
+ */
+ public boolean contains(JComponent c, int x, int y)
+ {
+ boolean result = false;
+ Iterator iterator = uis.iterator();
+ // first UI delegate provides the return value
+ if (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ result = ui.contains(c, x, y);
+ }
+ // return values from auxiliary UI delegates are ignored
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ /* boolean ignored = */ ui.contains(c, x, y);
+ }
+ return result;
+ }
+
+ /**
+ * Calls the {@link ComponentUI#update(Graphics, JComponent)} method for all
+ * the UI delegates managed by this <code>MultiTableUI</code>.
+ *
+ * @param g the graphics device.
+ * @param c the component.
+ */
+ public void update(Graphics g, JComponent c)
+ {
+ Iterator iterator = uis.iterator();
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ ui.update(g, c);
+ }
+ }
+
+ /**
+ * Calls the <code>paint(Graphics, JComponent)</code> method for all the UI
+ * delegates managed by this <code>MultiTableUI</code>.
+ *
+ * @param g the graphics device.
+ * @param c the component.
+ */
+ public void paint(Graphics g, JComponent c)
+ {
+ Iterator iterator = uis.iterator();
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ ui.paint(g, c);
+ }
+ }
+
+ /**
+ * Calls the {@link ComponentUI#getPreferredSize(JComponent)} method for all
+ * the UI delegates managed by this <code>MultiTableUI</code>,
+ * returning the preferred size for the UI delegate from the primary look and
+ * feel.
+ *
+ * @param c the component.
+ *
+ * @return The preferred size returned by the UI delegate from the primary
+ * look and feel.
+ */
+ public Dimension getPreferredSize(JComponent c)
+ {
+ Dimension result = null;
+ Iterator iterator = uis.iterator();
+ // first UI delegate provides the return value
+ if (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ result = ui.getPreferredSize(c);
+ }
+ // return values from auxiliary UI delegates are ignored
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ /* Dimension ignored = */ ui.getPreferredSize(c);
+ }
+ return result;
+ }
+
+ /**
+ * Calls the {@link ComponentUI#getMinimumSize(JComponent)} method for all
+ * the UI delegates managed by this <code>MultiTableUI</code>,
+ * returning the minimum size for the UI delegate from the primary look and
+ * feel.
+ *
+ * @param c the component.
+ *
+ * @return The minimum size returned by the UI delegate from the primary
+ * look and feel.
+ */
+ public Dimension getMinimumSize(JComponent c)
+ {
+ Dimension result = null;
+ Iterator iterator = uis.iterator();
+ // first UI delegate provides the return value
+ if (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ result = ui.getMinimumSize(c);
+ }
+ // return values from auxiliary UI delegates are ignored
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ /* Dimension ignored = */ ui.getMinimumSize(c);
+ }
+ return result;
+ }
+
+ /**
+ * Calls the {@link ComponentUI#getMaximumSize(JComponent)} method for all
+ * the UI delegates managed by this <code>MultiTableUI</code>,
+ * returning the maximum size for the UI delegate from the primary look and
+ * feel.
+ *
+ * @param c the component.
+ *
+ * @return The maximum size returned by the UI delegate from the primary
+ * look and feel.
+ */
+ public Dimension getMaximumSize(JComponent c)
+ {
+ Dimension result = null;
+ Iterator iterator = uis.iterator();
+ // first UI delegate provides the return value
+ if (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ result = ui.getMaximumSize(c);
+ }
+ // return values from auxiliary UI delegates are ignored
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ /* Dimension ignored = */ ui.getMaximumSize(c);
+ }
+ return result;
+ }
+
+ /**
+ * Calls the {@link ComponentUI#getAccessibleChildrenCount(JComponent)} method
+ * for all the UI delegates managed by this <code>MultiTableUI</code>,
+ * returning the count for the UI delegate from the primary look and
+ * feel.
+ *
+ * @param c the component.
+ *
+ * @return The count returned by the UI delegate from the primary
+ * look and feel.
+ */
+ public int getAccessibleChildrenCount(JComponent c)
+ {
+ int result = 0;
+ Iterator iterator = uis.iterator();
+ // first UI delegate provides the return value
+ if (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ result = ui.getAccessibleChildrenCount(c);
+ }
+ // return values from auxiliary UI delegates are ignored
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ /* int ignored = */ ui.getAccessibleChildrenCount(c);
+ }
+ return result;
+ }
+
+ /**
+ * Calls the {@link ComponentUI#getAccessibleChild(JComponent, int)} method
+ * for all the UI delegates managed by this <code>MultiTableUI</code>,
+ * returning the child for the UI delegate from the primary look and
+ * feel.
+ *
+ * @param c the component
+ * @param i the child index.
+ *
+ * @return The child returned by the UI delegate from the primary
+ * look and feel.
+ */
+ public Accessible getAccessibleChild(JComponent c, int i)
+ {
+ Accessible result = null;
+ Iterator iterator = uis.iterator();
+ // first UI delegate provides the return value
+ if (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ result = ui.getAccessibleChild(c, i);
+ }
+ // return values from auxiliary UI delegates are ignored
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ /* Accessible ignored = */ ui.getAccessibleChild(c, i);
+ }
+ return result;
+ }
+
+}
--- /dev/null
+/* MultiTextUI.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., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 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 javax.swing.plaf.multi;
+
+import java.awt.Dimension;
+import java.awt.Graphics;
+import java.awt.Point;
+import java.awt.Rectangle;
+import java.util.Iterator;
+import java.util.Vector;
+
+import javax.accessibility.Accessible;
+import javax.swing.JComponent;
+import javax.swing.LookAndFeel;
+import javax.swing.UIManager;
+import javax.swing.plaf.ComponentUI;
+import javax.swing.plaf.TextUI;
+import javax.swing.text.BadLocationException;
+import javax.swing.text.EditorKit;
+import javax.swing.text.JTextComponent;
+import javax.swing.text.Position;
+import javax.swing.text.View;
+import javax.swing.text.Position.Bias;
+
+/**
+ * A UI delegate that that coordinates multiple {@link TextUI}
+ * instances, one from the primary look and feel, and one or more from the
+ * auxiliary look and feel(s).
+ *
+ * @see UIManager#addAuxiliaryLookAndFeel(LookAndFeel)
+ */
+public class MultiTextUI extends TextUI
+{
+
+ /** A list of references to the actual component UIs. */
+ protected Vector uis;
+
+ /**
+ * Creates a new <code>MultiTextUI</code> instance.
+ *
+ * @see #createUI(JComponent)
+ */
+ public MultiTextUI()
+ {
+ uis = new Vector();
+ }
+
+ /**
+ * Creates a delegate object for the specified component. If any auxiliary
+ * look and feels support this component, a <code>MultiTextUI</code> is
+ * returned, otherwise the UI from the default look and feel is returned.
+ *
+ * @param target the component.
+ *
+ * @see MultiLookAndFeel#createUIs(ComponentUI, Vector, JComponent)
+ */
+ public static ComponentUI createUI(JComponent target)
+ {
+ MultiTextUI mui = new MultiTextUI();
+ return MultiLookAndFeel.createUIs(mui, mui.uis, target);
+ }
+
+ /**
+ * Calls the {@link ComponentUI#installUI(JComponent)} method for all
+ * the UI delegates managed by this <code>MultiTextUI</code>.
+ *
+ * @param c the component.
+ */
+ public void installUI(JComponent c)
+ {
+ Iterator iterator = uis.iterator();
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ ui.installUI(c);
+ }
+ }
+
+ /**
+ * Calls the {@link ComponentUI#uninstallUI(JComponent)} method for all
+ * the UI delegates managed by this <code>MultiTextUI</code>.
+ *
+ * @param c the component.
+ */
+ public void uninstallUI(JComponent c)
+ {
+ Iterator iterator = uis.iterator();
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ ui.uninstallUI(c);
+ }
+ }
+
+ /**
+ * Returns an array containing the UI delegates managed by this
+ * <code>MultiTextUI</code>. The first item in the array is always
+ * the UI delegate from the installed default look and feel.
+ *
+ * @return An array of UI delegates.
+ */
+ public ComponentUI[] getUIs()
+ {
+ return MultiLookAndFeel.uisToArray(uis);
+ }
+
+ /**
+ * Calls the {@link ComponentUI#contains(JComponent, int, int)} method for all
+ * the UI delegates managed by this <code>MultiTextUI</code>,
+ * returning the result for the UI delegate from the primary look and
+ * feel.
+ *
+ * @param c the component.
+ * @param x the x-coordinate.
+ * @param y the y-coordinate.
+ *
+ * @return <code>true</code> if the specified (x, y) coordinate falls within
+ * the bounds of the component as rendered by the UI delegate in the
+ * primary look and feel, and <code>false</code> otherwise.
+ */
+ public boolean contains(JComponent c, int x, int y)
+ {
+ boolean result = false;
+ Iterator iterator = uis.iterator();
+ // first UI delegate provides the return value
+ if (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ result = ui.contains(c, x, y);
+ }
+ // return values from auxiliary UI delegates are ignored
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ /* boolean ignored = */ ui.contains(c, x, y);
+ }
+ return result;
+ }
+
+ /**
+ * Calls the {@link ComponentUI#update(Graphics, JComponent)} method for all
+ * the UI delegates managed by this <code>MultiTextUI</code>.
+ *
+ * @param g the graphics device.
+ * @param c the component.
+ */
+ public void update(Graphics g, JComponent c)
+ {
+ Iterator iterator = uis.iterator();
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ ui.update(g, c);
+ }
+ }
+
+ /**
+ * Calls the <code>paint(Graphics, JComponent)</code> method for all the UI
+ * delegates managed by this <code>MultiTextUI</code>.
+ *
+ * @param g the graphics device.
+ * @param c the component.
+ */
+ public void paint(Graphics g, JComponent c)
+ {
+ Iterator iterator = uis.iterator();
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ ui.paint(g, c);
+ }
+ }
+
+ /**
+ * Calls the {@link ComponentUI#getPreferredSize(JComponent)} method for all
+ * the UI delegates managed by this <code>MultiTextUI</code>,
+ * returning the preferred size for the UI delegate from the primary look and
+ * feel.
+ *
+ * @param c the component.
+ *
+ * @return The preferred size returned by the UI delegate from the primary
+ * look and feel.
+ */
+ public Dimension getPreferredSize(JComponent c)
+ {
+ Dimension result = null;
+ Iterator iterator = uis.iterator();
+ // first UI delegate provides the return value
+ if (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ result = ui.getPreferredSize(c);
+ }
+ // return values from auxiliary UI delegates are ignored
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ /* Dimension ignored = */ ui.getPreferredSize(c);
+ }
+ return result;
+ }
+
+ /**
+ * Calls the {@link ComponentUI#getMinimumSize(JComponent)} method for all
+ * the UI delegates managed by this <code>MultiTextUI</code>,
+ * returning the minimum size for the UI delegate from the primary look and
+ * feel.
+ *
+ * @param c the component.
+ *
+ * @return The minimum size returned by the UI delegate from the primary
+ * look and feel.
+ */
+ public Dimension getMinimumSize(JComponent c)
+ {
+ Dimension result = null;
+ Iterator iterator = uis.iterator();
+ // first UI delegate provides the return value
+ if (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ result = ui.getMinimumSize(c);
+ }
+ // return values from auxiliary UI delegates are ignored
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ /* Dimension ignored = */ ui.getMinimumSize(c);
+ }
+ return result;
+ }
+
+ /**
+ * Calls the {@link ComponentUI#getMaximumSize(JComponent)} method for all
+ * the UI delegates managed by this <code>MultiTextUI</code>,
+ * returning the maximum size for the UI delegate from the primary look and
+ * feel.
+ *
+ * @param c the component.
+ *
+ * @return The maximum size returned by the UI delegate from the primary
+ * look and feel.
+ */
+ public Dimension getMaximumSize(JComponent c)
+ {
+ Dimension result = null;
+ Iterator iterator = uis.iterator();
+ // first UI delegate provides the return value
+ if (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ result = ui.getMaximumSize(c);
+ }
+ // return values from auxiliary UI delegates are ignored
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ /* Dimension ignored = */ ui.getMaximumSize(c);
+ }
+ return result;
+ }
+
+ /**
+ * Calls the {@link ComponentUI#getAccessibleChildrenCount(JComponent)} method
+ * for all the UI delegates managed by this <code>MultiTextUI</code>,
+ * returning the count for the UI delegate from the primary look and
+ * feel.
+ *
+ * @param c the component.
+ *
+ * @return The count returned by the UI delegate from the primary
+ * look and feel.
+ */
+ public int getAccessibleChildrenCount(JComponent c)
+ {
+ int result = 0;
+ Iterator iterator = uis.iterator();
+ // first UI delegate provides the return value
+ if (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ result = ui.getAccessibleChildrenCount(c);
+ }
+ // return values from auxiliary UI delegates are ignored
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ /* int ignored = */ ui.getAccessibleChildrenCount(c);
+ }
+ return result;
+ }
+
+ /**
+ * Calls the {@link ComponentUI#getAccessibleChild(JComponent, int)} method
+ * for all the UI delegates managed by this <code>MultiTextUI</code>,
+ * returning the child for the UI delegate from the primary look and
+ * feel.
+ *
+ * @param c the component
+ * @param i the child index.
+ *
+ * @return The child returned by the UI delegate from the primary
+ * look and feel.
+ */
+ public Accessible getAccessibleChild(JComponent c, int i)
+ {
+ Accessible result = null;
+ Iterator iterator = uis.iterator();
+ // first UI delegate provides the return value
+ if (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ result = ui.getAccessibleChild(c, i);
+ }
+ // return values from auxiliary UI delegates are ignored
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ /* Accessible ignored = */ ui.getAccessibleChild(c, i);
+ }
+ return result;
+ }
+
+ /**
+ * Calls the {@link TextUI#modelToView(JTextComponent, int)} method for all
+ * the UI delegates managed by this <code>MultiTextUI</code>,
+ * returning the bounds for the UI delegate from the primary look and
+ * feel.
+ *
+ * @param tc the text component.
+ *
+ * @return The bounds returned by the UI delegate from the primary
+ * look and feel.
+ */
+ public Rectangle modelToView(JTextComponent tc, int pos)
+ throws BadLocationException
+ {
+ Rectangle result = null;
+ Iterator iterator = uis.iterator();
+ // first UI delegate provides the return value
+ if (iterator.hasNext())
+ {
+ TextUI ui = (TextUI) iterator.next();
+ result = ui.modelToView(tc, pos);
+ }
+ // return values from auxiliary UI delegates are ignored
+ while (iterator.hasNext())
+ {
+ TextUI ui = (TextUI) iterator.next();
+ /* Rectangle ignored = */ ui.modelToView(tc, pos);
+ }
+ return result;
+ }
+
+ /**
+ * Calls the {@link TextUI#modelToView(JTextComponent, int, Position.Bias)}
+ * method for all the UI delegates managed by this <code>MultiTextUI</code>,
+ * returning the bounds for the UI delegate from the primary look and
+ * feel.
+ *
+ * @param tc the text component.
+ *
+ * @return The bounds returned by the UI delegate from the primary
+ * look and feel.
+ */
+ public Rectangle modelToView(JTextComponent tc, int pos, Bias bias)
+ throws BadLocationException
+ {
+ Rectangle result = null;
+ Iterator iterator = uis.iterator();
+ // first UI delegate provides the return value
+ if (iterator.hasNext())
+ {
+ TextUI ui = (TextUI) iterator.next();
+ result = ui.modelToView(tc, pos, bias);
+ }
+ // return values from auxiliary UI delegates are ignored
+ while (iterator.hasNext())
+ {
+ TextUI ui = (TextUI) iterator.next();
+ /* Rectangle ignored = */ ui.modelToView(tc, pos, bias);
+ }
+ return result;
+ }
+
+ /**
+ * Calls the {@link TextUI#viewToModel(JTextComponent, Point)} method for all
+ * the UI delegates managed by this <code>MultiTextUI</code>,
+ * returning the position for the UI delegate from the primary look and
+ * feel.
+ *
+ * @param t the text component.
+ * @param pt the point.
+ *
+ * @return The position returned by the UI delegate from the primary
+ * look and feel.
+ */
+ public int viewToModel(JTextComponent t, Point pt)
+ {
+ int result = 0;
+ Iterator iterator = uis.iterator();
+ // first UI delegate provides the return value
+ if (iterator.hasNext())
+ {
+ TextUI ui = (TextUI) iterator.next();
+ result = ui.viewToModel(t, pt);
+ }
+ // return values from auxiliary UI delegates are ignored
+ while (iterator.hasNext())
+ {
+ TextUI ui = (TextUI) iterator.next();
+ /* int ignored = */ ui.viewToModel(t, pt);
+ }
+ return result;
+ }
+
+ /**
+ * Calls the {@link TextUI#viewToModel(JTextComponent, Point, Bias[])} method
+ * for all the UI delegates managed by this <code>MultiTextUI</code>,
+ * returning the position for the UI delegate from the primary look and
+ * feel.
+ *
+ * @param tc the text component.
+ *
+ * @return The position returned by the UI delegate from the primary
+ * look and feel.
+ */
+ public int viewToModel(JTextComponent tc, Point loc, Bias[] outBias)
+ {
+ int result = 0;
+ Iterator iterator = uis.iterator();
+ // first UI delegate provides the return value
+ if (iterator.hasNext())
+ {
+ TextUI ui = (TextUI) iterator.next();
+ result = ui.viewToModel(tc, loc, outBias);
+ }
+ // return values from auxiliary UI delegates are ignored
+ while (iterator.hasNext())
+ {
+ TextUI ui = (TextUI) iterator.next();
+ /* int ignored = */ ui.viewToModel(tc, loc, outBias);
+ }
+ return result;
+ }
+
+ /**
+ * Calls the {@link TextUI#getNextVisualPositionFrom(JTextComponent, int,
+ * Position.Bias, int, Position.Bias[])} method for all
+ * the UI delegates managed by this <code>MultiTextUI</code>,
+ * returning the position for the UI delegate from the primary look and
+ * feel.
+ *
+ * @param tc the text component.
+ *
+ * @return The position returned by the UI delegate from the primary
+ * look and feel.
+ */
+ public int getNextVisualPositionFrom(JTextComponent tc, int pos, Bias bias,
+ int direction, Bias[] outBias) throws BadLocationException
+ {
+ int result = 0;
+ Iterator iterator = uis.iterator();
+ // first UI delegate provides the return value
+ if (iterator.hasNext())
+ {
+ TextUI ui = (TextUI) iterator.next();
+ result = ui.getNextVisualPositionFrom(tc, pos, bias, direction,
+ outBias);
+ }
+ // return values from auxiliary UI delegates are ignored
+ while (iterator.hasNext())
+ {
+ TextUI ui = (TextUI) iterator.next();
+ /* int ignored = */ ui.getNextVisualPositionFrom(tc, pos, bias,
+ direction, outBias);
+ }
+ return result;
+ }
+
+ /**
+ * Calls the {@link TextUI#damageRange(JTextComponent, int, int)} method for
+ * all the UI delegates managed by this <code>MultiTextUI</code>.
+ *
+ * @param tc the component.
+ * @param start the start position.
+ * @param end the end position.
+ */
+ public void damageRange(JTextComponent tc, int start, int end)
+ {
+ Iterator iterator = uis.iterator();
+ while (iterator.hasNext())
+ {
+ TextUI ui = (TextUI) iterator.next();
+ ui.damageRange(tc, start, end);
+ }
+ }
+
+ /**
+ * Calls the {@link TextUI#damageRange(JTextComponent, int, int,
+ * Position.Bias, Position.Bias)} method for all the UI delegates managed by
+ * this <code>MultiTextUI</code>.
+ *
+ * @param tc the component.
+ * @param start the start position.
+ * @param end the end position.
+ * @param startBias the start bias.
+ * @param endBias the end bias.
+ */
+ public void damageRange(JTextComponent tc, int start, int end,
+ Bias startBias, Bias endBias)
+ {
+ Iterator iterator = uis.iterator();
+ while (iterator.hasNext())
+ {
+ TextUI ui = (TextUI) iterator.next();
+ ui.damageRange(tc, start, end, startBias, endBias);
+ }
+ }
+
+ /**
+ * Calls the {@link TextUI#getEditorKit(JTextComponent)} method for all
+ * the UI delegates managed by this <code>MultiTextUI</code>,
+ * returning the editor kit for the UI delegate from the primary look and
+ * feel.
+ *
+ * @param tc the text component.
+ *
+ * @return The editor kit returned by the UI delegate from the primary
+ * look and feel.
+ */
+ public EditorKit getEditorKit(JTextComponent tc)
+ {
+ EditorKit result = null;
+ Iterator iterator = uis.iterator();
+ // first UI delegate provides the return value
+ if (iterator.hasNext())
+ {
+ TextUI ui = (TextUI) iterator.next();
+ result = ui.getEditorKit(tc);
+ }
+ // return values from auxiliary UI delegates are ignored
+ while (iterator.hasNext())
+ {
+ TextUI ui = (TextUI) iterator.next();
+ /* EditorKit ignored = */ ui.getEditorKit(tc);
+ }
+ return result;
+ }
+
+ /**
+ * Calls the {@link TextUI#getRootView(JTextComponent)} method for all
+ * the UI delegates managed by this <code>MultiTextUI</code>,
+ * returning the view for the UI delegate from the primary look and
+ * feel.
+ *
+ * @param tc the text component.
+ *
+ * @return The view returned by the UI delegate from the primary
+ * look and feel.
+ */
+ public View getRootView(JTextComponent tc)
+ {
+ View result = null;
+ Iterator iterator = uis.iterator();
+ // first UI delegate provides the return value
+ if (iterator.hasNext())
+ {
+ TextUI ui = (TextUI) iterator.next();
+ result = ui.getRootView(tc);
+ }
+ // return values from auxiliary UI delegates are ignored
+ while (iterator.hasNext())
+ {
+ TextUI ui = (TextUI) iterator.next();
+ /* View ignored = */ ui.getRootView(tc);
+ }
+ return result;
+ }
+
+}
--- /dev/null
+/* MultiToolBarUI.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., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 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 javax.swing.plaf.multi;
+
+import java.awt.Dimension;
+import java.awt.Graphics;
+import java.util.Iterator;
+import java.util.Vector;
+
+import javax.accessibility.Accessible;
+import javax.swing.JComponent;
+import javax.swing.LookAndFeel;
+import javax.swing.UIManager;
+import javax.swing.plaf.ComponentUI;
+import javax.swing.plaf.ToolBarUI;
+
+/**
+ * A UI delegate that that coordinates multiple {@link ToolBarUI}
+ * instances, one from the primary look and feel, and one or more from the
+ * auxiliary look and feel(s).
+ *
+ * @see UIManager#addAuxiliaryLookAndFeel(LookAndFeel)
+ */
+public class MultiToolBarUI extends ToolBarUI
+{
+
+ /** A list of references to the actual component UIs. */
+ protected Vector uis;
+
+ /**
+ * Creates a new <code>MultiToolBarUI</code> instance.
+ *
+ * @see #createUI(JComponent)
+ */
+ public MultiToolBarUI()
+ {
+ uis = new Vector();
+ }
+
+ /**
+ * Creates a delegate object for the specified component. If any auxiliary
+ * look and feels support this component, a <code>MultiToolBarUI</code> is
+ * returned, otherwise the UI from the default look and feel is returned.
+ *
+ * @param target the component.
+ *
+ * @see MultiLookAndFeel#createUIs(ComponentUI, Vector, JComponent)
+ */
+ public static ComponentUI createUI(JComponent target)
+ {
+ MultiToolBarUI mui = new MultiToolBarUI();
+ return MultiLookAndFeel.createUIs(mui, mui.uis, target);
+ }
+
+ /**
+ * Calls the {@link ComponentUI#installUI(JComponent)} method for all
+ * the UI delegates managed by this <code>MultiToolBarUI</code>.
+ *
+ * @param c the component.
+ */
+ public void installUI(JComponent c)
+ {
+ Iterator iterator = uis.iterator();
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ ui.installUI(c);
+ }
+ }
+
+ /**
+ * Calls the {@link ComponentUI#uninstallUI(JComponent)} method for all
+ * the UI delegates managed by this <code>MultiToolBarUI</code>.
+ *
+ * @param c the component.
+ */
+ public void uninstallUI(JComponent c)
+ {
+ Iterator iterator = uis.iterator();
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ ui.uninstallUI(c);
+ }
+ }
+
+ /**
+ * Returns an array containing the UI delegates managed by this
+ * <code>MultiToolBarUI</code>. The first item in the array is always
+ * the UI delegate from the installed default look and feel.
+ *
+ * @return An array of UI delegates.
+ */
+ public ComponentUI[] getUIs()
+ {
+ return MultiLookAndFeel.uisToArray(uis);
+ }
+
+ /**
+ * Calls the {@link ComponentUI#contains(JComponent, int, int)} method for all
+ * the UI delegates managed by this <code>MultiToolBarUI</code>,
+ * returning the result for the UI delegate from the primary look and
+ * feel.
+ *
+ * @param c the component.
+ * @param x the x-coordinate.
+ * @param y the y-coordinate.
+ *
+ * @return <code>true</code> if the specified (x, y) coordinate falls within
+ * the bounds of the component as rendered by the UI delegate in the
+ * primary look and feel, and <code>false</code> otherwise.
+ */
+ public boolean contains(JComponent c, int x, int y)
+ {
+ boolean result = false;
+ Iterator iterator = uis.iterator();
+ // first UI delegate provides the return value
+ if (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ result = ui.contains(c, x, y);
+ }
+ // return values from auxiliary UI delegates are ignored
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ /* boolean ignored = */ ui.contains(c, x, y);
+ }
+ return result;
+ }
+
+ /**
+ * Calls the {@link ComponentUI#update(Graphics, JComponent)} method for all
+ * the UI delegates managed by this <code>MultiToolBarUI</code>.
+ *
+ * @param g the graphics device.
+ * @param c the component.
+ */
+ public void update(Graphics g, JComponent c)
+ {
+ Iterator iterator = uis.iterator();
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ ui.update(g, c);
+ }
+ }
+
+ /**
+ * Calls the <code>paint(Graphics, JComponent)</code> method for all the UI
+ * delegates managed by this <code>MultiToolBarUI</code>.
+ *
+ * @param g the graphics device.
+ * @param c the component.
+ */
+ public void paint(Graphics g, JComponent c)
+ {
+ Iterator iterator = uis.iterator();
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ ui.paint(g, c);
+ }
+ }
+
+ /**
+ * Calls the {@link ComponentUI#getPreferredSize(JComponent)} method for all
+ * the UI delegates managed by this <code>MultiToolBarUI</code>,
+ * returning the preferred size for the UI delegate from the primary look and
+ * feel.
+ *
+ * @param c the component.
+ *
+ * @return The preferred size returned by the UI delegate from the primary
+ * look and feel.
+ */
+ public Dimension getPreferredSize(JComponent c)
+ {
+ Dimension result = null;
+ Iterator iterator = uis.iterator();
+ // first UI delegate provides the return value
+ if (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ result = ui.getPreferredSize(c);
+ }
+ // return values from auxiliary UI delegates are ignored
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ /* Dimension ignored = */ ui.getPreferredSize(c);
+ }
+ return result;
+ }
+
+ /**
+ * Calls the {@link ComponentUI#getMinimumSize(JComponent)} method for all
+ * the UI delegates managed by this <code>MultiToolBarUI</code>,
+ * returning the minimum size for the UI delegate from the primary look and
+ * feel.
+ *
+ * @param c the component.
+ *
+ * @return The minimum size returned by the UI delegate from the primary
+ * look and feel.
+ */
+ public Dimension getMinimumSize(JComponent c)
+ {
+ Dimension result = null;
+ Iterator iterator = uis.iterator();
+ // first UI delegate provides the return value
+ if (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ result = ui.getMinimumSize(c);
+ }
+ // return values from auxiliary UI delegates are ignored
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ /* Dimension ignored = */ ui.getMinimumSize(c);
+ }
+ return result;
+ }
+
+ /**
+ * Calls the {@link ComponentUI#getMaximumSize(JComponent)} method for all
+ * the UI delegates managed by this <code>MultiToolBarUI</code>,
+ * returning the maximum size for the UI delegate from the primary look and
+ * feel.
+ *
+ * @param c the component.
+ *
+ * @return The maximum size returned by the UI delegate from the primary
+ * look and feel.
+ */
+ public Dimension getMaximumSize(JComponent c)
+ {
+ Dimension result = null;
+ Iterator iterator = uis.iterator();
+ // first UI delegate provides the return value
+ if (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ result = ui.getMaximumSize(c);
+ }
+ // return values from auxiliary UI delegates are ignored
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ /* Dimension ignored = */ ui.getMaximumSize(c);
+ }
+ return result;
+ }
+
+ /**
+ * Calls the {@link ComponentUI#getAccessibleChildrenCount(JComponent)} method
+ * for all the UI delegates managed by this <code>MultiToolBarUI</code>,
+ * returning the count for the UI delegate from the primary look and
+ * feel.
+ *
+ * @param c the component.
+ *
+ * @return The count returned by the UI delegate from the primary
+ * look and feel.
+ */
+ public int getAccessibleChildrenCount(JComponent c)
+ {
+ int result = 0;
+ Iterator iterator = uis.iterator();
+ // first UI delegate provides the return value
+ if (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ result = ui.getAccessibleChildrenCount(c);
+ }
+ // return values from auxiliary UI delegates are ignored
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ /* int ignored = */ ui.getAccessibleChildrenCount(c);
+ }
+ return result;
+ }
+
+ /**
+ * Calls the {@link ComponentUI#getAccessibleChild(JComponent, int)} method
+ * for all the UI delegates managed by this <code>MultiToolBarUI</code>,
+ * returning the child for the UI delegate from the primary look and
+ * feel.
+ *
+ * @param c the component
+ * @param i the child index.
+ *
+ * @return The child returned by the UI delegate from the primary
+ * look and feel.
+ */
+ public Accessible getAccessibleChild(JComponent c, int i)
+ {
+ Accessible result = null;
+ Iterator iterator = uis.iterator();
+ // first UI delegate provides the return value
+ if (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ result = ui.getAccessibleChild(c, i);
+ }
+ // return values from auxiliary UI delegates are ignored
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ /* Accessible ignored = */ ui.getAccessibleChild(c, i);
+ }
+ return result;
+ }
+
+}
--- /dev/null
+/* MultiToolTipUI.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., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 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 javax.swing.plaf.multi;
+
+import java.awt.Dimension;
+import java.awt.Graphics;
+import java.util.Iterator;
+import java.util.Vector;
+
+import javax.accessibility.Accessible;
+import javax.swing.JComponent;
+import javax.swing.LookAndFeel;
+import javax.swing.UIManager;
+import javax.swing.plaf.ComponentUI;
+import javax.swing.plaf.ToolTipUI;
+
+/**
+ * A UI delegate that that coordinates multiple {@link ToolTipUI}
+ * instances, one from the primary look and feel, and one or more from the
+ * auxiliary look and feel(s).
+ *
+ * @see UIManager#addAuxiliaryLookAndFeel(LookAndFeel)
+ */
+public class MultiToolTipUI extends ToolTipUI
+{
+
+ /** A list of references to the actual component UIs. */
+ protected Vector uis;
+
+ /**
+ * Creates a new <code>MultiToolTipUI</code> instance.
+ *
+ * @see #createUI(JComponent)
+ */
+ public MultiToolTipUI()
+ {
+ uis = new Vector();
+ }
+
+ /**
+ * Creates a delegate object for the specified component. If any auxiliary
+ * look and feels support this component, a <code>MultiToolTipUI</code> is
+ * returned, otherwise the UI from the default look and feel is returned.
+ *
+ * @param target the component.
+ *
+ * @see MultiLookAndFeel#createUIs(ComponentUI, Vector, JComponent)
+ */
+ public static ComponentUI createUI(JComponent target)
+ {
+ MultiToolTipUI mui = new MultiToolTipUI();
+ return MultiLookAndFeel.createUIs(mui, mui.uis, target);
+ }
+
+ /**
+ * Calls the {@link ComponentUI#installUI(JComponent)} method for all
+ * the UI delegates managed by this <code>MultiToolTipUI</code>.
+ *
+ * @param c the component.
+ */
+ public void installUI(JComponent c)
+ {
+ Iterator iterator = uis.iterator();
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ ui.installUI(c);
+ }
+ }
+
+ /**
+ * Calls the {@link ComponentUI#uninstallUI(JComponent)} method for all
+ * the UI delegates managed by this <code>MultiToolTipUI</code>.
+ *
+ * @param c the component.
+ */
+ public void uninstallUI(JComponent c)
+ {
+ Iterator iterator = uis.iterator();
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ ui.uninstallUI(c);
+ }
+ }
+
+ /**
+ * Returns an array containing the UI delegates managed by this
+ * <code>MultiToolTipUI</code>. The first item in the array is always
+ * the UI delegate from the installed default look and feel.
+ *
+ * @return An array of UI delegates.
+ */
+ public ComponentUI[] getUIs()
+ {
+ return MultiLookAndFeel.uisToArray(uis);
+ }
+
+ /**
+ * Calls the {@link ComponentUI#contains(JComponent, int, int)} method for all
+ * the UI delegates managed by this <code>MultiToolTipUI</code>,
+ * returning the result for the UI delegate from the primary look and
+ * feel.
+ *
+ * @param c the component.
+ * @param x the x-coordinate.
+ * @param y the y-coordinate.
+ *
+ * @return <code>true</code> if the specified (x, y) coordinate falls within
+ * the bounds of the component as rendered by the UI delegate in the
+ * primary look and feel, and <code>false</code> otherwise.
+ */
+ public boolean contains(JComponent c, int x, int y)
+ {
+ boolean result = false;
+ Iterator iterator = uis.iterator();
+ // first UI delegate provides the return value
+ if (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ result = ui.contains(c, x, y);
+ }
+ // return values from auxiliary UI delegates are ignored
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ /* boolean ignored = */ ui.contains(c, x, y);
+ }
+ return result;
+ }
+
+ /**
+ * Calls the {@link ComponentUI#update(Graphics, JComponent)} method for all
+ * the UI delegates managed by this <code>MultiToolTipUI</code>.
+ *
+ * @param g the graphics device.
+ * @param c the component.
+ */
+ public void update(Graphics g, JComponent c)
+ {
+ Iterator iterator = uis.iterator();
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ ui.update(g, c);
+ }
+ }
+
+ /**
+ * Calls the <code>paint(Graphics, JComponent)</code> method for all the UI
+ * delegates managed by this <code>MultiToolTipUI</code>.
+ *
+ * @param g the graphics device.
+ * @param c the component.
+ */
+ public void paint(Graphics g, JComponent c)
+ {
+ Iterator iterator = uis.iterator();
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ ui.paint(g, c);
+ }
+ }
+
+ /**
+ * Calls the {@link ComponentUI#getPreferredSize(JComponent)} method for all
+ * the UI delegates managed by this <code>MultiToolTipUI</code>,
+ * returning the preferred size for the UI delegate from the primary look and
+ * feel.
+ *
+ * @param c the component.
+ *
+ * @return The preferred size returned by the UI delegate from the primary
+ * look and feel.
+ */
+ public Dimension getPreferredSize(JComponent c)
+ {
+ Dimension result = null;
+ Iterator iterator = uis.iterator();
+ // first UI delegate provides the return value
+ if (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ result = ui.getPreferredSize(c);
+ }
+ // return values from auxiliary UI delegates are ignored
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ /* Dimension ignored = */ ui.getPreferredSize(c);
+ }
+ return result;
+ }
+
+ /**
+ * Calls the {@link ComponentUI#getMinimumSize(JComponent)} method for all
+ * the UI delegates managed by this <code>MultiToolTipUI</code>,
+ * returning the minimum size for the UI delegate from the primary look and
+ * feel.
+ *
+ * @param c the component.
+ *
+ * @return The minimum size returned by the UI delegate from the primary
+ * look and feel.
+ */
+ public Dimension getMinimumSize(JComponent c)
+ {
+ Dimension result = null;
+ Iterator iterator = uis.iterator();
+ // first UI delegate provides the return value
+ if (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ result = ui.getMinimumSize(c);
+ }
+ // return values from auxiliary UI delegates are ignored
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ /* Dimension ignored = */ ui.getMinimumSize(c);
+ }
+ return result;
+ }
+
+ /**
+ * Calls the {@link ComponentUI#getMaximumSize(JComponent)} method for all
+ * the UI delegates managed by this <code>MultiToolTipUI</code>,
+ * returning the maximum size for the UI delegate from the primary look and
+ * feel.
+ *
+ * @param c the component.
+ *
+ * @return The maximum size returned by the UI delegate from the primary
+ * look and feel.
+ */
+ public Dimension getMaximumSize(JComponent c)
+ {
+ Dimension result = null;
+ Iterator iterator = uis.iterator();
+ // first UI delegate provides the return value
+ if (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ result = ui.getMaximumSize(c);
+ }
+ // return values from auxiliary UI delegates are ignored
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ /* Dimension ignored = */ ui.getMaximumSize(c);
+ }
+ return result;
+ }
+
+ /**
+ * Calls the {@link ComponentUI#getAccessibleChildrenCount(JComponent)} method
+ * for all the UI delegates managed by this <code>MultiToolTipUI</code>,
+ * returning the count for the UI delegate from the primary look and
+ * feel.
+ *
+ * @param c the component.
+ *
+ * @return The count returned by the UI delegate from the primary
+ * look and feel.
+ */
+ public int getAccessibleChildrenCount(JComponent c)
+ {
+ int result = 0;
+ Iterator iterator = uis.iterator();
+ // first UI delegate provides the return value
+ if (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ result = ui.getAccessibleChildrenCount(c);
+ }
+ // return values from auxiliary UI delegates are ignored
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ /* int ignored = */ ui.getAccessibleChildrenCount(c);
+ }
+ return result;
+ }
+
+ /**
+ * Calls the {@link ComponentUI#getAccessibleChild(JComponent, int)} method
+ * for all the UI delegates managed by this <code>MultiToolTipUI</code>,
+ * returning the child for the UI delegate from the primary look and
+ * feel.
+ *
+ * @param c the component
+ * @param i the child index.
+ *
+ * @return The child returned by the UI delegate from the primary
+ * look and feel.
+ */
+ public Accessible getAccessibleChild(JComponent c, int i)
+ {
+ Accessible result = null;
+ Iterator iterator = uis.iterator();
+ // first UI delegate provides the return value
+ if (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ result = ui.getAccessibleChild(c, i);
+ }
+ // return values from auxiliary UI delegates are ignored
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ /* Accessible ignored = */ ui.getAccessibleChild(c, i);
+ }
+ return result;
+ }
+
+}
--- /dev/null
+/* MultiTreeUI.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., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 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 javax.swing.plaf.multi;
+
+import java.awt.Dimension;
+import java.awt.Graphics;
+import java.awt.Rectangle;
+import java.util.Iterator;
+import java.util.Vector;
+
+import javax.accessibility.Accessible;
+import javax.swing.JComponent;
+import javax.swing.JTree;
+import javax.swing.LookAndFeel;
+import javax.swing.UIManager;
+import javax.swing.plaf.ComponentUI;
+import javax.swing.plaf.TreeUI;
+import javax.swing.tree.TreePath;
+
+/**
+ * A UI delegate that that coordinates multiple {@link TreeUI}
+ * instances, one from the primary look and feel, and one or more from the
+ * auxiliary look and feel(s).
+ *
+ * @see UIManager#addAuxiliaryLookAndFeel(LookAndFeel)
+ */
+public class MultiTreeUI extends TreeUI
+{
+
+ /** A list of references to the actual component UIs. */
+ protected Vector uis;
+
+ /**
+ * Creates a new <code>MultiTreeUI</code> instance.
+ *
+ * @see #createUI(JComponent)
+ */
+ public MultiTreeUI()
+ {
+ uis = new Vector();
+ }
+
+ /**
+ * Creates a delegate object for the specified component. If any auxiliary
+ * look and feels support this component, a <code>MultiTreeUI</code> is
+ * returned, otherwise the UI from the default look and feel is returned.
+ *
+ * @param target the component.
+ *
+ * @see MultiLookAndFeel#createUIs(ComponentUI, Vector, JComponent)
+ */
+ public static ComponentUI createUI(JComponent target)
+ {
+ MultiTreeUI mui = new MultiTreeUI();
+ return MultiLookAndFeel.createUIs(mui, mui.uis, target);
+ }
+
+ /**
+ * Calls the {@link ComponentUI#installUI(JComponent)} method for all
+ * the UI delegates managed by this <code>MultiTreeUI</code>.
+ *
+ * @param c the component.
+ */
+ public void installUI(JComponent c)
+ {
+ Iterator iterator = uis.iterator();
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ ui.installUI(c);
+ }
+ }
+
+ /**
+ * Calls the {@link ComponentUI#uninstallUI(JComponent)} method for all
+ * the UI delegates managed by this <code>MultiTreeUI</code>.
+ *
+ * @param c the component.
+ */
+ public void uninstallUI(JComponent c)
+ {
+ Iterator iterator = uis.iterator();
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ ui.uninstallUI(c);
+ }
+ }
+
+ /**
+ * Returns an array containing the UI delegates managed by this
+ * <code>MultiTreeUI</code>. The first item in the array is always
+ * the UI delegate from the installed default look and feel.
+ *
+ * @return An array of UI delegates.
+ */
+ public ComponentUI[] getUIs()
+ {
+ return MultiLookAndFeel.uisToArray(uis);
+ }
+
+ /**
+ * Calls the {@link ComponentUI#contains(JComponent, int, int)} method for all
+ * the UI delegates managed by this <code>MultiTreeUI</code>,
+ * returning the result for the UI delegate from the primary look and
+ * feel.
+ *
+ * @param c the component.
+ * @param x the x-coordinate.
+ * @param y the y-coordinate.
+ *
+ * @return <code>true</code> if the specified (x, y) coordinate falls within
+ * the bounds of the component as rendered by the UI delegate in the
+ * primary look and feel, and <code>false</code> otherwise.
+ */
+ public boolean contains(JComponent c, int x, int y)
+ {
+ boolean result = false;
+ Iterator iterator = uis.iterator();
+ // first UI delegate provides the return value
+ if (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ result = ui.contains(c, x, y);
+ }
+ // return values from auxiliary UI delegates are ignored
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ /* boolean ignored = */ ui.contains(c, x, y);
+ }
+ return result;
+ }
+
+ /**
+ * Calls the {@link ComponentUI#update(Graphics, JComponent)} method for all
+ * the UI delegates managed by this <code>MultiTreeUI</code>.
+ *
+ * @param g the graphics device.
+ * @param c the component.
+ */
+ public void update(Graphics g, JComponent c)
+ {
+ Iterator iterator = uis.iterator();
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ ui.update(g, c);
+ }
+ }
+
+ /**
+ * Calls the <code>paint(Graphics, JComponent)</code> method for all the UI
+ * delegates managed by this <code>MultiTreeUI</code>.
+ *
+ * @param g the graphics device.
+ * @param c the component.
+ */
+ public void paint(Graphics g, JComponent c)
+ {
+ Iterator iterator = uis.iterator();
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ ui.paint(g, c);
+ }
+ }
+
+ /**
+ * Calls the {@link ComponentUI#getPreferredSize(JComponent)} method for all
+ * the UI delegates managed by this <code>MultiTreeUI</code>,
+ * returning the preferred size for the UI delegate from the primary look and
+ * feel.
+ *
+ * @param c the component.
+ *
+ * @return The preferred size returned by the UI delegate from the primary
+ * look and feel.
+ */
+ public Dimension getPreferredSize(JComponent c)
+ {
+ Dimension result = null;
+ Iterator iterator = uis.iterator();
+ // first UI delegate provides the return value
+ if (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ result = ui.getPreferredSize(c);
+ }
+ // return values from auxiliary UI delegates are ignored
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ /* Dimension ignored = */ ui.getPreferredSize(c);
+ }
+ return result;
+ }
+
+ /**
+ * Calls the {@link ComponentUI#getMinimumSize(JComponent)} method for all
+ * the UI delegates managed by this <code>MultiTreeUI</code>,
+ * returning the minimum size for the UI delegate from the primary look and
+ * feel.
+ *
+ * @param c the component.
+ *
+ * @return The minimum size returned by the UI delegate from the primary
+ * look and feel.
+ */
+ public Dimension getMinimumSize(JComponent c)
+ {
+ Dimension result = null;
+ Iterator iterator = uis.iterator();
+ // first UI delegate provides the return value
+ if (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ result = ui.getMinimumSize(c);
+ }
+ // return values from auxiliary UI delegates are ignored
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ /* Dimension ignored = */ ui.getMinimumSize(c);
+ }
+ return result;
+ }
+
+ /**
+ * Calls the {@link ComponentUI#getMaximumSize(JComponent)} method for all
+ * the UI delegates managed by this <code>MultiTreeUI</code>,
+ * returning the maximum size for the UI delegate from the primary look and
+ * feel.
+ *
+ * @param c the component.
+ *
+ * @return The maximum size returned by the UI delegate from the primary
+ * look and feel.
+ */
+ public Dimension getMaximumSize(JComponent c)
+ {
+ Dimension result = null;
+ Iterator iterator = uis.iterator();
+ // first UI delegate provides the return value
+ if (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ result = ui.getMaximumSize(c);
+ }
+ // return values from auxiliary UI delegates are ignored
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ /* Dimension ignored = */ ui.getMaximumSize(c);
+ }
+ return result;
+ }
+
+ /**
+ * Calls the {@link ComponentUI#getAccessibleChildrenCount(JComponent)} method
+ * for all the UI delegates managed by this <code>MultiTreeUI</code>,
+ * returning the count for the UI delegate from the primary look and
+ * feel.
+ *
+ * @param c the component.
+ *
+ * @return The count returned by the UI delegate from the primary
+ * look and feel.
+ */
+ public int getAccessibleChildrenCount(JComponent c)
+ {
+ int result = 0;
+ Iterator iterator = uis.iterator();
+ // first UI delegate provides the return value
+ if (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ result = ui.getAccessibleChildrenCount(c);
+ }
+ // return values from auxiliary UI delegates are ignored
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ /* int ignored = */ ui.getAccessibleChildrenCount(c);
+ }
+ return result;
+ }
+
+ /**
+ * Calls the {@link ComponentUI#getAccessibleChild(JComponent, int)} method
+ * for all the UI delegates managed by this <code>MultiTreeUI</code>,
+ * returning the child for the UI delegate from the primary look and
+ * feel.
+ *
+ * @param c the component
+ * @param i the child index.
+ *
+ * @return The child returned by the UI delegate from the primary
+ * look and feel.
+ */
+ public Accessible getAccessibleChild(JComponent c, int i)
+ {
+ Accessible result = null;
+ Iterator iterator = uis.iterator();
+ // first UI delegate provides the return value
+ if (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ result = ui.getAccessibleChild(c, i);
+ }
+ // return values from auxiliary UI delegates are ignored
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ /* Accessible ignored = */ ui.getAccessibleChild(c, i);
+ }
+ return result;
+ }
+
+ /**
+ * Calls the {@link TreeUI#getPathBounds(JTree, TreePath)} method
+ * for all the UI delegates managed by this <code>MultiTreeUI</code>,
+ * returning the bounds for the UI delegate from the primary look and
+ * feel.
+ *
+ * @param tree the tree component.
+ *
+ * @return The bounds returned by the UI delegate from the primary
+ * look and feel.
+ */
+ public Rectangle getPathBounds(JTree tree, TreePath path)
+ {
+ Rectangle result = null;
+ Iterator iterator = uis.iterator();
+ // first UI delegate provides the return value
+ if (iterator.hasNext())
+ {
+ TreeUI ui = (TreeUI) iterator.next();
+ result = ui.getPathBounds(tree, path);
+ }
+ // return values from auxiliary UI delegates are ignored
+ while (iterator.hasNext())
+ {
+ TreeUI ui = (TreeUI) iterator.next();
+ /* Rectangle ignored = */ ui.getPathBounds(tree, path);
+ }
+ return result;
+ }
+
+ /**
+ * Calls the {@link TreeUI#getPathForRow(JTree, int)} method
+ * for all the UI delegates managed by this <code>MultiTreeUI</code>,
+ * returning the path for the UI delegate from the primary look and
+ * feel.
+ *
+ * @param tree the tree component.
+ *
+ * @return The path returned by the UI delegate from the primary
+ * look and feel.
+ */
+ public TreePath getPathForRow(JTree tree, int row)
+ {
+ TreePath result = null;
+ Iterator iterator = uis.iterator();
+ // first UI delegate provides the return value
+ if (iterator.hasNext())
+ {
+ TreeUI ui = (TreeUI) iterator.next();
+ result = ui.getPathForRow(tree, row);
+ }
+ // return values from auxiliary UI delegates are ignored
+ while (iterator.hasNext())
+ {
+ TreeUI ui = (TreeUI) iterator.next();
+ /* TreePath ignored = */ ui.getPathForRow(tree, row);
+ }
+ return result;
+ }
+
+ /**
+ * Calls the {@link TreeUI#getRowForPath(JTree, TreePath)} method
+ * for all the UI delegates managed by this <code>MultiTreeUI</code>,
+ * returning the row index for the UI delegate from the primary look and
+ * feel.
+ *
+ * @param tree the tree component.
+ *
+ * @return The row index returned by the UI delegate from the primary
+ * look and feel.
+ */
+ public int getRowForPath(JTree tree, TreePath path)
+ {
+ int result = 0;
+ Iterator iterator = uis.iterator();
+ // first UI delegate provides the return value
+ if (iterator.hasNext())
+ {
+ TreeUI ui = (TreeUI) iterator.next();
+ result = ui.getRowForPath(tree, path);
+ }
+ // return values from auxiliary UI delegates are ignored
+ while (iterator.hasNext())
+ {
+ TreeUI ui = (TreeUI) iterator.next();
+ /* int ignored = */ ui.getRowForPath(tree, path);
+ }
+ return result;
+ }
+
+ /**
+ * Calls the {@link TreeUI#getRowCount(JTree)} method
+ * for all the UI delegates managed by this <code>MultiTreeUI</code>,
+ * returning the count for the UI delegate from the primary look and
+ * feel.
+ *
+ * @param tree the tree component.
+ *
+ * @return The count returned by the UI delegate from the primary
+ * look and feel.
+ */
+ public int getRowCount(JTree tree)
+ {
+ int result = 0;
+ Iterator iterator = uis.iterator();
+ // first UI delegate provides the return value
+ if (iterator.hasNext())
+ {
+ TreeUI ui = (TreeUI) iterator.next();
+ result = ui.getRowCount(tree);
+ }
+ // return values from auxiliary UI delegates are ignored
+ while (iterator.hasNext())
+ {
+ TreeUI ui = (TreeUI) iterator.next();
+ /* int ignored = */ ui.getRowCount(tree);
+ }
+ return result;
+ }
+
+ /**
+ * Calls the {@link TreeUI#getClosestPathForLocation(JTree, int, int)} method
+ * for all the UI delegates managed by this <code>MultiTreeUI</code>,
+ * returning the path for the UI delegate from the primary look and
+ * feel.
+ *
+ * @param tree the tree component.
+ *
+ * @return The path returned by the UI delegate from the primary
+ * look and feel.
+ */
+ public TreePath getClosestPathForLocation(JTree tree, int x, int y)
+ {
+ TreePath result = null;
+ Iterator iterator = uis.iterator();
+ // first UI delegate provides the return value
+ if (iterator.hasNext())
+ {
+ TreeUI ui = (TreeUI) iterator.next();
+ result = ui.getClosestPathForLocation(tree, x, y);
+ }
+ // return values from auxiliary UI delegates are ignored
+ while (iterator.hasNext())
+ {
+ TreeUI ui = (TreeUI) iterator.next();
+ /* TreePath ignored = */ ui.getClosestPathForLocation(tree, x, y);
+ }
+ return result;
+ }
+
+ /**
+ * Calls the {@link TreeUI#isEditing(JTree)} method for all
+ * the UI delegates managed by this <code>MultiTreeUI</code>,
+ * returning the result for the UI delegate from the primary look and
+ * feel.
+ *
+ * @param tree the tree component.
+ *
+ * @return The result returned by the UI delegate from the primary
+ * look and feel.
+ */
+ public boolean isEditing(JTree tree)
+ {
+ boolean result = false;
+ Iterator iterator = uis.iterator();
+ // first UI delegate provides the return value
+ if (iterator.hasNext())
+ {
+ TreeUI ui = (TreeUI) iterator.next();
+ result = ui.isEditing(tree);
+ }
+ // return values from auxiliary UI delegates are ignored
+ while (iterator.hasNext())
+ {
+ TreeUI ui = (TreeUI) iterator.next();
+ /* boolean ignored = */ ui.isEditing(tree);
+ }
+ return result;
+ }
+
+ /**
+ * Calls the {@link TreeUI#stopEditing(JTree)} method for all
+ * the UI delegates managed by this <code>MultiTreeUI</code>,
+ * returning the result for the UI delegate from the primary look and
+ * feel.
+ *
+ * @param tree the tree component.
+ *
+ * @return The result returned by the UI delegate from the primary
+ * look and feel.
+ */
+ public boolean stopEditing(JTree tree)
+ {
+ boolean result = false;
+ Iterator iterator = uis.iterator();
+ // first UI delegate provides the return value
+ if (iterator.hasNext())
+ {
+ TreeUI ui = (TreeUI) iterator.next();
+ result = ui.stopEditing(tree);
+ }
+ // return values from auxiliary UI delegates are ignored
+ while (iterator.hasNext())
+ {
+ TreeUI ui = (TreeUI) iterator.next();
+ /* boolean ignored = */ ui.stopEditing(tree);
+ }
+ return result;
+ }
+
+ /**
+ * Calls the {@link TreeUI#cancelEditing(JTree)} method for
+ * all the UI delegates managed by this <code>MultiTreeUI</code>.
+ *
+ * @param tree the tree component.
+ */
+ public void cancelEditing(JTree tree)
+ {
+ Iterator iterator = uis.iterator();
+ while (iterator.hasNext())
+ {
+ TreeUI ui = (TreeUI) iterator.next();
+ ui.cancelEditing(tree);
+ }
+ }
+
+ /**
+ * Calls the {@link TreeUI#startEditingAtPath(JTree, TreePath)} method for
+ * all the UI delegates managed by this <code>MultiTreeUI</code>.
+ *
+ * @param tree the tree component.
+ * @param path the path.
+ */
+ public void startEditingAtPath(JTree tree, TreePath path)
+ {
+ Iterator iterator = uis.iterator();
+ while (iterator.hasNext())
+ {
+ TreeUI ui = (TreeUI) iterator.next();
+ ui.startEditingAtPath(tree, path);
+ }
+ }
+
+ /**
+ * Calls the {@link TreeUI#getEditingPath(JTree)} method for all
+ * the UI delegates managed by this <code>MultiTreeUI</code>,
+ * returning the path for the UI delegate from the primary look and
+ * feel.
+ *
+ * @param tree the tree component.
+ *
+ * @return The path returned by the UI delegate from the primary
+ * look and feel.
+ */
+ public TreePath getEditingPath(JTree tree)
+ {
+ TreePath result = null;
+ Iterator iterator = uis.iterator();
+ // first UI delegate provides the return value
+ if (iterator.hasNext())
+ {
+ TreeUI ui = (TreeUI) iterator.next();
+ result = ui.getEditingPath(tree);
+ }
+ // return values from auxiliary UI delegates are ignored
+ while (iterator.hasNext())
+ {
+ TreeUI ui = (TreeUI) iterator.next();
+ /* TreePath ignored = */ ui.getEditingPath(tree);
+ }
+ return result;
+ }
+
+}
--- /dev/null
+/* MultiViewPortUI.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., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 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 javax.swing.plaf.multi;
+
+import java.awt.Dimension;
+import java.awt.Graphics;
+import java.util.Iterator;
+import java.util.Vector;
+
+import javax.accessibility.Accessible;
+import javax.swing.JComponent;
+import javax.swing.LookAndFeel;
+import javax.swing.UIManager;
+import javax.swing.plaf.ComponentUI;
+import javax.swing.plaf.ViewportUI;
+
+/**
+ * A UI delegate that that coordinates multiple {@link ViewportUI}
+ * instances, one from the primary look and feel, and one or more from the
+ * auxiliary look and feel(s).
+ *
+ * @see UIManager#addAuxiliaryLookAndFeel(LookAndFeel)
+ */
+public class MultiViewportUI extends ViewportUI
+{
+
+ /** A list of references to the actual component UIs. */
+ protected Vector uis;
+
+ /**
+ * Creates a new <code>MultiViewPortUI</code> instance.
+ *
+ * @see #createUI(JComponent)
+ */
+ public MultiViewportUI()
+ {
+ uis = new Vector();
+ }
+
+ /**
+ * Creates a delegate object for the specified component. If any auxiliary
+ * look and feels support this component, a <code>MultiViewportUI</code> is
+ * returned, otherwise the UI from the default look and feel is returned.
+ *
+ * @param target the component.
+ *
+ * @see MultiLookAndFeel#createUIs(ComponentUI, Vector, JComponent)
+ */
+ public static ComponentUI createUI(JComponent target)
+ {
+ MultiViewportUI mui = new MultiViewportUI();
+ return MultiLookAndFeel.createUIs(mui, mui.uis, target);
+ }
+
+ /**
+ * Calls the {@link ComponentUI#installUI(JComponent)} method for all
+ * the UI delegates managed by this <code>MultiViewportUI</code>.
+ *
+ * @param c the component.
+ */
+ public void installUI(JComponent c)
+ {
+ Iterator iterator = uis.iterator();
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ ui.installUI(c);
+ }
+ }
+
+ /**
+ * Calls the {@link ComponentUI#uninstallUI(JComponent)} method for all
+ * the UI delegates managed by this <code>MultiViewportUI</code>.
+ *
+ * @param c the component.
+ */
+ public void uninstallUI(JComponent c)
+ {
+ Iterator iterator = uis.iterator();
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ ui.uninstallUI(c);
+ }
+ }
+
+ /**
+ * Returns an array containing the UI delegates managed by this
+ * <code>MultiViewportUI</code>. The first item in the array is always
+ * the UI delegate from the installed default look and feel.
+ *
+ * @return An array of UI delegates.
+ */
+ public ComponentUI[] getUIs()
+ {
+ return MultiLookAndFeel.uisToArray(uis);
+ }
+
+ /**
+ * Calls the {@link ComponentUI#contains(JComponent, int, int)} method for all
+ * the UI delegates managed by this <code>MultiViewportUI</code>,
+ * returning the result for the UI delegate from the primary look and
+ * feel.
+ *
+ * @param c the component.
+ * @param x the x-coordinate.
+ * @param y the y-coordinate.
+ *
+ * @return <code>true</code> if the specified (x, y) coordinate falls within
+ * the bounds of the component as rendered by the UI delegate in the
+ * primary look and feel, and <code>false</code> otherwise.
+ */
+ public boolean contains(JComponent c, int x, int y)
+ {
+ boolean result = false;
+ Iterator iterator = uis.iterator();
+ // first UI delegate provides the return value
+ if (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ result = ui.contains(c, x, y);
+ }
+ // return values from auxiliary UI delegates are ignored
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ /* boolean ignored = */ ui.contains(c, x, y);
+ }
+ return result;
+ }
+
+ /**
+ * Calls the {@link ComponentUI#update(Graphics, JComponent)} method for all
+ * the UI delegates managed by this <code>MultiViewportUI</code>.
+ *
+ * @param g the graphics device.
+ * @param c the component.
+ */
+ public void update(Graphics g, JComponent c)
+ {
+ Iterator iterator = uis.iterator();
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ ui.update(g, c);
+ }
+ }
+
+ /**
+ * Calls the <code>paint(Graphics, JComponent)</code> method for all the UI
+ * delegates managed by this <code>MultiViewportUI</code>.
+ *
+ * @param g the graphics device.
+ * @param c the component.
+ */
+ public void paint(Graphics g, JComponent c)
+ {
+ Iterator iterator = uis.iterator();
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ ui.paint(g, c);
+ }
+ }
+
+ /**
+ * Calls the {@link ComponentUI#getPreferredSize(JComponent)} method for all
+ * the UI delegates managed by this <code>MultiViewportUI</code>,
+ * returning the preferred size for the UI delegate from the primary look and
+ * feel.
+ *
+ * @param c the component.
+ *
+ * @return The preferred size returned by the UI delegate from the primary
+ * look and feel.
+ */
+ public Dimension getPreferredSize(JComponent c)
+ {
+ Dimension result = null;
+ Iterator iterator = uis.iterator();
+ // first UI delegate provides the return value
+ if (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ result = ui.getPreferredSize(c);
+ }
+ // return values from auxiliary UI delegates are ignored
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ /* Dimension ignored = */ ui.getPreferredSize(c);
+ }
+ return result;
+ }
+
+ /**
+ * Calls the {@link ComponentUI#getMinimumSize(JComponent)} method for all
+ * the UI delegates managed by this <code>MultiViewportUI</code>,
+ * returning the minimum size for the UI delegate from the primary look and
+ * feel.
+ *
+ * @param c the component.
+ *
+ * @return The minimum size returned by the UI delegate from the primary
+ * look and feel.
+ */
+ public Dimension getMinimumSize(JComponent c)
+ {
+ Dimension result = null;
+ Iterator iterator = uis.iterator();
+ // first UI delegate provides the return value
+ if (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ result = ui.getMinimumSize(c);
+ }
+ // return values from auxiliary UI delegates are ignored
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ /* Dimension ignored = */ ui.getMinimumSize(c);
+ }
+ return result;
+ }
+
+ /**
+ * Calls the {@link ComponentUI#getMaximumSize(JComponent)} method for all
+ * the UI delegates managed by this <code>MultiViewportUI</code>,
+ * returning the maximum size for the UI delegate from the primary look and
+ * feel.
+ *
+ * @param c the component.
+ *
+ * @return The maximum size returned by the UI delegate from the primary
+ * look and feel.
+ */
+ public Dimension getMaximumSize(JComponent c)
+ {
+ Dimension result = null;
+ Iterator iterator = uis.iterator();
+ // first UI delegate provides the return value
+ if (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ result = ui.getMaximumSize(c);
+ }
+ // return values from auxiliary UI delegates are ignored
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ /* Dimension ignored = */ ui.getMaximumSize(c);
+ }
+ return result;
+ }
+
+ /**
+ * Calls the {@link ComponentUI#getAccessibleChildrenCount(JComponent)} method
+ * for all the UI delegates managed by this <code>MultiViewportUI</code>,
+ * returning the count for the UI delegate from the primary look and
+ * feel.
+ *
+ * @param c the component.
+ *
+ * @return The count returned by the UI delegate from the primary
+ * look and feel.
+ */
+ public int getAccessibleChildrenCount(JComponent c)
+ {
+ int result = 0;
+ Iterator iterator = uis.iterator();
+ // first UI delegate provides the return value
+ if (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ result = ui.getAccessibleChildrenCount(c);
+ }
+ // return values from auxiliary UI delegates are ignored
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ /* int ignored = */ ui.getAccessibleChildrenCount(c);
+ }
+ return result;
+ }
+
+ /**
+ * Calls the {@link ComponentUI#getAccessibleChild(JComponent, int)} method
+ * for all the UI delegates managed by this <code>MultiViewportUI</code>,
+ * returning the child for the UI delegate from the primary look and
+ * feel.
+ *
+ * @param c the component
+ * @param i the child index.
+ *
+ * @return The child returned by the UI delegate from the primary
+ * look and feel.
+ */
+ public Accessible getAccessibleChild(JComponent c, int i)
+ {
+ Accessible result = null;
+ Iterator iterator = uis.iterator();
+ // first UI delegate provides the return value
+ if (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ result = ui.getAccessibleChild(c, i);
+ }
+ // return values from auxiliary UI delegates are ignored
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ /* Accessible ignored = */ ui.getAccessibleChild(c, i);
+ }
+ return result;
+ }
+
+}
--- /dev/null
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
+<!-- package.html - describes classes in javax.swing.plaf.metal package.
+ Copyright (C) 2002, 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., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 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 - javax.swing.plaf.multi</title></head>
+
+<body>
+<p>Provides a look and feel that can combine a primary look and feel with one or more auxiliary look and feels.</p>
+
+</body>
+</html>
--- /dev/null
+/* AbstractWriter.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., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 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 javax.swing.text;
+
+import java.io.IOException;
+import java.io.Writer;
+import java.util.Arrays;
+import java.util.Enumeration;
+
+/**
+ * This is an abstract base class for writing Document instances to a
+ * Writer. A concrete subclass must implement a method to iterate
+ * over the Elements of the Document and correctly format them.
+ */
+public abstract class AbstractWriter
+{
+ /**
+ * The default line separator character.
+ * @specnote although this is a constant, it is not static in the JDK
+ */
+ protected static final char NEWLINE = '\n';
+
+ // Where we write.
+ private Writer writer;
+ // How we iterate over the document.
+ private ElementIterator iter;
+ // The document over which we iterate.
+ private Document document;
+ // Maximum number of characters per line.
+ private int maxLineLength = 100;
+ // Number of characters we have currently written.
+ private int lineLength;
+ // True if we can apply line wrapping.
+ private boolean canWrapLines; // FIXME default?
+ // The number of spaces per indentation level.
+ private int indentSpace = 2;
+ // The current indentation level.
+ private int indentLevel;
+ // True if we have indented this line.
+ private boolean indented;
+ // Starting offset in document.
+ private int startOffset;
+ // Ending offset in document.
+ private int endOffset;
+ // The line separator string.
+ private String lineSeparator = "" + NEWLINE;
+ // The characters making up the line separator.
+ private char[] lineSeparatorChars = lineSeparator.toCharArray();
+
+ /**
+ * Create a new AbstractWriter with the indicated Writer and
+ * Document. The full range of the Document will be used. The
+ * internal ElementIterator will be initialized with the Document's
+ * root node.
+ */
+ protected AbstractWriter(Writer writer, Document doc)
+ {
+ this.writer = writer;
+ this.iter = new ElementIterator(doc);
+ this.document = doc;
+ this.startOffset = 0;
+ this.endOffset = doc.getLength();
+ }
+
+ /**
+ * Create a new AbstractWriter with the indicated Writer and
+ * Document. The full range of the Document will be used. The
+ * internal ElementIterator will be initialized with the Document's
+ * root node.
+ */
+ protected AbstractWriter(Writer writer, Document doc, int pos, int len)
+ {
+ this.writer = writer;
+ this.iter = new ElementIterator(doc);
+ this.document = doc;
+ this.startOffset = pos;
+ this.endOffset = pos + len;
+ }
+
+ /**
+ * Create a new AbstractWriter with the indicated Writer and
+ * Element. The full range of the Element will be used.
+ */
+ protected AbstractWriter(Writer writer, Element elt)
+ {
+ this.writer = writer;
+ this.iter = new ElementIterator(elt);
+ this.document = elt.getDocument();
+ this.startOffset = elt.getStartOffset();
+ this.endOffset = elt.getEndOffset();
+ }
+
+ /**
+ * Create a new AbstractWriter with the indicated Writer and
+ * Element. The full range of the Element will be used. The range
+ * will be limited to the indicated range of the Document.
+ */
+ protected AbstractWriter(Writer writer, Element elt, int pos, int len)
+ {
+ this.writer = writer;
+ this.iter = new ElementIterator(elt);
+ this.document = elt.getDocument();
+ this.startOffset = pos;
+ this.endOffset = pos + len;
+ }
+
+ /**
+ * Return the ElementIterator for this writer.
+ */
+ protected ElementIterator getElementIterator()
+ {
+ return iter;
+ }
+
+ /**
+ * Return the Writer to which we are writing.
+ * @since 1.3
+ */
+ protected Writer getWriter()
+ {
+ return writer;
+ }
+
+ /**
+ * Return this writer's Document.
+ */
+ protected Document getDocument()
+ {
+ return document;
+ }
+
+ /**
+ * This method must be overridden by a concrete subclass. It is
+ * responsible for iterating over the Elements of the Document and
+ * writing them out.
+ */
+ protected abstract void write() throws IOException, BadLocationException;
+
+ /**
+ * Return the text of the Document that is associated with the given
+ * Element. If the Element is not a leaf Element, this will throw
+ * BadLocationException.
+ *
+ * @throws BadLocationException if the element is not a leaf
+ */
+ protected String getText(Element elt) throws BadLocationException
+ {
+ if (! elt.isLeaf())
+ throw new BadLocationException("Element is not a leaf",
+ elt.getStartOffset());
+ return document.getText(elt.getStartOffset(), elt.getEndOffset());
+ }
+
+ /**
+ * This method calls Writer.write on the indicated data, and updates
+ * the current line length. This method does not look for newlines
+ * in the written data; the caller is responsible for that.
+ *
+ * @since 1.3
+ */
+ protected void output(char[] data, int start, int len) throws IOException
+ {
+ writer.write(data, start, len);
+ lineLength += len;
+ }
+
+ /**
+ * Write a line separator using the output method, and then reset
+ * the current line length.
+ *
+ * @since 1.3
+ */
+ protected void writeLineSeparator() throws IOException
+ {
+ output(lineSeparatorChars, 0, lineSeparatorChars.length);
+ lineLength = 0;
+ indented = false;
+ }
+
+ /**
+ * Write a single character.
+ */
+ protected void write(char ch) throws IOException
+ {
+ write(new char[] { ch }, 0, 1);
+ }
+
+ /**
+ * Write a String.
+ */
+ protected void write(String s) throws IOException
+ {
+ char[] v = s.toCharArray();
+ write(v, 0, v.length);
+ }
+
+ /**
+ * Write a character array to the output Writer, properly handling
+ * newlines and, if needed, wrapping lines as they are output.
+ * @since 1.3
+ */
+ protected void write(char[] data, int start, int len) throws IOException
+ {
+ if (getCanWrapLines())
+ {
+ // FIXME: should we be handling newlines specially here?
+ for (int i = 0; i < len; )
+ {
+ int start_i = i;
+ // Find next space.
+ while (i < len && data[start + i] != ' ')
+ ++i;
+ if (i < len && lineLength + i - start_i >= maxLineLength)
+ writeLineSeparator();
+ else if (i < len)
+ {
+ // Write the trailing space.
+ ++i;
+ }
+ // Write out the text.
+ output(data, start + start_i, start + i - start_i);
+ }
+ }
+ else
+ {
+ int saved_i = start;
+ for (int i = start; i < start + len; ++i)
+ {
+ if (data[i] == NEWLINE)
+ {
+ output(data, saved_i, i - saved_i);
+ writeLineSeparator();
+ }
+ }
+ if (saved_i < start + len - 1)
+ output(data, saved_i, start + len - saved_i);
+ }
+ }
+
+ /**
+ * Indent this line by emitting spaces, according to the current
+ * indent level and the current number of spaces per indent. After
+ * this method is called, the current line is no longer considered
+ * to be empty, even if no spaces are actually written.
+ */
+ protected void indent() throws IOException
+ {
+ int spaces = indentLevel * indentSpace;
+ if (spaces > 0)
+ {
+ char[] v = new char[spaces];
+ Arrays.fill(v, ' ');
+ write(v, 0, v.length);
+ }
+ indented = true;
+ }
+
+ /**
+ * Return the index of the Document at which output starts.
+ * @since 1.3
+ */
+ public int getStartOffset()
+ {
+ return startOffset;
+ }
+
+ /**
+ * Return the index of the Document at which output ends.
+ * @since 1.3
+ */
+ public int getEndOffset()
+ {
+ return endOffset;
+ }
+
+ /**
+ * Return true if the Element's range overlaps our desired output
+ * range; false otherwise.
+ */
+ protected boolean inRange(Element elt)
+ {
+ int eltStart = elt.getStartOffset();
+ int eltEnd = elt.getEndOffset();
+ return ((eltStart >= startOffset && eltStart < endOffset)
+ || (eltEnd >= startOffset && eltEnd < endOffset));
+ }
+
+ /**
+ * Output the text of the indicated Element, properly clipping it to
+ * the range of the Document specified when the AbstractWriter was
+ * created.
+ */
+ protected void text(Element elt) throws BadLocationException, IOException
+ {
+ int eltStart = elt.getStartOffset();
+ int eltEnd = elt.getEndOffset();
+
+ eltStart = Math.max(eltStart, startOffset);
+ eltEnd = Math.min(eltEnd, endOffset);
+ write(document.getText(eltStart, eltEnd));
+ }
+
+ /**
+ * Set the maximum line length.
+ */
+ protected void setLineLength(int maxLineLength)
+ {
+ this.maxLineLength = maxLineLength;
+ }
+
+ /**
+ * Return the maximum line length.
+ * @since 1.3
+ */
+ protected int getLineLength()
+ {
+ return maxLineLength;
+ }
+
+ /**
+ * Set the current line length.
+ * @since 1.3
+ */
+ protected void setCurrentLineLength(int lineLength)
+ {
+ this.lineLength = lineLength;
+ }
+
+ /**
+ * Return the current line length.
+ * @since 1.3
+ */
+ protected int getCurrentLineLength()
+ {
+ return lineLength;
+ }
+
+ /**
+ * Return true if the line is empty, false otherwise. The line is
+ * empty if nothing has been written since the last newline, and
+ * indent has not been invoked.
+ */
+ protected boolean isLineEmpty()
+ {
+ return lineLength == 0 && ! indented;
+ }
+
+ /**
+ * Set the flag indicating whether lines will wrap. This affects
+ * the behavior of write().
+ * @since 1.3
+ */
+ protected void setCanWrapLines(boolean canWrapLines)
+ {
+ this.canWrapLines = canWrapLines;
+ }
+
+ /**
+ * Return true if lines printed via write() will wrap, false
+ * otherwise.
+ * @since 1.3
+ */
+ protected boolean getCanWrapLines()
+ {
+ return canWrapLines;
+ }
+
+ /**
+ * Set the number of spaces per indent level.
+ * @since 1.3
+ */
+ protected void setIndentSpace(int indentSpace)
+ {
+ this.indentSpace = indentSpace;
+ }
+
+ /**
+ * Return the number of spaces per indent level.
+ * @since 1.3
+ */
+ protected int getIndentSpace()
+ {
+ return indentSpace;
+ }
+
+ /**
+ * Set the current line separator.
+ * @since 1.3
+ */
+ public void setLineSeparator(String lineSeparator)
+ {
+ this.lineSeparator = lineSeparator;
+ this.lineSeparatorChars = lineSeparator.toCharArray();
+ }
+
+ /**
+ * Return the current line separator.
+ * @since 1.3
+ */
+ public String getLineSeparator()
+ {
+ return lineSeparator;
+ }
+
+ /**
+ * Increment the indent level.
+ */
+ protected void incrIndent()
+ {
+ ++indentLevel;
+ }
+
+ /**
+ * Decrement the indent level.
+ */
+ protected void decrIndent()
+ {
+ --indentLevel;
+ }
+
+ /**
+ * Return the current indent level.
+ * @since 1.3
+ */
+ protected int getIndentLevel()
+ {
+ return indentLevel;
+ }
+
+ /**
+ * Print the given AttributeSet as a sequence of assignment-like
+ * strings, e.g. "key=value".
+ */
+ protected void writeAttributes(AttributeSet attrs) throws IOException
+ {
+ Enumeration e = attrs.getAttributeNames();
+ while (e.hasMoreElements())
+ {
+ Object name = e.nextElement();
+ Object val = attrs.getAttribute(name);
+ write(name + "=" + val);
+ writeLineSeparator();
+ }
+ }
+}
--- /dev/null
+/* BoxView.java -- An composite view
+ 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., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 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 javax.swing.text;
+
+import java.awt.Graphics;
+import java.awt.Rectangle;
+import java.awt.Shape;
+
+import javax.swing.SizeRequirements;
+
+/**
+ * An implementation of {@link CompositeView} that arranges its children in
+ * a box along one axis. This is comparable to how the <code>BoxLayout</code>
+ * works, but for <code>View</code> children.
+ *
+ * @author Roman Kennke (roman@kennke.org)
+ */
+public class BoxView
+ extends CompositeView
+{
+
+ /**
+ * The axis along which this <code>BoxView</code> is laid out.
+ */
+ int myAxis;
+
+ /**
+ * Indicates wether the layout in X_AXIS is valid.
+ */
+ boolean xLayoutValid;
+
+ /**
+ * Indicates whether the layout in Y_AXIS is valid.
+ */
+ boolean yLayoutValid;
+
+ /**
+ * The spans in X direction of the children.
+ */
+ int[] spansX;
+
+ /**
+ * The spans in Y direction of the children.
+ */
+ int[] spansY;
+
+ /**
+ * The offsets of the children in X direction relative to this BoxView's
+ * inner bounds.
+ */
+ int[] offsetsX;
+
+ /**
+ * The offsets of the children in Y direction relative to this BoxView's
+ * inner bounds.
+ */
+ int[] offsetsY;
+
+ /**
+ * The current width.
+ */
+ int width;
+
+ /**
+ * The current height.
+ */
+ int height;
+
+ /**
+ * Creates a new <code>BoxView</code> for the given
+ * <code>Element</code> and axis. Valid values for the axis are
+ * {@link View#X_AXIS} and {@link View#Y_AXIS}.
+ *
+ * @param element the element that is rendered by this BoxView
+ * @param axis the axis along which the box is laid out
+ */
+ public BoxView(Element element, int axis)
+ {
+ super(element);
+ myAxis = axis;
+ xLayoutValid = false;
+ yLayoutValid = false;
+
+ // Initialize the cache arrays.
+ spansX = new int[0];
+ spansY = new int[0];
+ offsetsX = new int[0];
+ offsetsY = new int[0];
+
+ width = 0;
+ height = 0;
+ }
+
+ /**
+ * Returns the axis along which this <code>BoxView</code> is laid out.
+ *
+ * @return the axis along which this <code>BoxView</code> is laid out
+ */
+ public int getAxis()
+ {
+ return myAxis;
+ }
+
+ /**
+ * Sets the axis along which this <code>BoxView</code> is laid out.
+ *
+ * Valid values for the axis are {@link View#X_AXIS} and
+ * {@link View#Y_AXIS}.
+ *
+ * @param axis the axis along which this <code>BoxView</code> is laid out
+ */
+ public void setAxis(int axis)
+ {
+ myAxis = axis;
+ }
+
+ /**
+ * Marks the layout along the specified axis as invalid. This is triggered
+ * automatically when any of the child view changes its preferences
+ * via {@link #preferenceChanged(View, boolean, boolean)}.
+ *
+ * The layout will be updated the next time when {@link #setSize()} is
+ * called, typically from within the {@link #paint()} method.
+ *
+ * Valid values for the axis are {@link View#X_AXIS} and
+ * {@link View#Y_AXIS}.
+ *
+ * @param axis an <code>int</code> value
+ */
+ public void layoutChanged(int axis)
+ {
+ switch (axis)
+ {
+ case X_AXIS:
+ xLayoutValid = false;
+ break;
+ case Y_AXIS:
+ yLayoutValid = false;
+ break;
+ default:
+ throw new IllegalArgumentException("Invalid axis parameter.");
+ }
+ }
+
+ /**
+ * Returns <code>true</code> if the layout along the specified
+ * <code>axis</code> is valid, <code>false</code> otherwise.
+ *
+ * Valid values for the axis are {@link View#X_AXIS} and
+ * {@link View#Y_AXIS}.
+ *
+ * @param axis the axis
+ *
+ * @return <code>true</code> if the layout along the specified
+ * <code>axis</code> is valid, <code>false</code> otherwise
+ */
+ protected boolean isLayoutValid(int axis)
+ {
+ boolean valid = false;
+ switch (axis)
+ {
+ case X_AXIS:
+ valid = xLayoutValid;
+ break;
+ case Y_AXIS:
+ valid = yLayoutValid;
+ break;
+ default:
+ throw new IllegalArgumentException("Invalid axis parameter.");
+ }
+ return valid;
+ }
+
+ /**
+ * Paints the child <code>View</code> at the specified <code>index</code>.
+ * This method modifies the actual values in <code>alloc</code> so make
+ * sure you have a copy of the original values if you need them.
+ *
+ * @param g the <code>Graphics</code> context to paint to
+ * @param alloc the allocated region for the child to paint into
+ * @param index the index of the child to be painted
+ *
+ * @see {@link #childAllocation}
+ */
+ protected void paintChild(Graphics g, Rectangle alloc, int index)
+ {
+ View child = getView(index);
+ childAllocation(index, alloc);
+ child.paint(g, alloc);
+ }
+
+ /**
+ * Replaces child views by some other child views. If there are no views to
+ * remove (<code>length == 0</code>), the result is a simple insert, if
+ * there are no children to add (<code>view == null</code>) the result
+ * is a simple removal.
+ *
+ * In addition this invalidates the layout and resizes the internal cache
+ * for the child allocations. The old children's cached allocations can
+ * still be accessed (although they are not guaranteed to be valid), and
+ * the new children will have an initial offset and span of 0.
+ *
+ * @param offset the start offset from where to remove children
+ * @param length the number of children to remove
+ * @param views the views that replace the removed children
+ */
+ public void replace(int offset, int length, View[] views)
+ {
+ // Resize and copy data for cache arrays.
+ // The spansX cache.
+ int oldSize = getViewCount();
+
+ int[] newSpansX = new int[oldSize - length + views.length];
+ System.arraycopy(spansX, 0, newSpansX, 0, offset);
+ System.arraycopy(spansX, offset + length, newSpansX,
+ offset + views.length,
+ oldSize - (offset + length));
+ spansX = newSpansX;
+
+ // The spansY cache.
+ int[] newSpansY = new int[oldSize - length + views.length];
+ System.arraycopy(spansY, 0, newSpansY, 0, offset);
+ System.arraycopy(spansY, offset + length, newSpansY,
+ offset + views.length,
+ oldSize - (offset + length));
+ spansY = newSpansY;
+
+ // The offsetsX cache.
+ int[] newOffsetsX = new int[oldSize - length + views.length];
+ System.arraycopy(offsetsX, 0, newOffsetsX, 0, offset);
+ System.arraycopy(offsetsX, offset + length, newOffsetsX,
+ offset + views.length,
+ oldSize - (offset + length));
+ offsetsX = newOffsetsX;
+
+ // The offsetsY cache.
+ int[] newOffsetsY = new int[oldSize - length + views.length];
+ System.arraycopy(offsetsY, 0, newOffsetsY, 0, offset);
+ System.arraycopy(offsetsY, offset + length, newOffsetsY,
+ offset + views.length,
+ oldSize - (offset + length));
+ offsetsY = newOffsetsY;
+
+ // Actually perform the replace.
+ super.replace(offset, length, views);
+
+ // Invalidate layout information.
+ layoutChanged(X_AXIS);
+ layoutChanged(Y_AXIS);
+ }
+
+ /**
+ * Renders the <code>Element</code> that is associated with this
+ * <code>View</code>.
+ *
+ * @param g the <code>Graphics</code> context to render to
+ * @param a the allocated region for the <code>Element</code>
+ */
+ public void paint(Graphics g, Shape a)
+ {
+ // Adjust size if the size is changed.
+ Rectangle bounds = a.getBounds();
+
+ if (bounds.width != getWidth() || bounds.height != getHeight())
+ setSize(bounds.width, bounds.height);
+
+ Rectangle inside = getInsideAllocation(a);
+
+ Rectangle copy = new Rectangle(inside);
+ int count = getViewCount();
+ for (int i = 0; i < count; ++i)
+ {
+ // TODO: Figure out if the parameter to paintChild is meant to
+ // be the child allocation or the allocation of this BoxView.
+ // I assume the second option here.
+ // We pass this method a copy of the inside rectangle here because
+ // it modifies the actual values.
+ copy.setBounds(inside);
+ paintChild(g, copy, i);
+ }
+ }
+
+ /**
+ * Returns the preferred span of the content managed by this
+ * <code>View</code> along the specified <code>axis</code>.
+ *
+ * @param axis the axis
+ *
+ * @return the preferred span of this <code>View</code>.
+ */
+ public float getPreferredSpan(int axis)
+ {
+ SizeRequirements sr = new SizeRequirements();
+ int pref = baselineRequirements(axis, sr).preferred;
+ return (float) pref;
+ }
+
+ public float getMaximumSpan(int axis)
+ {
+ if (axis == getAxis())
+ return getPreferredSpan(axis);
+ else
+ return Integer.MAX_VALUE;
+ }
+
+ /**
+ * Calculates the size requirements for this <code>BoxView</code> along
+ * the specified axis.
+ *
+ * @param axis the axis that is examined
+ * @param sr the <code>SizeRequirements</code> object to hold the result,
+ * if <code>null</code>, a new one is created
+ *
+ * @return the size requirements for this <code>BoxView</code> along
+ * the specified axis
+ */
+ protected SizeRequirements baselineRequirements(int axis,
+ SizeRequirements sr)
+ {
+ SizeRequirements result;
+ if (axis == myAxis)
+ result = calculateMajorAxisRequirements(axis, sr);
+ else
+ result = calculateMinorAxisRequirements(axis, sr);
+ return result;
+ }
+
+ /**
+ * Calculates the size requirements of this <code>BoxView</code> along
+ * its major axis, that is the axis specified in the constructor.
+ *
+ * @param axis the axis that is examined
+ * @param sr the <code>SizeRequirements</code> object to hold the result,
+ * if <code>null</code>, a new one is created
+ *
+ * @return the size requirements for this <code>BoxView</code> along
+ * the specified axis
+ */
+ protected SizeRequirements calculateMajorAxisRequirements(int axis,
+ SizeRequirements sr)
+ {
+ if (sr == null)
+ sr = new SizeRequirements();
+ else
+ {
+ sr.maximum = 0;
+ sr.minimum = 0;
+ sr.preferred = 0;
+ sr.alignment = 0.5F;
+ }
+
+ int count = getViewCount();
+
+ // Sum up the sizes of the children along the specified axis.
+ for (int i = 0; i < count; ++i)
+ {
+ View child = getView(i);
+ sr.minimum += child.getMinimumSpan(axis);
+ sr.preferred += child.getPreferredSpan(axis);
+ sr.maximum += child.getMaximumSpan(axis);
+ }
+ return sr;
+ }
+
+ /**
+ * Calculates the size requirements of this <code>BoxView</code> along
+ * its minor axis, that is the axis opposite to the axis specified in the
+ * constructor.
+ *
+ * @param axis the axis that is examined
+ * @param sr the <code>SizeRequirements</code> object to hold the result,
+ * if <code>null</code>, a new one is created
+ *
+ * @return the size requirements for this <code>BoxView</code> along
+ * the specified axis
+ */
+ protected SizeRequirements calculateMinorAxisRequirements(int axis,
+ SizeRequirements sr)
+ {
+ if (sr == null)
+ sr = new SizeRequirements();
+ else
+ {
+ sr.maximum = 0;
+ sr.minimum = 0;
+ sr.preferred = 0;
+ sr.alignment = 0.5F;
+ }
+
+ int count = getViewCount();
+
+ int aboveBaseline = 0;
+ int belowBaseline = 0;
+ int aboveBaselineMin = 0;
+ int belowBaselineMin = 0;
+ int aboveBaselineMax = 0;
+ int belowBaselineMax = 0;
+
+ for (int i = 0; i < count; ++i)
+ {
+ View child = getView(i);
+ float align = child.getAlignment(axis);
+ int pref = (int) child.getPreferredSpan(axis);
+ int min = (int) child.getMinimumSpan(axis);
+ int max = (int) child.getMaximumSpan(axis);
+ aboveBaseline += (int) (align * pref);
+ belowBaseline += (int) ((1.F - align) * pref);
+ aboveBaselineMin += (int) (align * min);
+ belowBaselineMin += (int) ((1.F - align) * min);
+ aboveBaselineMax += (int) (align * max);
+ belowBaselineMax += (int) ((1.F - align) * max);
+ }
+ sr.minimum = aboveBaselineMin + belowBaselineMin;
+ sr.maximum = aboveBaselineMax + belowBaselineMax;
+ sr.preferred = aboveBaseline + belowBaseline;
+ if (aboveBaseline == 0)
+ sr.alignment = 1.0F;
+ else
+ sr.alignment = (float) (sr.preferred / aboveBaseline);
+
+ return sr;
+ }
+
+ /**
+ * Returns <code>true</code> if the specified point lies before the
+ * given <code>Rectangle</code>, <code>false</code> otherwise.
+ *
+ * "Before" is typically defined as being to the left or above.
+ *
+ * @param x the X coordinate of the point
+ * @param y the Y coordinate of the point
+ * @param r the rectangle to test the point against
+ *
+ * @return <code>true</code> if the specified point lies before the
+ * given <code>Rectangle</code>, <code>false</code> otherwise
+ */
+ protected boolean isBefore(int x, int y, Rectangle r)
+ {
+ boolean result = false;
+
+ if (myAxis == X_AXIS)
+ result = x < r.x;
+ else
+ result = y < r.y;
+
+ return result;
+ }
+
+ /**
+ * Returns <code>true</code> if the specified point lies after the
+ * given <code>Rectangle</code>, <code>false</code> otherwise.
+ *
+ * "After" is typically defined as being to the right or below.
+ *
+ * @param x the X coordinate of the point
+ * @param y the Y coordinate of the point
+ * @param r the rectangle to test the point against
+ *
+ * @return <code>true</code> if the specified point lies after the
+ * given <code>Rectangle</code>, <code>false</code> otherwise
+ */
+ protected boolean isAfter(int x, int y, Rectangle r)
+ {
+ boolean result = false;
+
+ if (myAxis == X_AXIS)
+ result = x > r.x;
+ else
+ result = y > r.y;
+
+ return result;
+ }
+
+ /**
+ * Returns the child <code>View</code> at the specified location.
+ *
+ * @param x the X coordinate
+ * @param y the Y coordinate
+ * @param r the inner allocation of this <code>BoxView</code> on entry,
+ * the allocation of the found child on exit
+ *
+ * @return the child <code>View</code> at the specified location
+ */
+ protected View getViewAtPoint(int x, int y, Rectangle r)
+ {
+ View result = null;
+
+ int count = getViewCount();
+ Rectangle copy = new Rectangle(r);
+
+ for (int i = 0; i < count; ++i)
+ {
+ copy.setBounds(r);
+ childAllocation(i, r);
+ if (copy.contains(x, y))
+ {
+ result = getView(i);
+ break;
+ }
+ }
+
+ return result;
+ }
+
+ /**
+ * Computes the allocation for a child <code>View</code>. The parameter
+ * <code>a</code> stores the allocation of this <code>CompositeView</code>
+ * and is then adjusted to hold the allocation of the child view.
+ *
+ * @param index the index of the child <code>View</code>
+ * @param a the allocation of this <code>CompositeView</code> before the
+ * call, the allocation of the child on exit
+ */
+ protected void childAllocation(int index, Rectangle a)
+ {
+ if (! isAllocationValid())
+ layout(a.width, a.height);
+
+ a.x += offsetsX[index];
+ a.y += offsetsY[index];
+ a.width = spansX[index];
+ a.height = spansY[index];
+ }
+
+ /**
+ * Lays out the children of this <code>BoxView</code> with the specified
+ * bounds.
+ *
+ * @param width the width of the allocated region for the children (that
+ * is the inner allocation of this <code>BoxView</code>
+ * @param height the height of the allocated region for the children (that
+ * is the inner allocation of this <code>BoxView</code>
+ */
+ protected void layout(int width, int height)
+ {
+ this.width = width;
+ this.height = height;
+
+ if (myAxis == X_AXIS)
+ {
+ layoutMajorAxis(width, X_AXIS, offsetsX, spansX);
+ layoutMinorAxis(height, Y_AXIS, offsetsY, spansY);
+ }
+ else
+ {
+ layoutMajorAxis(height, Y_AXIS, offsetsY, spansY);
+ layoutMinorAxis(width, X_AXIS, offsetsX, spansX);
+ }
+ }
+
+ /**
+ * Performs the layout along the major axis of a <code>BoxView</code>.
+ *
+ * @param targetSpan the (inner) span of the <code>BoxView</code> in which
+ * to layout the children
+ * @param axis the axis along which the layout is performed
+ * @param offsets the array that holds the offsets of the children on exit
+ * @param offsets the array that holds the spans of the children on exit
+ */
+ protected void layoutMajorAxis(int targetSpan, int axis, int[] offsets,
+ int[] spans)
+ {
+ // Allocate SizeRequirements for each child view.
+ int count = getViewCount();
+ SizeRequirements[] childReqs = new SizeRequirements[count];
+ for (int i = 0; i < count; ++i)
+ {
+ View view = getView(i);
+ childReqs[i] = new SizeRequirements((int) view.getMinimumSpan(axis),
+ (int) view.getPreferredSpan(axis),
+ (int) view.getMaximumSpan(axis),
+ view.getAlignment(axis));
+ }
+
+ // Calculate the spans and offsets using the SizeRequirements uility
+ // methods.
+ SizeRequirements.calculateTiledPositions(targetSpan, null, childReqs,
+ offsets, spans);
+
+ validateLayout(axis);
+ }
+
+ /**
+ * Performs the layout along the minor axis of a <code>BoxView</code>.
+ *
+ * @param targetSpan the (inner) span of the <code>BoxView</code> in which
+ * to layout the children
+ * @param axis the axis along which the layout is performed
+ * @param offsets the array that holds the offsets of the children on exit
+ * @param offsets the array that holds the spans of the children on exit
+ */
+ protected void layoutMinorAxis(int targetSpan, int axis, int[] offsets,
+ int[] spans)
+ {
+ // Allocate SizeRequirements for each child view.
+ int count = getViewCount();
+ SizeRequirements[] childReqs = new SizeRequirements[count];
+ for (int i = 0; i < count; ++i)
+ {
+ View view = getView(i);
+ childReqs[i] = new SizeRequirements((int) view.getMinimumSpan(axis),
+ (int) view.getPreferredSpan(axis),
+ (int) view.getMaximumSpan(axis),
+ view.getAlignment(axis));
+ }
+
+ // Calculate the spans and offsets using the SizeRequirements uility
+ // methods.
+ SizeRequirements.calculateAlignedPositions(targetSpan, null, childReqs,
+ offsets, spans);
+ validateLayout(axis);
+ }
+
+ /**
+ * Returns <code>true</code> if the cached allocations for the children
+ * are still valid, <code>false</code> otherwise.
+ *
+ * @return <code>true</code> if the cached allocations for the children
+ * are still valid, <code>false</code> otherwise
+ */
+ protected boolean isAllocationValid()
+ {
+ return isLayoutValid(X_AXIS) && isLayoutValid(Y_AXIS);
+ }
+
+ /**
+ * Return the current width of the box. This is the last allocated width.
+ *
+ * @return the current width of the box
+ */
+ public int getWidth()
+ {
+ return width;
+ }
+
+ /**
+ * Return the current height of the box. This is the last allocated height.
+ *
+ * @return the current height of the box
+ */
+ public int getHeight()
+ {
+ return height;
+ }
+
+ /**
+ * Sets the size of the view. If the actual size has changed, the layout
+ * is updated accordingly.
+ *
+ * @param width the new width
+ * @param height the new height
+ */
+ public void setSize(float width, float height)
+ {
+ if (this.width != (int) width)
+ layoutChanged(X_AXIS);
+ if (this.height != (int) height)
+ layoutChanged(Y_AXIS);
+
+ Rectangle outside = new Rectangle(0, 0, this.width, this.height);
+ Rectangle inside = getInsideAllocation(outside);
+ if (!isAllocationValid())
+ layout(inside.width, inside.height);
+ }
+
+ /**
+ * Sets the layout to valid for a specific axis.
+ *
+ * @param axis the axis for which to validate the layout
+ */
+ void validateLayout(int axis)
+ {
+ if (axis == X_AXIS)
+ xLayoutValid = true;
+ if (axis == Y_AXIS)
+ yLayoutValid = true;
+ }
+}
--- /dev/null
+/* CompositeView.java -- An abstract view that manages child views
+ 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., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 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 javax.swing.text;
+
+import java.awt.Insets;
+import java.awt.Rectangle;
+import java.awt.Shape;
+
+import javax.swing.SwingConstants;
+
+/**
+ * An abstract base implementation of {@link View} that manages child
+ * <code>View</code>s.
+ *
+ * @author Roman Kennke (roman@kennke.org)
+ */
+public abstract class CompositeView
+ extends View
+{
+
+ /**
+ * The child views of this <code>CompositeView</code>.
+ */
+ View[] children;
+
+ /**
+ * The allocation of this <code>View</code> minus its insets. This is
+ * initialized in {@link #getInsideAllocation} and reused and modified in
+ * {@link childAllocation}.
+ */
+ Rectangle insideAllocation;
+
+ /**
+ * The insets of this <code>CompositeView</code>. This is initialized
+ * in {@link #setInsets}.
+ */
+ Insets insets;
+
+ /**
+ * Creates a new <code>CompositeView</code> for the given
+ * <code>Element</code>.
+ *
+ * @param element the element that is rendered by this CompositeView
+ */
+ public CompositeView(Element element)
+ {
+ super(element);
+ children = new View[0];
+ insets = new Insets(0, 0, 0, 0);
+ }
+
+ /**
+ * Loads the child views of this <code>CompositeView</code>. This method
+ * is called from {@link #setParent} to initialize the child views of
+ * this composite view.
+ *
+ * @param f the view factory to use for creating new child views
+ *
+ * @see #setParent
+ */
+ protected void loadChildren(ViewFactory f)
+ {
+ Element el = getElement();
+ int count = el.getElementCount();
+ View[] newChildren = new View[count];
+ for (int i = 0; i < count; ++i)
+ {
+ Element child = el.getElement(i);
+ View view = f.create(child);
+ newChildren[i] = view;
+ }
+ replace(0, getViewCount(), newChildren);
+ }
+
+ /**
+ * Sets the parent of this <code>View</code>.
+ * In addition to setting the parent, this calls {@link #loadChildren}, if
+ * this <code>View</code> does not already have its children initialized.
+ *
+ * @param parent the parent to set
+ */
+ public void setParent(View parent)
+ {
+ super.setParent(parent);
+ if (parent != null && ((children == null) || children.length == 0))
+ loadChildren(getViewFactory());
+ }
+
+ /**
+ * Returns the number of child views.
+ *
+ * @return the number of child views
+ */
+ public int getViewCount()
+ {
+ return children.length;
+ }
+
+ /**
+ * Returns the child view at index <code>n</code>.
+ *
+ * @param n the index of the requested child view
+ *
+ * @return the child view at index <code>n</code>
+ */
+ public View getView(int n)
+ {
+ return children[n];
+ }
+
+ /**
+ * Replaces child views by some other child views. If there are no views to
+ * remove (<code>length == 0</code>), the result is a simple insert, if
+ * there are no children to add (<code>view == null</code>) the result
+ * is a simple removal.
+ *
+ * @param offset the start offset from where to remove children
+ * @param length the number of children to remove
+ * @param views the views that replace the removed children
+ */
+ public void replace(int offset, int length, View[] views)
+ {
+ // Check for null views to add.
+ for (int i = 0; i < views.length; ++i)
+ if (views[i] == null)
+ throw new NullPointerException("Added views must not be null");
+
+ int endOffset = offset + length;
+
+ // First we set the parent of the removed children to null.
+ for (int i = offset; i < endOffset; ++i)
+ children[i].setParent(null);
+
+ View[] newChildren = new View[children.length - length + views.length];
+ System.arraycopy(children, 0, newChildren, 0, offset);
+ System.arraycopy(views, 0, newChildren, offset, views.length);
+ System.arraycopy(children, offset + length, newChildren,
+ offset + views.length,
+ children.length - (offset + length));
+ children = newChildren;
+
+ // Finally we set the parent of the added children to this.
+ for (int i = 0; i < views.length; ++i)
+ views[i].setParent(this);
+ }
+
+ /**
+ * Returns the allocation for the specified child <code>View</code>.
+ *
+ * @param index the index of the child view
+ * @param a the allocation for this view
+ *
+ * @return the allocation for the specified child <code>View</code>
+ */
+ public Shape getChildAllocation(int index, Shape a)
+ {
+ Rectangle r = getInsideAllocation(a);
+ childAllocation(index, r);
+ return r;
+ }
+
+ /**
+ * Maps a position in the document into the coordinate space of the View.
+ * The output rectangle usually reflects the font height but has a width
+ * of zero.
+ *
+ * @param pos the position of the character in the model
+ * @param a the area that is occupied by the view
+ * @param bias either {@link Position.Bias#Forward} or
+ * {@link Position.Bias#Backward} depending on the preferred
+ * direction bias. If <code>null</code> this defaults to
+ * <code>Position.Bias.Forward</code>
+ *
+ * @return a rectangle that gives the location of the document position
+ * inside the view coordinate space
+ *
+ * @throws BadLocationException if <code>pos</code> is invalid
+ * @throws IllegalArgumentException if b is not one of the above listed
+ * valid values
+ */
+ public Shape modelToView(int pos, Shape a, Position.Bias bias)
+ throws BadLocationException
+ {
+ int childIndex = getViewIndex(pos, bias);
+ if (childIndex != -1)
+ {
+ View child = getView(childIndex);
+ Shape result = child.modelToView(pos, a, bias);
+ if (result == null)
+ throw new AssertionError("" + child.getClass().getName()
+ + ".modelToView() must not return null");
+ return result;
+ }
+ else
+ {
+ // FIXME: Handle the case when we have no child view for the given
+ // position.
+ throw new AssertionError("No child views found where child views are "
+ + "expected. pos = " + pos + ", bias = "
+ + bias);
+ }
+ }
+
+ /**
+ * Maps a region in the document into the coordinate space of the View.
+ *
+ * @param p1 the beginning position inside the document
+ * @param b1 the direction bias for the beginning position
+ * @param p2 the end position inside the document
+ * @param b2 the direction bias for the end position
+ * @param a the area that is occupied by the view
+ *
+ * @return a rectangle that gives the span of the document region
+ * inside the view coordinate space
+ *
+ * @throws BadLocationException if <code>p1</code> or <code>p2</code> are
+ * invalid
+ * @throws IllegalArgumentException if b1 or b2 is not one of the above
+ * listed valid values
+ */
+ public Shape modelToView(int p1, Position.Bias b1,
+ int p2, Position.Bias b2, Shape a)
+ throws BadLocationException
+ {
+ // TODO: This is most likely not 100% ok, figure out what else is to
+ // do here.
+ return super.modelToView(p1, b1, p2, b2, a);
+ }
+
+ /**
+ * Maps coordinates from the <code>View</code>'s space into a position
+ * in the document model.
+ *
+ * @param x the x coordinate in the view space
+ * @param y the y coordinate in the view space
+ * @param a the allocation of this <code>View</code>
+ * @param b the bias to use
+ *
+ * @return the position in the document that corresponds to the screen
+ * coordinates <code>x, y</code>
+ */
+ public int viewToModel(float x, float y, Shape a, Position.Bias[] b)
+ {
+ Rectangle r = getInsideAllocation(a);
+ View view = getViewAtPoint((int) x, (int) y, r);
+ return view.viewToModel(x, y, a, b);
+ }
+
+ /**
+ * Returns the next model location that is visible in eiter north / south
+ * direction or east / west direction. This is used to determine the
+ * placement of the caret when navigating around the document with
+ * the arrow keys.
+ *
+ * This is a convenience method for
+ * {@link #getNextNorthSouthVisualPositionFrom} and
+ * {@link #getNextEastWestVisualPositionFrom}.
+ *
+ * @param pos the model position to start search from
+ * @param b the bias for <code>pos</code>
+ * @param a the allocated region for this view
+ * @param direction the direction from the current position, can be one of
+ * the following:
+ * <ul>
+ * <li>{@link SwingConstants#WEST}</li>
+ * <li>{@link SwingConstants#EAST}</li>
+ * <li>{@link SwingConstants#NORTH}</li>
+ * <li>{@link SwingConstants#SOUTH}</li>
+ * </ul>
+ * @param biasRet the bias of the return value gets stored here
+ *
+ * @return the position inside the model that represents the next visual
+ * location
+ *
+ * @throws BadLocationException if <code>pos</code> is not a valid location
+ * inside the document model
+ * @throws IllegalArgumentException if <code>direction</code> is invalid
+ */
+ public int getNextVisualPositionFrom(int pos, Position.Bias b, Shape a,
+ int direction, Position.Bias[] biasRet)
+ {
+ int retVal = -1;
+ switch (direction)
+ {
+ case SwingConstants.WEST:
+ case SwingConstants.EAST:
+ retVal = getNextEastWestVisualPositionFrom(pos, b, a, direction,
+ biasRet);
+ break;
+ case SwingConstants.NORTH:
+ case SwingConstants.SOUTH:
+ retVal = getNextNorthSouthVisualPositionFrom(pos, b, a, direction,
+ biasRet);
+ break;
+ default:
+ throw new IllegalArgumentException("Illegal value for direction.");
+ }
+ return retVal;
+ }
+
+ /**
+ * Returns the index of the child view that represents the specified
+ * model location.
+ *
+ * @param pos the model location for which to determine the child view index
+ * @param b the bias to be applied to <code>pos</code>
+ *
+ * @return the index of the child view that represents the specified
+ * model location
+ */
+ public int getViewIndex(int pos, Position.Bias b)
+ {
+ // FIXME: Handle bias somehow.
+ return getViewIndexAtPosition(pos);
+ }
+
+ /**
+ * Returns <code>true</code> if the specified point lies before the
+ * given <code>Rectangle</code>, <code>false</code> otherwise.
+ *
+ * "Before" is typically defined as being to the left or above.
+ *
+ * @param x the X coordinate of the point
+ * @param y the Y coordinate of the point
+ * @param r the rectangle to test the point against
+ *
+ * @return <code>true</code> if the specified point lies before the
+ * given <code>Rectangle</code>, <code>false</code> otherwise
+ */
+ protected abstract boolean isBefore(int x, int y, Rectangle r);
+
+ /**
+ * Returns <code>true</code> if the specified point lies after the
+ * given <code>Rectangle</code>, <code>false</code> otherwise.
+ *
+ * "After" is typically defined as being to the right or below.
+ *
+ * @param x the X coordinate of the point
+ * @param y the Y coordinate of the point
+ * @param r the rectangle to test the point against
+ *
+ * @return <code>true</code> if the specified point lies after the
+ * given <code>Rectangle</code>, <code>false</code> otherwise
+ */
+ protected abstract boolean isAfter(int x, int y, Rectangle r);
+
+ /**
+ * Returns the child <code>View</code> at the specified location.
+ *
+ * @param x the X coordinate
+ * @param y the Y coordinate
+ * @param r the inner allocation of this <code>BoxView</code> on entry,
+ * the allocation of the found child on exit
+ *
+ * @return the child <code>View</code> at the specified location
+ */
+ protected abstract View getViewAtPoint(int x, int y, Rectangle r);
+
+ /**
+ * Computes the allocation for a child <code>View</code>. The parameter
+ * <code>a</code> stores the allocation of this <code>CompositeView</code>
+ * and is then adjusted to hold the allocation of the child view.
+ *
+ * @param index the index of the child <code>View</code>
+ * @param a the allocation of this <code>CompositeView</code> before the
+ * call, the allocation of the child on exit
+ */
+ protected abstract void childAllocation(int index, Rectangle a);
+
+ /**
+ * Returns the child <code>View</code> that contains the given model
+ * position. The given <code>Rectangle</code> gives the parent's allocation
+ * and is changed to the child's allocation on exit.
+ *
+ * @param pos the model position to query the child <code>View</code> for
+ * @param a the parent allocation on entry and the child allocation on exit
+ *
+ * @return the child view at the given model position
+ */
+ protected View getViewAtPosition(int pos, Rectangle a)
+ {
+ int i = getViewIndexAtPosition(pos);
+ View view = children[i];
+ childAllocation(i, a);
+ return view;
+ }
+
+ /**
+ * Returns the index of the child <code>View</code> for the given model
+ * position.
+ *
+ * @param pos the model position for whicht the child <code>View</code> is
+ * queried
+ *
+ * @return the index of the child <code>View</code> for the given model
+ * position
+ */
+ protected int getViewIndexAtPosition(int pos)
+ {
+ // We have one child view allocated for each child element in
+ // loadChildren(), so this should work.
+ Element el = getElement();
+ int index = el.getElementIndex(pos);
+ return index;
+ }
+
+ /**
+ * Returns the allocation that is given to this <code>CompositeView</code>
+ * minus this <code>CompositeView</code>'s insets.
+ *
+ * Also this translates from an immutable allocation to a mutable allocation
+ * that is typically reused and further narrowed, like in
+ * {@link #childAllocation}.
+ *
+ * @param a the allocation given to this <code>CompositeView</code>
+ *
+ * @return the allocation that is given to this <code>CompositeView</code>
+ * minus this <code>CompositeView</code>'s insets or
+ * <code>null</code> if a was <code>null</code>
+ */
+ protected Rectangle getInsideAllocation(Shape a)
+ {
+ if (a == null)
+ return null;
+
+ Rectangle alloc = a.getBounds();
+ // Initialize the inside allocation rectangle. This is done inside
+ // a synchronized block in order to avoid multiple threads creating
+ // this instance simultanously.
+ Rectangle inside;
+ synchronized(this)
+ {
+ inside = insideAllocation;
+ if (inside == null)
+ {
+ inside = new Rectangle();
+ insideAllocation = inside;
+ }
+ }
+ inside.x = alloc.x - insets.left;
+ inside.y = alloc.y - insets.top;
+ inside.width = alloc.width - insets.left - insets.right;
+ inside.height = alloc.height - insets.top - insets.bottom;
+ return inside;
+ }
+
+ /**
+ * Sets the insets defined by attributes in <code>attributes</code>. This
+ * queries the attribute keys {@link StyleConstants#SpaceAbove},
+ * {@link StyleConstants#SpaceBelow}, {@link StyleConstants#LeftIndent} and
+ * {@link StyleConstants#RightIndent} and calls {@link #setInsets} to
+ * actually set the insets on this <code>CompositeView</code>.
+ *
+ * @param attributes the attributes from which to query the insets
+ */
+ protected void setParagraphInsets(AttributeSet attributes)
+ {
+ Float l = (Float) attributes.getAttribute(StyleConstants.LeftIndent);
+ short left = 0;
+ if (l != null)
+ left = l.shortValue();
+ Float r = (Float) attributes.getAttribute(StyleConstants.RightIndent);
+ short right = 0;
+ if (r != null)
+ right = r.shortValue();
+ Float t = (Float) attributes.getAttribute(StyleConstants.SpaceAbove);
+ short top = 0;
+ if (t != null)
+ top = t.shortValue();
+ Float b = (Float) attributes.getAttribute(StyleConstants.SpaceBelow);
+ short bottom = 0;
+ if (b != null)
+ bottom = b.shortValue();
+ setInsets(top, left, bottom, right);
+ }
+
+ /**
+ * Sets the insets of this <code>CompositeView</code>.
+ *
+ * @param top the top inset
+ * @param left the left inset
+ * @param bottom the bottom inset
+ * @param right the right inset
+ */
+ protected void setInsets(short top, short left, short bottom, short right)
+ {
+ insets.top = top;
+ insets.left = left;
+ insets.bottom = bottom;
+ insets.right = right;
+ }
+
+ /**
+ * Returns the left inset of this <code>CompositeView</code>.
+ *
+ * @return the left inset of this <code>CompositeView</code>
+ */
+ protected short getLeftInset()
+ {
+ return (short) insets.left;
+ }
+
+ /**
+ * Returns the right inset of this <code>CompositeView</code>.
+ *
+ * @return the right inset of this <code>CompositeView</code>
+ */
+ protected short getRightInset()
+ {
+ return (short) insets.right;
+ }
+
+ /**
+ * Returns the top inset of this <code>CompositeView</code>.
+ *
+ * @return the top inset of this <code>CompositeView</code>
+ */
+ protected short getTopInset()
+ {
+ return (short) insets.top;
+ }
+
+ /**
+ * Returns the bottom inset of this <code>CompositeView</code>.
+ *
+ * @return the bottom inset of this <code>CompositeView</code>
+ */
+ protected short getBottomInset()
+ {
+ return (short) insets.bottom;
+ }
+
+ /**
+ * Returns the next model location that is visible in north or south
+ * direction.
+ * This is used to determine the
+ * placement of the caret when navigating around the document with
+ * the arrow keys.
+ *
+ * @param pos the model position to start search from
+ * @param b the bias for <code>pos</code>
+ * @param a the allocated region for this view
+ * @param direction the direction from the current position, can be one of
+ * the following:
+ * <ul>
+ * <li>{@link SwingConstants#NORTH}</li>
+ * <li>{@link SwingConstants#SOUTH}</li>
+ * </ul>
+ * @param biasRet the bias of the return value gets stored here
+ *
+ * @return the position inside the model that represents the next visual
+ * location
+ *
+ * @throws BadLocationException if <code>pos</code> is not a valid location
+ * inside the document model
+ * @throws IllegalArgumentException if <code>direction</code> is invalid
+ */
+ protected int getNextNorthSouthVisualPositionFrom(int pos, Position.Bias b,
+ Shape a, int direction,
+ Position.Bias[] biasRet)
+ {
+ // FIXME: Implement this correctly.
+ return pos;
+ }
+
+ /**
+ * Returns the next model location that is visible in east or west
+ * direction.
+ * This is used to determine the
+ * placement of the caret when navigating around the document with
+ * the arrow keys.
+ *
+ * @param pos the model position to start search from
+ * @param b the bias for <code>pos</code>
+ * @param a the allocated region for this view
+ * @param direction the direction from the current position, can be one of
+ * the following:
+ * <ul>
+ * <li>{@link SwingConstants#EAST}</li>
+ * <li>{@link SwingConstants#WEST}</li>
+ * </ul>
+ * @param biasRet the bias of the return value gets stored here
+ *
+ * @return the position inside the model that represents the next visual
+ * location
+ *
+ * @throws BadLocationException if <code>pos</code> is not a valid location
+ * inside the document model
+ * @throws IllegalArgumentException if <code>direction</code> is invalid
+ */
+ protected int getNextEastWestVisualPositionFrom(int pos, Position.Bias b,
+ Shape a, int direction,
+ Position.Bias[] biasRet)
+ {
+ // FIXME: Implement this correctly.
+ return pos;
+ }
+
+ /**
+ * Determines if the next view in horinzontal direction is located to
+ * the east or west of the view at position <code>pos</code>. Usually
+ * the <code>View</code>s are laid out from the east to the west, so
+ * we unconditionally return <code>false</code> here. Subclasses that
+ * support bidirectional text may wish to override this method.
+ *
+ * @param pos the position in the document
+ * @param bias the bias to be applied to <code>pos</code>
+ *
+ * @return <code>true</code> if the next <code>View</code> is located
+ * to the EAST, <code>false</code> otherwise
+ */
+ protected boolean flipEastAndWestAtEnds(int pos, Position.Bias bias)
+ {
+ return false;
+ }
+}
--- /dev/null
+/* ElementIterator.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., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 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 javax.swing.text;
+
+/**
+ * This class can be used to iterate over the {@link Element} tree of
+ * a {@link Document} or an {@link Element}. This iterator performs
+ * an "in-order" traversal -- first it visits a node, then each of the
+ * node's children in order. No locking is performed during the
+ * iteration; that is up to the caller.
+ */
+public class ElementIterator implements Cloneable
+{
+ // The root element.
+ private Element root;
+ // The current element.
+ private Element currentElement;
+ // The depth to which we have descended in the tree.
+ private int currentDepth;
+
+ // This is at least as big as the current depth, and at index N
+ // contains the index of the child element we're currently
+ // examining.
+ private int[] state;
+
+ // The previous item.
+ private Element previousItem;
+
+ /**
+ * Create a new ElementIterator to iterate over the given document.
+ * @param document the Document over which we iterate
+ */
+ public ElementIterator(Document document)
+ {
+ this.root = document.getDefaultRootElement();
+ this.currentElement = root;
+ this.state = new int[5];
+ }
+
+ /**
+ * Create a new ElementIterator to iterate over the given document.
+ * @param root the Document over which we iterate
+ */
+ public ElementIterator(Element root)
+ {
+ this.root = root;
+ this.currentElement = root;
+ this.state = new int[5];
+ }
+
+ /**
+ * Returns a new ElementIterator which is a clone of this
+ * ElementIterator.
+ */
+ public Object clone()
+ {
+ try
+ {
+ return super.clone();
+ }
+ catch (CloneNotSupportedException _)
+ {
+ // Can't happen.
+ return null;
+ }
+ }
+
+ /**
+ * Returns the current element.
+ */
+ public Element current()
+ {
+ return currentElement;
+ }
+
+ /**
+ * Returns the depth to which we have descended in the tree.
+ */
+ public int depth()
+ {
+ return currentDepth;
+ }
+
+ /**
+ * Returns the first element in the tree.
+ */
+ public Element first()
+ {
+ // Reset the iterator.
+ currentElement = root;
+ currentDepth = 0;
+ previousItem = null;
+ return root;
+ }
+
+ /**
+ * Advance the iterator and return the next element of the tree,
+ * performing an "in-order" traversal.
+ */
+ public Element next()
+ {
+ previousItem = currentElement;
+ if (currentElement == null)
+ return null;
+ if (! currentElement.isLeaf())
+ {
+ ++currentDepth;
+ if (currentDepth > state.length)
+ {
+ int[] newState = new int[state.length * 2];
+ System.arraycopy(state, 0, newState, 0, state.length);
+ state = newState;
+ }
+ state[currentDepth] = 0;
+ currentElement = currentElement.getElement(0);
+ return currentElement;
+ }
+
+ while (currentDepth > 0)
+ {
+ // At a leaf, or done with a non-leaf's children, so go up a
+ // level.
+ --currentDepth;
+ currentElement = currentElement.getParentElement();
+ ++state[currentDepth];
+ if (state[currentDepth] < currentElement.getElementCount())
+ {
+ currentElement = currentElement.getElement(state[currentDepth]);
+ return currentElement;
+ }
+ }
+
+ currentElement = null;
+ return currentElement;
+ }
+
+ /**
+ * Returns the previous item. Does not modify the iterator state.
+ */
+ public Element previous()
+ {
+ if (currentElement == null || currentElement == root)
+ return null;
+ return previousItem;
+ }
+}
--- /dev/null
+/* FlowView.java -- A composite View
+ 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., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 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 javax.swing.text;
+
+import java.awt.Container;
+import java.awt.Graphics;
+import java.awt.Rectangle;
+import java.awt.Shape;
+import java.util.Vector;
+
+import javax.swing.event.DocumentEvent;
+
+/**
+ * A <code>View</code> that can flows it's children into it's layout space.
+ *
+ * The <code>FlowView</code> manages a set of logical views (that are
+ * the children of the {@link #layoutPool} field). These are translated
+ * at layout time into a set of physical views. These are the views that
+ * are managed as the real child views. Each of these child views represents
+ * a row and are laid out within a box using the superclasses behaviour.
+ * The concrete implementation of the rows must be provided by subclasses.
+ *
+ * @author Roman Kennke (roman@kennke.org)
+ */
+public abstract class FlowView extends BoxView
+{
+ /**
+ * A strategy for translating the logical views of a <code>FlowView</code>
+ * into the real views.
+ */
+ public static class FlowStrategy
+ {
+ /**
+ * Creates a new instance of <code>FlowStragegy</code>.
+ */
+ public FlowStrategy()
+ {
+ }
+
+ /**
+ * Receives notification from a <code>FlowView</code> that some content
+ * has been inserted into the document at a location that the
+ * <code>FlowView</code> is responsible for.
+ *
+ * The default implementation simply calls {@link #layout}.
+ *
+ * @param fv the flow view that sends the notification
+ * @param e the document event describing the change
+ * @param alloc the current allocation of the flow view
+ */
+ public void insertUpdate(FlowView fv, DocumentEvent e, Rectangle alloc)
+ {
+ layout(fv);
+ }
+
+ /**
+ * Receives notification from a <code>FlowView</code> that some content
+ * has been removed from the document at a location that the
+ * <code>FlowView</code> is responsible for.
+ *
+ * The default implementation simply calls {@link #layout}.
+ *
+ * @param fv the flow view that sends the notification
+ * @param e the document event describing the change
+ * @param alloc the current allocation of the flow view
+ */
+ public void removeUpdate(FlowView fv, DocumentEvent e, Rectangle alloc)
+ {
+ layout(fv);
+ }
+
+ /**
+ * Receives notification from a <code>FlowView</code> that some attributes
+ * have changed in the document at a location that the
+ * <code>FlowView</code> is responsible for.
+ *
+ * The default implementation simply calls {@link #layout}.
+ *
+ * @param fv the flow view that sends the notification
+ * @param e the document event describing the change
+ * @param alloc the current allocation of the flow view
+ */
+ public void changedUpdate(FlowView fv, DocumentEvent e, Rectangle alloc)
+ {
+ layout(fv);
+ }
+
+ /**
+ * Returns the logical view of the managed <code>FlowView</code>.
+ *
+ * @param fv the flow view for which to return the logical view
+ *
+ * @return the logical view of the managed <code>FlowView</code>
+ */
+ public View getLogicalView(FlowView fv)
+ {
+ return fv.layoutPool;
+ }
+
+ /**
+ * Performs the layout for the whole view. By default this rebuilds
+ * all the physical views from the logical views of the managed FlowView.
+ *
+ * This is called by {@link FlowLayout#layout} to update the layout of
+ * the view.
+ *
+ * @param fv the flow view for which we perform the layout
+ */
+ public void layout(FlowView fv)
+ {
+ fv.removeAll();
+ Element el = fv.getElement();
+
+ int rowStart = el.getStartOffset();
+ int end = el.getEndOffset();
+ int rowIndex = 0;
+ while (rowStart >= 0 && rowStart < end)
+ {
+ View row = fv.createRow();
+ fv.append(row);
+ rowStart = layoutRow(fv, rowIndex, rowStart);
+ rowIndex++;
+ }
+ }
+
+ /**
+ * Lays out one row of the flow view. This is called by {@link #layout}
+ * to fill one row with child views until the available span is exhausted.
+ *
+ * @param fv the flow view for which we perform the layout
+ * @param rowIndex the index of the row
+ * @param pos the start position for the row
+ *
+ * @return the start position of the next row
+ */
+ protected int layoutRow(FlowView fv, int rowIndex, int pos)
+ {
+ int spanLeft = fv.getFlowSpan(rowIndex);
+ if (spanLeft <= 0)
+ return -1;
+
+ int offset = pos;
+ View row = fv.getView(rowIndex);
+ int flowAxis = fv.getFlowAxis();
+
+ while (spanLeft > 0)
+ {
+ View child = createView(fv, offset, spanLeft, rowIndex);
+ if (child == null)
+ break;
+
+ int span = (int) child.getPreferredSpan(flowAxis);
+ if (span > spanLeft)
+ break;
+
+ row.append(child);
+ spanLeft -= span;
+ offset = child.getEndOffset();
+ }
+ return offset;
+ }
+
+ /**
+ * Creates physical views that form the rows of the flow view. This
+ * can be an entire view from the logical view (if it fits within the
+ * available span), a fragment of such a view (if it doesn't fit in the
+ * available span and can be broken down) or <code>null</code> (if it does
+ * not fit in the available span and also cannot be broken down).
+ *
+ * @param fv the flow view
+ * @param startOffset the start offset for the view to be created
+ * @param spanLeft the available span
+ * @param rowIndex the index of the row
+ *
+ * @return a view to fill the row with, or <code>null</code> if there
+ * is no view or view fragment that fits in the available span
+ */
+ protected View createView(FlowView fv, int offset, int spanLeft,
+ int rowIndex)
+ {
+ // Find the logical element for the given offset.
+ View logicalView = getLogicalView(fv);
+
+ int viewIndex = logicalView.getViewIndex(offset, Position.Bias.Forward);
+ View child = logicalView.getView(viewIndex);
+ int flowAxis = fv.getFlowAxis();
+ int span = (int) child.getPreferredSpan(flowAxis);
+
+ if (span <= spanLeft)
+ return child;
+
+ else if (child.getBreakWeight(flowAxis, offset, spanLeft)
+ > BadBreakWeight)
+ // FIXME: What to do with the pos parameter here?
+ return child.breakView(flowAxis, offset, 0, spanLeft);
+ else
+ return null;
+ }
+ }
+
+ /**
+ * This special subclass of <code>View</code> is used to represent
+ * the logical representation of this view. It does not support any
+ * visual representation, this is handled by the physical view implemented
+ * in the <code>FlowView</code>.
+ */
+ class LogicalView extends View
+ {
+ /**
+ * The child views of this logical view.
+ */
+ Vector children;
+
+ /**
+ * Creates a new LogicalView instance.
+ */
+ LogicalView(Element el)
+ {
+ super(el);
+ children = new Vector();
+ }
+
+ /**
+ * Returns the container that holds this view. The logical view returns
+ * the enclosing FlowView's container here.
+ *
+ * @return the container that holds this view
+ */
+ public Container getContainer()
+ {
+ return FlowView.this.getContainer();
+ }
+
+ /**
+ * Returns the number of child views of this logical view.
+ *
+ * @return the number of child views of this logical view
+ */
+ public int getViewCount()
+ {
+ return children.size();
+ }
+
+ /**
+ * Returns the child view at the specified index.
+ *
+ * @param index the index
+ *
+ * @return the child view at the specified index
+ */
+ public View getView(int index)
+ {
+ return (View) children.get(index);
+ }
+
+ /**
+ * Replaces some child views with other child views.
+ *
+ * @param offset the offset at which to replace child views
+ * @param length the number of children to remove
+ * @param views the views to be inserted
+ */
+ public void replace(int offset, int length, View[] views)
+ {
+ if (length > 0)
+ {
+ for (int count = 0; count < length; ++count)
+ children.remove(offset);
+ }
+
+ int endOffset = offset + views.length;
+ for (int i = offset; i < endOffset; ++i)
+ {
+ children.add(i, views[i - offset]);
+ // Set the parent of the child views to the flow view itself so
+ // it has something to resolve.
+ views[i - offset].setParent(FlowView.this);
+ }
+ }
+
+ /**
+ * Returns the index of the child view that contains the specified
+ * position in the document model.
+ *
+ * @param pos the position for which we are searching the child view
+ * @param b the bias
+ *
+ * @return the index of the child view that contains the specified
+ * position in the document model
+ */
+ public int getViewIndex(int pos, Position.Bias b)
+ {
+ return getElement().getElementIndex(pos);
+ }
+
+ /**
+ * Throws an AssertionError because it must never be called. LogicalView
+ * only serves as a holder for child views and has no visual
+ * representation.
+ */
+ public float getPreferredSpan(int axis)
+ {
+ throw new AssertionError("This method must not be called in "
+ + "LogicalView.");
+ }
+
+ /**
+ * Throws an AssertionError because it must never be called. LogicalView
+ * only serves as a holder for child views and has no visual
+ * representation.
+ */
+ public Shape modelToView(int pos, Shape a, Position.Bias b)
+ throws BadLocationException
+ {
+ throw new AssertionError("This method must not be called in "
+ + "LogicalView.");
+ }
+
+ /**
+ * Throws an AssertionError because it must never be called. LogicalView
+ * only serves as a holder for child views and has no visual
+ * representation.
+ */
+ public void paint(Graphics g, Shape s)
+ {
+ throw new AssertionError("This method must not be called in "
+ + "LogicalView.");
+ }
+
+ /**
+ * Throws an AssertionError because it must never be called. LogicalView
+ * only serves as a holder for child views and has no visual
+ * representation.
+ */
+ public int viewToModel(float x, float y, Shape a, Position.Bias[] b)
+ {
+ throw new AssertionError("This method must not be called in "
+ + "LogicalView.");
+ }
+ }
+
+ /**
+ * The shared instance of FlowStrategy.
+ */
+ static final FlowStrategy sharedStrategy = new FlowStrategy();
+
+ /**
+ * The span of the <code>FlowView</code> that should be flowed.
+ */
+ protected int layoutSpan;
+
+ /**
+ * Represents the logical child elements of this view, encapsulated within
+ * one parent view (an instance of a package private <code>LogicalView</code>
+ * class). These will be translated to a set of real views that are then
+ * displayed on screen. This translation is performed by the inner class
+ * {@link FlowStrategy}.
+ */
+ protected View layoutPool;
+
+ /**
+ * The <code>FlowStrategy</code> to use for translating between the
+ * logical and physical view.
+ */
+ protected FlowStrategy strategy;
+
+ /**
+ * Creates a new <code>FlowView</code> for the given
+ * <code>Element</code> and <code>axis</code>.
+ *
+ * @param element the element that is rendered by this FlowView
+ * @param axis the axis along which the view is tiled, either
+ * <code>View.X_AXIS</code> or <code>View.Y_AXIS</code>, the flow
+ * axis is orthogonal to this one
+ */
+ public FlowView(Element element, int axis)
+ {
+ super(element, axis);
+ strategy = sharedStrategy;
+ }
+
+ /**
+ * Returns the axis along which the view should be flowed. This is
+ * orthogonal to the axis along which the boxes are tiled.
+ *
+ * @return the axis along which the view should be flowed
+ */
+ public int getFlowAxis()
+ {
+ int axis = getAxis();
+ int flowAxis;
+
+ if (axis == X_AXIS)
+ flowAxis = Y_AXIS;
+ else
+ flowAxis = X_AXIS;
+
+ return flowAxis;
+
+ }
+
+ /**
+ * Returns the span of the flow for the specified child view. A flow
+ * layout can be shaped by providing different span values for different
+ * child indices. The default implementation returns the entire available
+ * span inside the view.
+ *
+ * @param index the index of the child for which to return the span
+ *
+ * @return the span of the flow for the specified child view
+ */
+ public int getFlowSpan(int index)
+ {
+ return layoutSpan;
+ }
+
+ /**
+ * Returns the location along the flow axis where the flow span starts
+ * given a child view index. The flow can be shaped by providing
+ * different values here.
+ *
+ * @param index the index of the child for which to return the flow location
+ *
+ * @return the location along the flow axis where the flow span starts
+ */
+ public int getFlowStart(int index)
+ {
+ return getLeftInset(); // TODO: Is this correct?
+ }
+
+ /**
+ * Creates a new view that represents a row within a flow.
+ *
+ * @return a view for a new row
+ */
+ protected abstract View createRow();
+
+ /**
+ * Loads the children of this view. The <code>FlowView</code> does not
+ * directly load its children. Instead it creates a logical view
+ * (@{link #layoutPool}) which is filled by the logical child views.
+ * The real children are created at layout time and each represent one
+ * row.
+ *
+ * This method is called by {@link #setParent} in order to initialize
+ * the view.
+ *
+ * @param vf the view factory to use for creating the child views
+ */
+ protected void loadChildren(ViewFactory vf)
+ {
+ if (layoutPool == null)
+ {
+ layoutPool = new LogicalView(getElement());
+
+ Element el = getElement();
+ int count = el.getElementCount();
+ for (int i = 0; i < count; ++i)
+ {
+ Element childEl = el.getElement(i);
+ View childView = vf.create(childEl);
+ layoutPool.append(childView);
+ }
+ }
+ }
+
+ /**
+ * Performs the layout of this view. If the span along the flow axis changed,
+ * this first calls {@link FlowStrategy.layout} in order to rebuild the
+ * rows of this view. Then the superclass's behaviour is called to arrange
+ * the rows within the box.
+ *
+ * @param width the width of the view
+ * @param height the height of the view
+ */
+ protected void layout(int width, int height)
+ {
+ boolean rebuild = false;
+
+ int flowAxis = getFlowAxis();
+ if (flowAxis == X_AXIS)
+ {
+ rebuild = !(width == layoutSpan);
+ layoutSpan = width;
+ }
+ else
+ {
+ rebuild = !(height == layoutSpan);
+ layoutSpan = height;
+ }
+
+ if (rebuild)
+ strategy.layout(this);
+
+ // TODO: If the span along the box axis has changed in the process of
+ // relayouting the rows (that is, if rows have been added or removed),
+ // call preferenceChanged in order to throw away cached layout information
+ // of the surrounding BoxView.
+
+ super.layout(width, height);
+ }
+
+ /**
+ * Receice notification that some content has been inserted in the region
+ * that this view is responsible for. This calls
+ * {@link FlowStrategy#insertUpdate}.
+ *
+ * @param changes the document event describing the changes
+ * @param a the current allocation of the view
+ * @param vf the view factory that is used for creating new child views
+ */
+ public void insertUpdate(DocumentEvent changes, Shape a, ViewFactory vf)
+ {
+ strategy.insertUpdate(this, changes, getInsideAllocation(a));
+ }
+
+ /**
+ * Receice notification that some content has been removed from the region
+ * that this view is responsible for. This calls
+ * {@link FlowStrategy#removeUpdate}.
+ *
+ * @param changes the document event describing the changes
+ * @param a the current allocation of the view
+ * @param vf the view factory that is used for creating new child views
+ */
+ public void removeUpdate(DocumentEvent changes, Shape a, ViewFactory vf)
+ {
+ strategy.removeUpdate(this, changes, getInsideAllocation(a));
+ }
+
+ /**
+ * Receice notification that some attributes changed in the region
+ * that this view is responsible for. This calls
+ * {@link FlowStrategy#changedUpdate}.
+ *
+ * @param changes the document event describing the changes
+ * @param a the current allocation of the view
+ * @param vf the view factory that is used for creating new child views
+ */
+ public void changedUpdate(DocumentEvent changes, Shape a, ViewFactory vf)
+ {
+ strategy.changedUpdate(this, changes, getInsideAllocation(a));
+ }
+
+ /**
+ * Returns the index of the child <code>View</code> for the given model
+ * position.
+ *
+ * This is implemented to iterate over the children of this
+ * view (the rows) and return the index of the first view that contains
+ * the given position.
+ *
+ * @param pos the model position for whicht the child <code>View</code> is
+ * queried
+ *
+ * @return the index of the child <code>View</code> for the given model
+ * position
+ */
+ protected int getViewIndexAtPosition(int pos)
+ {
+ // First make sure we have a valid layout.
+ if (!isAllocationValid())
+ layout(getWidth(), getHeight());
+
+ int count = getViewCount();
+ int result = -1;
+
+ for (int i = 0; i < count; ++i)
+ {
+ View child = getView(i);
+ int start = child.getStartOffset();
+ int end = child.getEndOffset();
+ if (start <= pos && end > pos)
+ {
+ result = i;
+ break;
+ }
+ }
+ return result;
+ }
+}
--- /dev/null
+/* GlyphView.java -- A view to render styled text
+ 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., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 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 javax.swing.text;
+
+import java.awt.Color;
+import java.awt.Font;
+import java.awt.FontMetrics;
+import java.awt.Graphics;
+import java.awt.Rectangle;
+import java.awt.Shape;
+
+/**
+ * Renders a run of styled text. This {@link View} subclass paints the
+ * characters of the <code>Element</code> it is responsible for using
+ * the style information from that <code>Element</code>.
+ *
+ * @author Roman Kennke (roman@kennke.org)
+ */
+public class GlyphView
+ extends View
+ implements TabableView, Cloneable
+{
+
+ /**
+ * An abstract base implementation for a glyph painter for
+ * <code>GlyphView</code>.
+ */
+ public abstract static class GlyphPainter
+ {
+ /**
+ * Creates a new <code>GlyphPainer</code>.
+ */
+ public GlyphPainter()
+ {
+ }
+
+ /**
+ * Returns the full height of the rendered text.
+ *
+ * @return the full height of the rendered text
+ */
+ public abstract float getHeight(GlyphView view);
+
+ /**
+ * Paints the glyphs.
+ *
+ * @param view the glyph view to paint
+ * @param g the graphics context to use for painting
+ * @param a the allocation of the glyph view
+ * @param p0 the start position (in the model) from which to paint
+ * @param p1 the end position (in the model) to which to paint
+ */
+ public abstract void paint(GlyphView view, Graphics g, Shape a, int p0,
+ int p1);
+
+ /**
+ * Maps a position in the document into the coordinate space of the View.
+ * The output rectangle usually reflects the font height but has a width
+ * of zero.
+ *
+ * @param view the glyph view
+ * @param pos the position of the character in the model
+ * @param a the area that is occupied by the view
+ * @param bias either {@link Position.Bias.Forward} or
+ * {@link Position.Bias.Backward} depending on the preferred
+ * direction bias. If <code>null</code> this defaults to
+ * <code>Position.Bias.Forward</code>
+ *
+ * @return a rectangle that gives the location of the document position
+ * inside the view coordinate space
+ *
+ * @throws BadLocationException if <code>pos</code> is invalid
+ * @throws IllegalArgumentException if b is not one of the above listed
+ * valid values
+ */
+ public abstract Shape modelToView(GlyphView view, int pos, Position.Bias b,
+ Shape a)
+ throws BadLocationException;
+
+ /**
+ * Determine the span of the glyphs from location <code>p0</code> to
+ * location <code>p1</code>. If <code>te</code> is not <code>null</code>,
+ * then TABs are expanded using this <code>TabExpander</code>.
+ * The parameter <code>x</code> is the location at which the view is
+ * located (this is important when using TAB expansion).
+ *
+ * @param view the glyph view
+ * @param p0 the starting location in the document model
+ * @param p0 the end location in the document model
+ * @param te the tab expander to use
+ * @param x the location at which the view is located
+ *
+ * @return the span of the glyphs from location <code>p0</code> to
+ * location <code>p1</code>, possibly using TAB expansion
+ */
+ public abstract float getSpan(GlyphView view, int p0, int p1,
+ TabExpander te, float x);
+
+ }
+
+ /**
+ * The default <code>GlyphPainter</code> used in <code>GlyphView</code>.
+ */
+ static class DefaultGlyphPainter extends GlyphPainter
+ {
+ /**
+ * Returns the full height of the rendered text.
+ *
+ * @return the full height of the rendered text
+ */
+ public float getHeight(GlyphView view)
+ {
+ Font font = view.getFont();
+ FontMetrics metrics = view.getContainer().getFontMetrics(font);
+ float height = metrics.getHeight();
+ return height;
+ }
+
+ /**
+ * Paints the glyphs.
+ *
+ * @param view the glyph view to paint
+ * @param g the graphics context to use for painting
+ * @param a the allocation of the glyph view
+ * @param p0 the start position (in the model) from which to paint
+ * @param p1 the end position (in the model) to which to paint
+ */
+ public void paint(GlyphView view, Graphics g, Shape a, int p0,
+ int p1)
+ {
+ int height = (int) getHeight(view);
+ Segment txt = view.getText(p0, p1);
+ Rectangle bounds = a.getBounds();
+
+ TabExpander tabEx = null;
+ View parent = view.getParent();
+ if (parent instanceof TabExpander)
+ tabEx = (TabExpander) parent;
+
+ // FIXME: Set character attributes like font-family, font-size, colors.
+ Color foreground = view.getForeground();
+ g.setColor(foreground);
+ Utilities.drawTabbedText(txt, bounds.x, bounds.y, g, tabEx,
+ txt.offset);
+ }
+
+ /**
+ * Maps a position in the document into the coordinate space of the View.
+ * The output rectangle usually reflects the font height but has a width
+ * of zero.
+ *
+ * @param view the glyph view
+ * @param pos the position of the character in the model
+ * @param a the area that is occupied by the view
+ * @param bias either {@link Position.Bias.Forward} or
+ * {@link Position.Bias.Backward} depending on the preferred
+ * direction bias. If <code>null</code> this defaults to
+ * <code>Position.Bias.Forward</code>
+ *
+ * @return a rectangle that gives the location of the document position
+ * inside the view coordinate space
+ *
+ * @throws BadLocationException if <code>pos</code> is invalid
+ * @throws IllegalArgumentException if b is not one of the above listed
+ * valid values
+ */
+ public Shape modelToView(GlyphView view, int pos, Position.Bias b,
+ Shape a)
+ throws BadLocationException
+ {
+ Element el = view.getElement();
+ Font font = view.getFont();
+ FontMetrics fm = view.getContainer().getFontMetrics(font);
+ Segment txt = view.getText(el.getStartOffset(), pos);
+ int width = fm.charsWidth(txt.array, txt.offset, txt.count);
+ int height = fm.getHeight();
+ Rectangle bounds = a.getBounds();
+ Rectangle result = new Rectangle(bounds.x + width, bounds.y,
+ bounds.x + width, height);
+ return result;
+ }
+
+ /**
+ * Determine the span of the glyphs from location <code>p0</code> to
+ * location <code>p1</code>. If <code>te</code> is not <code>null</code>,
+ * then TABs are expanded using this <code>TabExpander</code>.
+ * The parameter <code>x</code> is the location at which the view is
+ * located (this is important when using TAB expansion).
+ *
+ * @param view the glyph view
+ * @param p0 the starting location in the document model
+ * @param p0 the end location in the document model
+ * @param te the tab expander to use
+ * @param x the location at which the view is located
+ *
+ * @return the span of the glyphs from location <code>p0</code> to
+ * location <code>p1</code>, possibly using TAB expansion
+ */
+ public float getSpan(GlyphView view, int p0, int p1,
+ TabExpander te, float x)
+ {
+ Element el = view.getElement();
+ Font font = view.getFont();
+ FontMetrics fm = view.getContainer().getFontMetrics(font);
+ Segment txt = view.getText(p0, p1);
+ int span = Utilities.getTabbedTextWidth(txt, fm, (int) x, te, p0);
+ return span;
+ }
+ }
+
+ /**
+ * The GlyphPainer used for painting the glyphs.
+ */
+ GlyphPainter glyphPainter;
+
+ /**
+ * Creates a new <code>GlyphView</code> for the given <code>Element</code>.
+ *
+ * @param element the element that is rendered by this GlyphView
+ */
+ public GlyphView(Element element)
+ {
+ super(element);
+ }
+
+ /**
+ * Returns the <code>GlyphPainter</code> that is used by this
+ * <code>GlyphView</code>. If no <code>GlyphPainer</code> has been installed
+ * <code>null</code> is returned.
+ *
+ * @return the glyph painter that is used by this
+ * glyph view or <code>null</code> if no glyph painter has been
+ * installed
+ */
+ public GlyphPainter getGlyphPainter()
+ {
+ return glyphPainter;
+ }
+
+ /**
+ * Sets the {@link GlyphPainter} to be used for this <code>GlyphView</code>.
+ *
+ * @param painter the glyph painter to be used for this glyph view
+ */
+ public void setGlyphPainter(GlyphPainter painter)
+ {
+ glyphPainter = painter;
+ }
+
+ /**
+ * Checks if a <code>GlyphPainer</code> is installed. If this is not the
+ * case, a default painter is installed.
+ */
+ protected void checkPainter()
+ {
+ if (glyphPainter == null)
+ glyphPainter = new DefaultGlyphPainter();
+ }
+
+ /**
+ * Renders the <code>Element</code> that is associated with this
+ * <code>View</code>.
+ *
+ * @param g the <code>Graphics</code> context to render to
+ * @param a the allocated region for the <code>Element</code>
+ */
+ public void paint(Graphics g, Shape a)
+ {
+ Element el = getElement();
+ checkPainter();
+ getGlyphPainter().paint(this, g, a, el.getStartOffset(),
+ el.getEndOffset());
+ }
+
+
+ /**
+ * Returns the preferred span of the content managed by this
+ * <code>View</code> along the specified <code>axis</code>.
+ *
+ * @param axis the axis
+ *
+ * @return the preferred span of this <code>View</code>.
+ */
+ public float getPreferredSpan(int axis)
+ {
+ Element el = getElement();
+ checkPainter();
+ GlyphPainter painter = getGlyphPainter();
+ TabExpander tabEx = null;
+ View parent = getParent();
+ if (parent instanceof TabExpander)
+ tabEx = (TabExpander) parent;
+ // FIXME: Figure out how to determine the x parameter.
+ float span = painter.getSpan(this, el.getStartOffset(), el.getEndOffset(),
+ tabEx, 0.F);
+ return span;
+ }
+
+ /**
+ * Maps a position in the document into the coordinate space of the View.
+ * The output rectangle usually reflects the font height but has a width
+ * of zero.
+ *
+ * @param pos the position of the character in the model
+ * @param a the area that is occupied by the view
+ * @param b either {@link Position.Bias#Forward} or
+ * {@link Position.Bias#Backward} depending on the preferred
+ * direction bias. If <code>null</code> this defaults to
+ * <code>Position.Bias.Forward</code>
+ *
+ * @return a rectangle that gives the location of the document position
+ * inside the view coordinate space
+ *
+ * @throws BadLocationException if <code>pos</code> is invalid
+ * @throws IllegalArgumentException if b is not one of the above listed
+ * valid values
+ */
+ public Shape modelToView(int pos, Shape a, Position.Bias b)
+ throws BadLocationException
+ {
+ GlyphPainter p = getGlyphPainter();
+ return p.modelToView(this, pos, b, a);
+ }
+
+ /**
+ * Maps coordinates from the <code>View</code>'s space into a position
+ * in the document model.
+ *
+ * @param x the x coordinate in the view space
+ * @param y the y coordinate in the view space
+ * @param a the allocation of this <code>View</code>
+ * @param b the bias to use
+ *
+ * @return the position in the document that corresponds to the screen
+ * coordinates <code>x, y</code>
+ */
+ public int viewToModel(float x, float y, Shape a, Position.Bias[] b)
+ {
+ // FIXME: not implemented
+ return 0;
+ }
+
+ /**
+ * Return the {@link TabExpander} to use.
+ *
+ * @return the {@link TabExpander} to use
+ */
+ public TabExpander getTabExpander()
+ {
+ // TODO: Figure out if this is correct.
+ TabExpander te = null;
+ View parent = getParent();
+
+ if (parent instanceof ParagraphView)
+ te = (ParagraphView) parent;
+
+ return te;
+ }
+
+ /**
+ * Returns the preferred span of this view for tab expansion.
+ *
+ * @param x the location of the view
+ * @param te the tab expander to use
+ *
+ * @return the preferred span of this view for tab expansion
+ */
+ public float getTabbedSpan(float x, TabExpander te)
+ {
+ Element el = getElement();
+ return getGlyphPainter().getSpan(this, el.getStartOffset(),
+ el.getEndOffset(), te, x);
+ }
+
+ /**
+ * Returns the span of a portion of the view. This is used in TAB expansion
+ * for fragments that don't contain TABs.
+ *
+ * @param p0 the start index
+ * @param p1 the end index
+ *
+ * @return the span of the specified portion of the view
+ */
+ public float getPartialSpan(int p0, int p1)
+ {
+ Element el = getElement();
+ Document doc = el.getDocument();
+ Segment seg = new Segment();
+ try
+ {
+ doc.getText(p0, p1 - p0, seg);
+ }
+ catch (BadLocationException ex)
+ {
+ throw new AssertionError("BadLocationException must not be thrown "
+ + "here");
+ }
+ FontMetrics fm = null; // Fetch font metrics somewhere.
+ return Utilities.getTabbedTextWidth(seg, fm, 0, null, p0);
+ }
+
+ /**
+ * Returns the starting offset in the document model of the portion
+ * of text that this view is responsible for.
+ *
+ * @return the starting offset in the document model of the portion
+ * of text that this view is responsible for
+ */
+ public int getBeginIndex()
+ {
+ return getElement().getStartOffset();
+ }
+
+ /**
+ * Returns the end offset in the document model of the portion
+ * of text that this view is responsible for.
+ *
+ * @return the end offset in the document model of the portion
+ * of text that this view is responsible for
+ */
+ public int getEndIndex()
+ {
+ return getElement().getEndOffset();
+ }
+
+ /**
+ * Returns the text segment that this view is responsible for.
+ *
+ * @param p0 the start index in the document model
+ * @param p1 the end index in the document model
+ *
+ * @return the text segment that this view is responsible for
+ */
+ public Segment getText(int p0, int p1)
+ {
+ Segment txt = new Segment();
+ try
+ {
+ getDocument().getText(p0, p1 - p0, txt);
+ }
+ catch (BadLocationException ex)
+ {
+ throw new AssertionError("BadLocationException should not be "
+ + "thrown here. p0 = " + p0 + ", p1 = " + p1);
+ }
+
+ return txt;
+ }
+
+ /**
+ * Returns the font for the text run for which this <code>GlyphView</code>
+ * is responsible.
+ *
+ * @return the font for the text run for which this <code>GlyphView</code>
+ * is responsible
+ */
+ public Font getFont()
+ {
+ Element el = getElement();
+ AttributeSet atts = el.getAttributes();
+ String family = StyleConstants.getFontFamily(atts);
+ int size = StyleConstants.getFontSize(atts);
+ int style = Font.PLAIN;
+ if (StyleConstants.isBold(atts))
+ style |= Font.BOLD;
+ if (StyleConstants.isItalic(atts))
+ style |= Font.ITALIC;
+ Font font = new Font(family, style, size);
+ return font;
+ }
+
+ /**
+ * Returns the foreground color which should be used to paint the text.
+ * This is fetched from the associated element's text attributes using
+ * {@link StyleConstants#getForeground}.
+ *
+ * @return the foreground color which should be used to paint the text
+ */
+ public Color getForeground()
+ {
+ Element el = getElement();
+ AttributeSet atts = el.getAttributes();
+ return StyleConstants.getForeground(atts);
+ }
+}
--- /dev/null
+/* IconView.java -- A view to render icons
+ 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., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 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 javax.swing.text;
+
+import java.awt.Graphics;
+import java.awt.Shape;
+
+// TODO: Implement this class.
+public class IconView
+ extends View
+{
+
+ /**
+ * Creates a new <code>IconView</code> for the given <code>Element</code>.
+ *
+ * @param element the element that is rendered by this IconView
+ */
+ public IconView(Element element)
+ {
+ super(element);
+ }
+
+ /**
+ * Renders the <code>Element</code> that is associated with this
+ * <code>View</code>.
+ *
+ * @param g the <code>Graphics</code> context to render to
+ * @param a the allocated region for the <code>Element</code>
+ */
+ public void paint(Graphics g, Shape a)
+ {
+ // TODO: Implement me.
+ }
+
+ /**
+ * Returns the preferred span of the content managed by this
+ * <code>View</code> along the specified <code>axis</code>.
+ *
+ * @param axis the axis
+ *
+ * @return the preferred span of this <code>View</code>.
+ */
+ public float getPreferredSpan(int axis)
+ {
+ // TODO: Implement me.
+ return 0F;
+ }
+
+ /**
+ * Maps a position in the document into the coordinate space of the View.
+ * The output rectangle usually reflects the font height but has a width
+ * of zero.
+ *
+ * @param pos the position of the character in the model
+ * @param a the area that is occupied by the view
+ * @param b either {@link Position.Bias#Forward} or
+ * {@link Position.Bias#Backward} depending on the preferred
+ * direction bias. If <code>null</code> this defaults to
+ * <code>Position.Bias.Forward</code>
+ *
+ * @return a rectangle that gives the location of the document position
+ * inside the view coordinate space
+ *
+ * @throws BadLocationException if <code>pos</code> is invalid
+ * @throws IllegalArgumentException if b is not one of the above listed
+ * valid values
+ */
+ public Shape modelToView(int pos, Shape a, Position.Bias b)
+ throws BadLocationException
+ {
+ // Implement me.
+ return null;
+ }
+
+ /**
+ * Maps coordinates from the <code>View</code>'s space into a position
+ * in the document model.
+ *
+ * @param x the x coordinate in the view space
+ * @param y the y coordinate in the view space
+ * @param a the allocation of this <code>View</code>
+ * @param b the bias to use
+ *
+ * @return the position in the document that corresponds to the screen
+ * coordinates <code>x, y</code>
+ */
+ public int viewToModel(float x, float y, Shape a, Position.Bias[] b)
+ {
+ // FIXME: not implemented
+ return 0;
+ }
+}
--- /dev/null
+/* LabelView.java -- A view to render styled text
+ 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., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 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 javax.swing.text;
+
+// TODO: Implement this class.
+public class LabelView
+ extends GlyphView
+{
+ /**
+ * Creates a new <code>GlyphView</code> for the given <code>Element</code>.
+ *
+ * @param element the element that is rendered by this GlyphView
+ */
+ public LabelView(Element element)
+ {
+ super(element);
+ }
+}
--- /dev/null
+/* LayoutQueue.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., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 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 javax.swing.text;
+
+import java.util.LinkedList;
+
+/**
+ * This is a queue which holds {@link Runnable} objects. It is
+ * intended for deferring layout operations.
+ */
+public class LayoutQueue
+{
+ // The default layout queue.
+ private static LayoutQueue defaultQueue = new LayoutQueue();
+
+ // The queue of tasks.
+ private LinkedList list = new LinkedList();
+
+ /**
+ * Create a new layout queue.
+ */
+ public LayoutQueue()
+ {
+ }
+
+ /**
+ * Add a layout task to the queue.
+ */
+ public void addTask(Runnable task)
+ {
+ synchronized (list)
+ {
+ list.addLast(task);
+ list.notify();
+ }
+ }
+
+ /**
+ * Called by a worker thread to retrieve the next layout task. This
+ * will block until a new task is available. This method will
+ * return null if the thread is interrupted while waiting.
+ */
+ protected Runnable waitForWork()
+ {
+ synchronized (list)
+ {
+ while (list.size() == 0)
+ {
+ try
+ {
+ list.wait();
+ }
+ catch (InterruptedException _)
+ {
+ // This seemed like a good idea, but it has not been
+ // tested on the JDK.
+ return null;
+ }
+ }
+ return (Runnable) list.removeFirst();
+ }
+ }
+
+ /**
+ * Return the default layout queue.
+ */
+ public static synchronized LayoutQueue getDefaultQueue()
+ {
+ return defaultQueue;
+ }
+
+ /**
+ * Set the default layout queue.
+ */
+ public static synchronized void setDefaultQueue(LayoutQueue q)
+ {
+ defaultQueue = q;
+ }
+}
--- /dev/null
+/* ParagraphView.java -- A composite View
+ 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., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 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 javax.swing.text;
+
+/**
+ * A {@link FlowView} that flows it's children horizontally and boxes the rows
+ * vertically.
+ *
+ * @author Roman Kennke (roman@kennke.org)
+ */
+public class ParagraphView extends FlowView implements TabExpander
+{
+ /**
+ * A specialized horizontal <code>BoxView</code> that represents exactly
+ * one row in a <code>ParagraphView</code>.
+ */
+ class Row extends BoxView
+ {
+ /**
+ * Creates a new instance of <code>Row</code>.
+ */
+ Row(Element el)
+ {
+ super(el, X_AXIS);
+ }
+ }
+
+ /**
+ * Creates a new <code>ParagraphView</code> for the given
+ * <code>Element</code>.
+ *
+ * @param element the element that is rendered by this ParagraphView
+ */
+ public ParagraphView(Element element)
+ {
+ super(element, Y_AXIS);
+ }
+
+ public float nextTabStop(float x, int tabOffset)
+ {
+ throw new InternalError("Not implemented yet");
+ }
+
+ /**
+ * Creates a new view that represents a row within a flow.
+ *
+ * @return a view for a new row
+ */
+ protected View createRow()
+ {
+ return new Row(getElement());
+ }
+}
--- /dev/null
+/* EventFilter.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., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 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 javax.xml.stream;
+
+import javax.xml.stream.events.XMLEvent;
+
+/**
+ * Simple filter interface for XML events.
+ */
+public interface EventFilter
+ extends XMLFilter
+{
+
+ /**
+ * Indicates whether this filter can accept the specified event.
+ */
+ boolean accept(XMLEvent event);
+
+}
+
--- /dev/null
+/* FactoryConfigurationError.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., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 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 javax.xml.stream;
+
+/**
+ * Error indicating that a factory could not be configured.
+ */
+public class FactoryConfigurationError
+ extends Error
+{
+
+ private final Exception exception;
+
+ public FactoryConfigurationError()
+ {
+ this((String) null, (Exception) null);
+ }
+
+ public FactoryConfigurationError(Exception e)
+ {
+ this(e, null);
+ }
+
+ public FactoryConfigurationError(Exception e, String msg)
+ {
+ super(msg);
+ exception = e;
+ }
+
+ public FactoryConfigurationError(String msg, Exception e)
+ {
+ this(e, msg);
+ }
+
+ public FactoryConfigurationError(String msg)
+ {
+ this(null, msg);
+ }
+
+ public Exception getException()
+ {
+ return exception;
+ }
+
+ public String getMessage()
+ {
+ return super.getMessage();
+ }
+
+}
+
--- /dev/null
+/* Location.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., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 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 javax.xml.stream;
+
+/**
+ * Information about the location of an XML event within the underlying
+ * stream.
+ */
+public interface Location
+{
+
+ /**
+ * Returns the line number at which the current event ends,
+ * or -1 if this is not available.
+ */
+ int getLineNumber();
+
+ /**
+ * Returns the column number at which the current event ends,
+ * or -1 if this is not available.
+ */
+ int getColumnNumber();
+
+ /**
+ * Returns the offset from the start of the source, in bytes or characters
+ * depending on the nature of the source, or -1 if this is not available.
+ */
+ int getCharacterOffset();
+
+ /**
+ * Returns the system identifier for the underlying source.
+ */
+ String getLocationURI();
+
+}
+
--- /dev/null
+/* StreamFilter.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., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 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 javax.xml.stream;
+
+/**
+ * Simple filter interface for XMLStreamReaders.
+ */
+public interface StreamFilter
+ extends XMLFilter
+{
+
+ /**
+ * Indicates whether the current state of the specified reader in part of
+ * this stream.
+ */
+ boolean accept(XMLStreamReader reader);
+
+}
+
--- /dev/null
+/* XMLEventFactory.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., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 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 javax.xml.stream;
+
+import java.io.BufferedReader;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.io.IOException;
+import java.io.Reader;
+import java.util.Iterator;
+import java.util.Properties;
+import javax.xml.namespace.NamespaceContext;
+import javax.xml.namespace.QName;
+import javax.xml.stream.events.Attribute;
+import javax.xml.stream.events.Characters;
+import javax.xml.stream.events.Comment;
+import javax.xml.stream.events.DTD;
+import javax.xml.stream.events.EndDocument;
+import javax.xml.stream.events.EndElement;
+import javax.xml.stream.events.EntityDeclaration;
+import javax.xml.stream.events.EntityReference;
+import javax.xml.stream.events.Namespace;
+import javax.xml.stream.events.ProcessingInstruction;
+import javax.xml.stream.events.StartDocument;
+import javax.xml.stream.events.StartElement;
+
+/**
+ * Factory for XML events.
+ */
+public abstract class XMLEventFactory
+{
+
+ protected XMLEventFactory()
+ {
+ }
+
+ /**
+ * Create a new factory instance.
+ * @see #newInstance(String,ClassLoader)
+ */
+ public static XMLEventFactory newInstance()
+ throws FactoryConfigurationError
+ {
+ return newInstance(null, null);
+ }
+
+ /**
+ * Create a new factory instance.
+ * The implementation class to load is the first found in the following
+ * locations:
+ * <ol>
+ * <li>the <code>javax.xml.stream.XMLEventFactory</code> system
+ * property</li>
+ * <li>the above named property value in the
+ * <code><i>$JAVA_HOME</i>/lib/stax.properties</code> file</li>
+ * <li>the class name specified in the
+ * <code>META-INF/services/javax.xml.stream.XMLEventFactory</code>
+ * system resource</li>
+ * <li>the default factory class</li>
+ * </ol>
+ */
+ static XMLEventFactory newInstance(String factoryId, ClassLoader classLoader)
+ throws FactoryConfigurationError
+ {
+ ClassLoader loader = classLoader;
+ if (loader == null)
+ {
+ loader = Thread.currentThread().getContextClassLoader();
+ }
+ if (loader == null)
+ {
+ loader = XMLEventFactory.class.getClassLoader();
+ }
+ String className = null;
+ int count = 0;
+ do
+ {
+ className = getFactoryClassName(loader, count++);
+ if (className != null)
+ {
+ try
+ {
+ Class t = (loader != null) ? loader.loadClass(className) :
+ Class.forName(className);
+ return (XMLEventFactory) t.newInstance();
+ }
+ catch (ClassNotFoundException e)
+ {
+ className = null;
+ }
+ catch (Exception e)
+ {
+ throw new FactoryConfigurationError(e,
+ "error instantiating class " + className);
+ }
+ }
+ }
+ while (className == null && count < 3);
+ return new gnu.xml.stream.XMLEventFactoryImpl();
+ }
+
+ private static String getFactoryClassName(ClassLoader loader, int attempt)
+ {
+ final String propertyName = "javax.xml.stream.XMLEventFactory";
+ switch (attempt)
+ {
+ case 0:
+ return System.getProperty(propertyName);
+ case 1:
+ try
+ {
+ File file = new File(System.getProperty("java.home"));
+ file = new File(file, "lib");
+ file = new File(file, "stax.properties");
+ InputStream in = new FileInputStream(file);
+ Properties props = new Properties();
+ props.load(in);
+ in.close();
+ return props.getProperty(propertyName);
+ }
+ catch (IOException e)
+ {
+ return null;
+ }
+ case 2:
+ try
+ {
+ String serviceKey = "/META-INF/services/" + propertyName;
+ InputStream in = (loader != null) ?
+ loader.getResourceAsStream(serviceKey) :
+ XMLEventFactory.class.getResourceAsStream(serviceKey);
+ if (in != null)
+ {
+ BufferedReader r =
+ new BufferedReader(new InputStreamReader(in));
+ String ret = r.readLine();
+ r.close();
+ return ret;
+ }
+ }
+ catch (IOException e)
+ {
+ }
+ return null;
+ default:
+ return null;
+ }
+ }
+
+ /**
+ * Sets the location for each event created by this factory.
+ */
+ public abstract void setLocation(Location location);
+
+ /**
+ * Create an attribute event.
+ */
+ public abstract Attribute createAttribute(String prefix, String namespaceURI,
+ String localName, String value);
+
+ /**
+ * Create an attribute event.
+ */
+ public abstract Attribute createAttribute(String localName, String value);
+
+ /**
+ * Create an attribute event.
+ */
+ public abstract Attribute createAttribute(QName name, String value);
+
+ /**
+ * Create a namespace declaration event.
+ */
+ public abstract Namespace createNamespace(String namespaceURI);
+
+ /**
+ * Create a namespace declaration event.
+ */
+ public abstract Namespace createNamespace(String prefix, String namespaceUri);
+
+ /**
+ * Create a start-element event.
+ */
+ public abstract StartElement createStartElement(QName name,
+ Iterator attributes,
+ Iterator namespaces);
+
+ /**
+ * Create a start-element event.
+ */
+ public abstract StartElement createStartElement(String prefix,
+ String namespaceUri,
+ String localName);
+
+ /**
+ * Create a start-element event.
+ */
+ public abstract StartElement createStartElement(String prefix,
+ String namespaceUri,
+ String localName,
+ Iterator attributes,
+ Iterator namespaces);
+
+ /**
+ * Create a start-element event.
+ */
+ public abstract StartElement createStartElement(String prefix,
+ String namespaceUri,
+ String localName,
+ Iterator attributes,
+ Iterator namespaces,
+ NamespaceContext context);
+
+ /**
+ * Create an end-element event.
+ */
+ public abstract EndElement createEndElement(QName name,
+ Iterator namespaces);
+
+ /**
+ * Create an end-element event.
+ */
+ public abstract EndElement createEndElement(String prefix,
+ String namespaceUri,
+ String localName);
+
+ /**
+ * Create an end-element event.
+ */
+ public abstract EndElement createEndElement(String prefix,
+ String namespaceUri,
+ String localName,
+ Iterator namespaces);
+
+ /**
+ * Create a text event.
+ */
+ public abstract Characters createCharacters(String content);
+
+ /**
+ * Create a text event of type CDATA section.
+ */
+ public abstract Characters createCData(String content);
+
+ /**
+ * Create a text event of type whitespace.
+ */
+ public abstract Characters createSpace(String content);
+
+ /**
+ * Create a text event of type ignorable whitespace.
+ */
+ public abstract Characters createIgnorableSpace(String content);
+
+ /**
+ * Create a start-document event.
+ */
+ public abstract StartDocument createStartDocument();
+
+ /**
+ * Create a start-document event.
+ */
+ public abstract StartDocument createStartDocument(String encoding,
+ String version,
+ boolean standalone);
+
+ /**
+ * Create a start-document event.
+ */
+ public abstract StartDocument createStartDocument(String encoding,
+ String version);
+
+ /**
+ * Create a start-document event.
+ */
+ public abstract StartDocument createStartDocument(String encoding);
+
+ /**
+ * Create an end-document event.
+ */
+ public abstract EndDocument createEndDocument();
+
+ /**
+ * Create an entity reference event.
+ */
+ //public abstract EntityReference createEntityReference(String name,
+ // EntityDeclaration declaration);
+ public abstract EntityReference createEntityReference(String name,
+ String replacementText);
+
+ /**
+ * Create a comment event.
+ */
+ public abstract Comment createComment(String text);
+
+ /**
+ * Create a processing instruction event.
+ */
+ public abstract ProcessingInstruction createProcessingInstruction(String target,
+ String data);
+
+ /**
+ * Create a DOCTYPE declaration event.
+ */
+ public abstract DTD createDTD(String dtd);
+
+}
+
--- /dev/null
+/* XMLEventReader.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., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 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 javax.xml.stream;
+
+import java.util.Iterator;
+import javax.xml.stream.events.XMLEvent;
+
+/**
+ * An XML parser.
+ */
+public interface XMLEventReader
+ extends XMLIterator
+{
+
+ /**
+ * Looks at the next XML event without advancing the cursor in the stream.
+ * Returns <code>null</code> if there are no more events to read.
+ */
+ XMLEvent peek()
+ throws XMLStreamException;
+
+ /**
+ * Reads the text context of an element.
+ * When invoked, the current event must be START_ELEMENT.
+ * On completion, the current event will be END_ELEMENT.
+ */
+ String getElementText()
+ throws XMLStreamException;
+
+ /**
+ * Returns the next element event.
+ * This method skips insignificant space until a START_ELEMENT or
+ * END_ELEMENT event is found.
+ * @exception XMLStreamException if an event that was not an insignificant
+ * space event was encountered
+ */
+ XMLEvent nextTag()
+ throws XMLStreamException;
+
+ /**
+ * Returns the implementation-specific feature or property of the given
+ * name.
+ * @exception IllegalArgumentException if the property is not supported
+ */
+ Object getProperty(String name)
+ throws IllegalArgumentException;
+
+}
+
--- /dev/null
+/* XMLEventWriter.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., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 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 javax.xml.stream;
+
+import javax.xml.namespace.NamespaceContext;
+import javax.xml.stream.events.XMLEvent;
+import javax.xml.stream.util.XMLEventConsumer;
+
+/**
+ * Interface for writing XML documents from a series of events.
+ */
+public interface XMLEventWriter
+ extends XMLEventConsumer
+{
+
+ /**
+ * Ensures that any cached events are written to the underlying output
+ * sink.
+ */
+ void flush()
+ throws XMLStreamException;
+
+ /**
+ * Frees any resources used by this writer.
+ */
+ void close()
+ throws XMLStreamException;
+
+ /**
+ * Adds the specified event to this writer.
+ */
+ void add(XMLEvent event)
+ throws XMLStreamException;
+
+ /**
+ * Adds the specified XML stream to this writer.
+ * The implementation will call <code>next</code> on the given argument
+ * while <code>hasNext</code> returns true.
+ */
+ void add(XMLEventReader reader)
+ throws XMLStreamException;
+
+ /**
+ * Returns the namespace prefix the specified URI is currently associated
+ * with.
+ */
+ String getPrefix(String uri)
+ throws XMLStreamException;
+
+ /**
+ * Associates the given namespace prefix and URI.
+ */
+ void setPrefix(String prefix, String uri)
+ throws XMLStreamException;
+
+ /**
+ * Sets the current default namespace URI.
+ */
+ void setDefaultNamespace(String uri)
+ throws XMLStreamException;
+
+ /**
+ * Sets the namespace context for managing namespace prefixes and URIs.
+ */
+ void setNamespaceContext(NamespaceContext context)
+ throws XMLStreamException;
+
+ /**
+ * Returns the namespace context.
+ */
+ NamespaceContext getNamespaceContext();
+
+}
+
--- /dev/null
+/* XMLFilter.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., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 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 javax.xml.stream;
+
+/**
+ * Marker interface for stream and event filters.
+ */
+public interface XMLFilter
+{
+}
+
--- /dev/null
+/* XMLInputFactory.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., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 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 javax.xml.stream;
+
+import java.io.BufferedReader;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.io.IOException;
+import java.io.Reader;
+import java.io.Writer;
+import java.util.Properties;
+import javax.xml.stream.util.XMLEventAllocator;
+import javax.xml.transform.Source;
+
+/**
+ * Factory for creating stream and event readers from various kinds of input
+ * source.
+ * <h3>Parameters</h3>
+ * <table>
+ * <tr>
+ * <th>Name</th>
+ * <th>Description</th>
+ * <th>Type</th>
+ * <th>Default</th>
+ * <th>Required</th>
+ * </tr>
+ * <tr>
+ * <td>javax.xml.stream.isValidating</td>
+ * <td>Controls DTD validation</td>
+ * <td>Boolean</td>
+ * <td>Boolean.FALSE</td>
+ * <td>no</td>
+ * </tr>
+ * <tr>
+ * <td>javax.xml.stream.isNamespaceAware</td>
+ * <td>Controls namespace processing for XML 1.0</td>
+ * <td>Boolean</td>
+ * <td>Boolean.TRUE</td>
+ * <td>true is required, false is optional</td>
+ * </tr>
+ * <tr>
+ * <td>javax.xml.stream.isCoalescing</td>
+ * <td>Controls coalescing (normalization of adjacent character data)</td>
+ * <td>Boolean</td>
+ * <td>Boolean.FALSE</td>
+ * <td>yes</td>
+ * </tr>
+ * <tr>
+ * <td>javax.xml.stream.isReplacingEntityReferences</td>
+ * <td>Controls replacement of entity references with their replacement
+ * text</td>
+ * <td>Boolean</td>
+ * <td>Boolean.TRUE</td>
+ * <td>yes</td>
+ * </tr>
+ * <tr>
+ * <td>javax.xml.stream.isSupportingExternalEntities</td>
+ * <td>Controls whether to resolve external entities</td>
+ * <td>Boolean</td>
+ * <td>not specified</td>
+ * <td>yes</td>
+ * </tr>
+ * <tr>
+ * <td>javax.xml.stream.supportDTD</td>
+ * <td>Controls whether to support DTDs</td>
+ * <td>Boolean</td>
+ * <td>Boolean.TRUE</td>
+ * <td>yes</td>
+ * </tr>
+ * <tr>
+ * <td>javax.xml.stream.reporter</td>
+ * <td></td>
+ * <td>javax.xml.stream.XMLReporter</td>
+ * <td></td>
+ * <td>yes</td>
+ * </tr>
+ * <tr>
+ * <td>javax.xml.stream.resolver</td>
+ * <td></td>
+ * <td>javax.xml.stream.XMLResolver</td>
+ * <td></td>
+ * <td>yes</td>
+ * </tr>
+ * <tr>
+ * <td>javax.xml.stream.allocator</td>
+ * <td></td>
+ * <td>javax.xml.stream.util.XMLEventAllocator</td>
+ * <td></td>
+ * <td>yes</td>
+ * </tr>
+ * </table>
+ */
+public abstract class XMLInputFactory
+{
+
+ /**
+ * Property used to control namespace support.
+ */
+ public static final String IS_NAMESPACE_AWARE =
+ "javax.xml.stream.isNamespaceAware";
+
+ /**
+ * Property used to control DTD validation.
+ */
+ public static final String IS_VALIDATING = "javax.xml.stream.isValidating";
+
+ /**
+ * Property used to control whether to coalesce adjacent text events.
+ */
+ public static final String IS_COALESCING = "javax.xml.stream.isCoalescing";
+
+ /**
+ * Property used to control whether to replace entity references with
+ * their replacement text.
+ */
+ public static final String IS_REPLACING_ENTITY_REFERENCES =
+ "javax.xml.stream.isReplacingEntityReferences";
+
+ /**
+ * Property used to control whether to resolve external entities.
+ */
+ public static final String IS_SUPPORTING_EXTERNAL_ENTITIES =
+ "javax.xml.stream.isSupportingExternalEntities";
+
+ /**
+ * Property used to indicate whether to support DTDs.
+ */
+ public static final String SUPPORT_DTD = "javax.xml.stream.supportDTD";
+
+ /**
+ * Property used to control the error reporter implementation.
+ */
+ public static final String REPORTER = "javax.xml.stream.reporter";
+
+ /**
+ * Property used to control the entity resolver implementation.
+ */
+ public static final String RESOLVER = "javax.xml.stream.resolver";
+
+ /**
+ * Property used to control the event allocator implementation.
+ */
+ public static final String ALLOCATOR = "javax.xml.stream.allocator";
+
+ protected XMLInputFactory()
+ {
+ }
+
+ /**
+ * Creates a new factory instance.
+ * @see #newInstance(String,ClassLoader)
+ */
+ public static XMLInputFactory newInstance()
+ throws FactoryConfigurationError
+ {
+ return newInstance(null, null);
+ }
+
+ /**
+ * Creates a new factory instance.
+ * The implementation class to load is the first found in the following
+ * locations:
+ * <ol>
+ * <li>the <code>javax.xml.stream.XMLInputFactory</code> system
+ * property</li>
+ * <li>the above named property value in the
+ * <code><i>$JAVA_HOME</i>/lib/stax.properties</code> file</li>
+ * <li>the class name specified in the
+ * <code>META-INF/services/javax.xml.stream.XMLInputFactory</code>
+ * system resource</li>
+ * <li>the default factory class</li>
+ * </ol>
+ */
+ public static XMLInputFactory newInstance(String factoryId,
+ ClassLoader classLoader)
+ throws FactoryConfigurationError
+ {
+ ClassLoader loader = classLoader;
+ if (loader == null)
+ {
+ loader = Thread.currentThread().getContextClassLoader();
+ }
+ if (loader == null)
+ {
+ loader = XMLInputFactory.class.getClassLoader();
+ }
+ String className = null;
+ int count = 0;
+ do
+ {
+ className = getFactoryClassName(loader, count++);
+ if (className != null)
+ {
+ try
+ {
+ Class t = (loader != null) ? loader.loadClass(className) :
+ Class.forName(className);
+ return (XMLInputFactory) t.newInstance();
+ }
+ catch (ClassNotFoundException e)
+ {
+ className = null;
+ }
+ catch (Exception e)
+ {
+ throw new FactoryConfigurationError(e,
+ "error instantiating class " + className);
+ }
+ }
+ }
+ while (className == null && count < 3);
+ return new gnu.xml.stream.XMLInputFactoryImpl();
+ }
+
+ private static String getFactoryClassName(ClassLoader loader, int attempt)
+ {
+ final String propertyName = "javax.xml.stream.XMLInputFactory";
+ switch (attempt)
+ {
+ case 0:
+ return System.getProperty(propertyName);
+ case 1:
+ try
+ {
+ File file = new File(System.getProperty("java.home"));
+ file = new File(file, "lib");
+ file = new File(file, "stax.properties");
+ InputStream in = new FileInputStream(file);
+ Properties props = new Properties();
+ props.load(in);
+ in.close();
+ return props.getProperty(propertyName);
+ }
+ catch (IOException e)
+ {
+ return null;
+ }
+ case 2:
+ try
+ {
+ String serviceKey = "/META-INF/services/" + propertyName;
+ InputStream in = (loader != null) ?
+ loader.getResourceAsStream(serviceKey) :
+ XMLInputFactory.class.getResourceAsStream(serviceKey);
+ if (in != null)
+ {
+ BufferedReader r =
+ new BufferedReader(new InputStreamReader(in));
+ String ret = r.readLine();
+ r.close();
+ return ret;
+ }
+ }
+ catch (IOException e)
+ {
+ }
+ return null;
+ default:
+ return null;
+ }
+ }
+
+ /**
+ * Creates a new stream reader.
+ */
+ public abstract XMLStreamReader createXMLStreamReader(Reader reader)
+ throws XMLStreamException;
+
+ /**
+ * Creates a new stream reader.
+ */
+ public abstract XMLStreamReader createXMLStreamReader(Source source)
+ throws XMLStreamException;
+
+ /**
+ * Creates a new stream reader.
+ */
+ public abstract XMLStreamReader createXMLStreamReader(InputStream stream)
+ throws XMLStreamException;
+
+ /**
+ * Creates a new stream reader.
+ */
+ public abstract XMLStreamReader createXMLStreamReader(InputStream stream,
+ String encoding)
+ throws XMLStreamException;
+
+ /**
+ * Creates a new stream reader.
+ *
+ public abstract XMLStreamReader createXMLStreamReader(String systemId,
+ InputStream stream)
+ throws XMLStreamException;*/
+
+ /**
+ * Creates a new stream reader.
+ *
+ public abstract XMLStreamReader createXMLStreamReader(String systemId,
+ Reader reader)
+ throws XMLStreamException;*/
+
+ /**
+ * Creates a new event reader.
+ */
+ public abstract XMLEventReader createXMLEventReader(Reader reader)
+ throws XMLStreamException;
+
+ /**
+ * Creates a new event reader.
+ *
+ public abstract XMLEventReader createXMLEventReader(String systemId,
+ Reader reader)
+ throws XMLStreamException;*/
+
+ /**
+ * Creates a new event reader.
+ */
+ public abstract XMLEventReader createXMLEventReader(XMLStreamReader reader)
+ throws XMLStreamException;
+
+ /**
+ * Creates a new event reader.
+ */
+ public abstract XMLEventReader createXMLEventReader(Source source)
+ throws XMLStreamException;
+
+ /**
+ * Creates a new event reader.
+ */
+ public abstract XMLEventReader createXMLEventReader(InputStream stream)
+ throws XMLStreamException;
+
+ /**
+ * Creates a new event reader.
+ */
+ public abstract XMLEventReader createXMLEventReader(InputStream stream,
+ String encoding)
+ throws XMLStreamException;
+
+ /**
+ * Creates a new event reader.
+ *
+ public abstract XMLEventReader createXMLEventReader(String systemId,
+ InputStream stream)
+ throws XMLStreamException;*/
+
+ /**
+ * Create a new filtered reader.
+ */
+ public abstract XMLStreamReader createFilteredReader(XMLStreamReader reader,
+ StreamFilter filter)
+ throws XMLStreamException;
+
+ /**
+ * Create a new filtered reader.
+ */
+ public abstract XMLEventReader createFilteredReader(XMLEventReader reader,
+ EventFilter filter)
+ throws XMLStreamException;
+
+ /**
+ * Returns the entity resolver.
+ */
+ public abstract XMLResolver getXMLResolver();
+
+ /**
+ * Sets the entity resolver.
+ */
+ public abstract void setXMLResolver(XMLResolver resolver);
+
+ /**
+ * Returns the error reporter.
+ */
+ public abstract XMLReporter getXMLReporter();
+
+ /**
+ * Sets the error reporter.
+ */
+ public abstract void setXMLReporter(XMLReporter reporter);
+
+ /**
+ * Sets the implementation-specific property of the given name.
+ * @exception IllegalArgumentException if the property is not supported
+ */
+ public abstract void setProperty(String name, Object value)
+ throws IllegalArgumentException;
+
+ /**
+ * Returns the implementation-specific property of the given name.
+ * @exception IllegalArgumentException if the property is not supported
+ */
+ public abstract Object getProperty(String name)
+ throws IllegalArgumentException;
+
+ /**
+ * Indicates whether the specified property is supported.
+ */
+ public abstract boolean isPropertySupported(String name);
+
+ /**
+ * Sets the event allocator.
+ */
+ public abstract void setEventAllocator(XMLEventAllocator allocator);
+
+ /**
+ * Returns the event allocator.
+ */
+ public abstract XMLEventAllocator getEventAllocator();
+
+ /**
+ * Sets whether text will be coalesced.
+ */
+ public abstract void setCoalescing(boolean coalescing);
+
+ /**
+ * Indicates whether text will be coalesced.
+ */
+ public abstract boolean isCoalescing();
+
+}
+
--- /dev/null
+/* XMLIterator.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., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 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 javax.xml.stream;
+
+import javax.xml.stream.events.XMLEvent;
+
+/**
+ * Simple iterator for XML events.
+ */
+public interface XMLIterator
+{
+
+ /**
+ * Returns the next XML event.
+ */
+ XMLEvent next()
+ throws XMLStreamException;
+
+ /**
+ * Indicates whether there are more XML events to be read.
+ */
+ boolean hasNext()
+ throws XMLStreamException;
+
+}
+
--- /dev/null
+/* XMLOutputFactory.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., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 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 javax.xml.stream;
+
+import java.io.BufferedReader;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.io.IOException;
+import java.io.OutputStream;
+import java.io.Writer;
+import java.util.Properties;
+//import javax.xml.transform.Result;
+
+/**
+ * Factory for obtaining XML stream and event writers for various kinds of
+ * output sink.
+ * <h3>Configuration</h3>
+ * <table>
+ * <tr>
+ * <th>Name</th>
+ * <th>Description</th>
+ * <th>Type</th>
+ * <th>Default</th>
+ * <th>Required</th>
+ * </tr>
+ * <tr>
+ * <td>javax.xml.stream.isRepairingNamespaces</td>
+ * <td>default namespace prefixes</td>
+ * <td>Boolean</td>
+ * <td>Boolean.FALSE</td>
+ * <td>yes</td>
+ * </tr>
+ * </table>
+ */
+public abstract class XMLOutputFactory
+{
+
+ /**
+ * Property used to control whether to default namespace prefixes.
+ * If true, the writer will create a namespace declaration for any
+ * attribute that doesn't have a namespace declaration in scope.
+ */
+ public static final java.lang.String IS_PREFIX_DEFAULTING =
+ "javax.xml.stream.isPrefixDefaulting";
+
+ protected XMLOutputFactory()
+ {
+ }
+
+ /**
+ * Creates a new <b>output</b> factory.
+ * The implementation class to load is the first found in the following
+ * locations:
+ * <ol>
+ * <li>the <code>javax.xml.stream.XMLOutputFactory</code> system
+ * property</li>
+ * <li>the above named property value in the
+ * <code><i>$JAVA_HOME</i>/lib/stax.properties</code> file</li>
+ * <li>the class name specified in the
+ * <code>META-INF/services/javax.xml.stream.XMLOutputFactory</code>
+ * system resource</li>
+ * <li>the default factory class</li>
+ * </ol>
+ */
+ public static XMLOutputFactory newInstance()
+ throws FactoryConfigurationError
+ {
+ ClassLoader loader = Thread.currentThread().getContextClassLoader();
+ if (loader == null)
+ {
+ loader = XMLOutputFactory.class.getClassLoader();
+ }
+ String className = null;
+ int count = 0;
+ do
+ {
+ className = getFactoryClassName(loader, count++);
+ if (className != null)
+ {
+ try
+ {
+ Class t = (loader != null) ? loader.loadClass(className) :
+ Class.forName(className);
+ return (XMLOutputFactory) t.newInstance();
+ }
+ catch (ClassNotFoundException e)
+ {
+ className = null;
+ }
+ catch (Exception e)
+ {
+ throw new FactoryConfigurationError(e,
+ "error instantiating class " + className);
+ }
+ }
+ }
+ while (className == null && count < 3);
+ return new gnu.xml.stream.XMLOutputFactoryImpl();
+ }
+
+ private static String getFactoryClassName(ClassLoader loader, int attempt)
+ {
+ final String propertyName = "javax.xml.stream.XMLOutputFactory";
+ switch (attempt)
+ {
+ case 0:
+ return System.getProperty(propertyName);
+ case 1:
+ try
+ {
+ File file = new File(System.getProperty("java.home"));
+ file = new File(file, "lib");
+ file = new File(file, "stax.properties");
+ InputStream in = new FileInputStream(file);
+ Properties props = new Properties();
+ props.load(in);
+ in.close();
+ return props.getProperty(propertyName);
+ }
+ catch (IOException e)
+ {
+ return null;
+ }
+ case 2:
+ try
+ {
+ String serviceKey = "/META-INF/services/" + propertyName;
+ InputStream in = (loader != null) ?
+ loader.getResourceAsStream(serviceKey) :
+ XMLOutputFactory.class.getResourceAsStream(serviceKey);
+ if (in != null)
+ {
+ BufferedReader r =
+ new BufferedReader(new InputStreamReader(in));
+ String ret = r.readLine();
+ r.close();
+ return ret;
+ }
+ }
+ catch (IOException e)
+ {
+ }
+ return null;
+ default:
+ return null;
+ }
+ }
+
+ /**
+ * Creates a new <b>input</b> factory.
+ * This appears to be an API design bug.
+ * @see javax.xml.stream.XMLInputFactory.newInstance(String,ClassLoader)
+ */
+ public static XMLInputFactory newInstance(String factoryId,
+ ClassLoader classLoader)
+ throws FactoryConfigurationError
+ {
+ return XMLInputFactory.newInstance(factoryId, classLoader);
+ }
+
+ /**
+ * Creates a new stream writer.
+ */
+ public abstract XMLStreamWriter createXMLStreamWriter(Writer stream)
+ throws XMLStreamException;
+
+ /**
+ * Creates a new stream writer.
+ */
+ public abstract XMLStreamWriter createXMLStreamWriter(OutputStream stream)
+ throws XMLStreamException;
+
+ /**
+ * Creates a new stream writer.
+ */
+ public abstract XMLStreamWriter createXMLStreamWriter(OutputStream stream,
+ String encoding)
+ throws XMLStreamException;
+
+ /**
+ * Creates a new stream writer.
+ * @exception UnsupportedOperationException if this method is not
+ * supported
+ */
+ //public abstract XMLStreamWriter createXMLStreamWriter(Result result)
+ // throws XMLStreamException;
+
+ /**
+ * Creates a new event writer.
+ * @exception UnsupportedOperationException if this method is not
+ * supported
+ */
+ //public abstract XMLEventWriter createXMLEventWriter(Result result)
+ // throws XMLStreamException;
+
+ /**
+ * Creates a new event writer.
+ */
+ public abstract XMLEventWriter createXMLEventWriter(OutputStream stream)
+ throws XMLStreamException;
+
+ /**
+ * Creates a new event writer.
+ */
+ public abstract XMLEventWriter createXMLEventWriter(OutputStream stream,
+ String encoding)
+ throws XMLStreamException;
+
+ /**
+ * Creates a new event writer.
+ */
+ public abstract XMLEventWriter createXMLEventWriter(Writer stream)
+ throws XMLStreamException;
+
+ /**
+ * Sets the implementation-specific property of the given name.
+ * @exception IllegalArgumentException if the property is not supported
+ */
+ public abstract void setProperty(String name, Object value)
+ throws IllegalArgumentException;
+
+ /**
+ * Returns the implementation-specific property of the given name.
+ * @exception IllegalArgumentException if the property is not supported
+ */
+ public abstract Object getProperty(String name)
+ throws IllegalArgumentException;
+
+ /**
+ * Indicates whether writers created by this factory will perform prefix
+ * defaulting.
+ * @see #IS_PREFIX_DEFAULTING
+ */
+ public abstract boolean isPrefixDefaulting();
+
+ /**
+ * Indicates whether the specified property is supported.
+ */
+ public abstract boolean isPropertySupported(String name);
+
+ /**
+ * Sets whether writers created by this factory will perform prefix
+ * defaulting.
+ * @see #IS_PREFIX_DEFAULTING
+ */
+ public abstract void setPrefixDefaulting(boolean value);
+
+}
+
--- /dev/null
+/* XMLReporter.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., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 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 javax.xml.stream;
+
+/**
+ * Interface used to report non-fatal errors during parsing.
+ */
+public interface XMLReporter
+{
+
+ /**
+ * Reports an error.
+ * @param message the error message
+ * @param errorType an implementation-specific error type
+ * @param relatedInformation additional information, if any
+ * @param location the error location, if available
+ */
+ void report(String message, String errorType,
+ Object relatedInformation, Location location)
+ throws XMLStreamException;
+
+}
+
--- /dev/null
+/* XMLResolver.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., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 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 javax.xml.stream;
+
+import java.io.InputStream;
+
+/**
+ * Interface used to resolve XML external entities during parsing.
+ */
+public interface XMLResolver
+{
+
+ /**
+ * Returns an input source from which the specified external entity can be
+ * read. The following return types are possible:
+ * <ol>
+ * <li><code>java.io.InputStream</code></li>
+ * <li><code>javax.xml.stream.XMLStreamReader</code></li>
+ * <li><code>java.xml.stream.XMLEventReader</code></li>
+ * </ol>
+ * If <code>null</code> is returned, the processor will attempt to resolve
+ * the entity itself.
+ * @param publicID the public ID of the external entity
+ * @param systemID the system ID of the external entity
+ * @param baseURI the absolute base URI of the referring entity
+ * @param namespace the namespace of the external entity
+ *
+ Object resolveEntity(String publicID, String systemID,
+ String baseURI, String namespace)
+ throws XMLStreamException;*/
+
+ /**
+ * Retrieves a resource from the specified URI.
+ */
+ XMLEventReader resolveAsXMLEventReader(String uri)
+ throws XMLStreamException;
+
+ /**
+ * Retrieves a resource from the specified URI.
+ */
+ XMLStreamReader resolveAsXMLStreamReader(String uri)
+ throws XMLStreamException;
+
+ /**
+ * Retrieves a resource from the specified URI.
+ */
+ InputStream resolve(String uri)
+ throws XMLStreamException;
+
+}
+
--- /dev/null
+/* XMLStreamConstants.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., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 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 javax.xml.stream;
+
+/**
+ * STaX constants.
+ */
+public interface XMLStreamConstants
+{
+
+ /**
+ * A start element event.
+ */
+ static final int START_ELEMENT = 1;
+
+ /**
+ * An end element event.
+ */
+ static final int END_ELEMENT = 2;
+
+ /**
+ * A processing instruction event.
+ */
+ static final int PROCESSING_INSTRUCTION = 3;
+
+ /**
+ * A text event.
+ */
+ static final int CHARACTERS = 4;
+
+ /**
+ * A comment event.
+ */
+ static final int COMMENT = 5;
+
+ /**
+ * An ignorable whitespace event.
+ */
+ static final int SPACE = 6;
+
+ /**
+ * A start document event.
+ */
+ static final int START_DOCUMENT = 7;
+
+ /**
+ * An end document event.
+ */
+ static final int END_DOCUMENT = 8;
+
+ /**
+ * An entity reference event.
+ */
+ static final int ENTITY_REFERENCE = 9;
+
+ /**
+ * An attribute event.
+ */
+ static final int ATTRIBUTE = 10;
+
+ /**
+ * A DOCTYPE declaration event.
+ */
+ static final int DTD = 11;
+
+ /**
+ * A CDATA section event.
+ */
+ static final int CDATA = 12;
+
+ /**
+ * A namespace event.
+ */
+ static final int NAMESPACE = 13;
+
+ /**
+ * A start-entity event.
+ */
+ static final int START_ENTITY = 14;
+
+ /**
+ * An end-entity event.
+ */
+ static final int END_ENTITY = 15;
+
+ /**
+ * A notation declaration event.
+ */
+ static final int NOTATION_DECLARATION = 16;
+
+ /**
+ * An entity declaration event.
+ */
+ static final int ENTITY_DECLARATION = 17;
+
+}
+
--- /dev/null
+/* XMLStreamException.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., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 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 javax.xml.stream;
+
+/**
+ * Exception indicating an XML stream processing error.
+ */
+public class XMLStreamException
+ extends Exception
+{
+
+ protected Location location;
+ protected Throwable nested;
+
+ public XMLStreamException()
+ {
+ this(null, null, null);
+ }
+
+ public XMLStreamException(String msg)
+ {
+ this(msg, null, null);
+ }
+
+ public XMLStreamException(Throwable th)
+ {
+ this(null, null, th);
+ }
+
+ public XMLStreamException(String msg, Throwable th)
+ {
+ this(msg, null, th);
+ }
+
+ public XMLStreamException(String msg, Location location, Throwable th)
+ {
+ super(msg);
+ this.location = location;
+ nested = th;
+ }
+
+ public XMLStreamException(String msg, Location location)
+ {
+ this(msg, location, null);
+ }
+
+ /**
+ * Returns the nested exception.
+ */
+ public Throwable getNestedException()
+ {
+ return nested;
+ }
+
+ /**
+ * Returns the location of the exception.
+ */
+ public Location getLocation()
+ {
+ return location;
+ }
+
+}
+
--- /dev/null
+/* XMLStreamReader.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., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 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 javax.xml.stream;
+
+import javax.xml.namespace.NamespaceContext;
+import javax.xml.namespace.QName;
+
+/**
+ * Interface implemented by an XML parser.
+ */
+public interface XMLStreamReader
+ extends XMLStreamConstants
+{
+
+ /**
+ * Returns the implementation-specific feature or property of the given
+ * name.
+ */
+ Object getProperty(String name)
+ throws IllegalArgumentException;
+
+ /**
+ * Returns the next parsing event.
+ */
+ int next()
+ throws XMLStreamException;
+
+ /**
+ * Tests whether the current event is of the given type and namespace.
+ * @exception XMLStreamException if the test fails
+ */
+ void require(int type, String namespaceURI, String localName)
+ throws XMLStreamException;
+
+ /**
+ * Returns the text content of a text-only element.
+ * When invoked, the current event must be START_ELEMENT.
+ * On completion, the current event will be END_ELEMENT.
+ */
+ String getElementText()
+ throws XMLStreamException;
+
+ /**
+ * Skips any ignorable whitespace, comments, and processing instructions
+ * until a START_ELEMENT or END_ELEMENT event is encountered.
+ * @exception XMLStreamException if an event of any other type is
+ * encountered
+ */
+ int nextTag()
+ throws XMLStreamException;
+
+ /**
+ * Indicates whether there are any remaining events to be read.
+ */
+ boolean hasNext()
+ throws XMLStreamException;
+
+ /**
+ * Frees any resources used by this parser.
+ * This method will not close the underlying input source.
+ */
+ void close()
+ throws XMLStreamException;
+
+ /**
+ * Returns the namespace URI for the given prefix.
+ */
+ String getNamespaceURI(String prefix);
+
+ /**
+ * Indicates whether the current event is START_ELEMENT.
+ */
+ boolean isStartElement();
+
+ /**
+ * Indicates whether the current event is END_ELEMENT.
+ */
+ boolean isEndElement();
+
+ /**
+ * Indicates whether the current event is character data.
+ */
+ boolean isCharacters();
+
+ /**
+ * Indicates whether the current event is ignorable whitespace.
+ */
+ boolean isWhiteSpace();
+
+ /**
+ * Returns the normalized attribute value for the given attribute.
+ */
+ String getAttributeValue(String namespaceURI, String localName);
+
+ /**
+ * Returns the number of attributes on this element.
+ * This method can only be invoked on a START_ELEMENT event.
+ */
+ int getAttributeCount();
+
+ /**
+ * Returns the QName of the attribute at the given index.
+ */
+ QName getAttributeQName(int index);
+
+ /**
+ * Returns the namespace URI of the attribute at the given index.
+ */
+ String getAttributeNamespace(int index);
+
+ /**
+ * Returns the local-name of the attribute at the given index.
+ */
+ String getAttributeName(int index);
+
+ /**
+ * Returns the namespace prefix of the attribute at the given index.
+ */
+ String getAttributePrefix(int index);
+
+ /**
+ * Returns the type of the attribute at the specified index.
+ */
+ String getAttributeType(int index);
+
+ /**
+ * Returns the normalized value of the attribute at the given index.
+ */
+ String getAttributeValue(int index);
+
+ /**
+ * Indicates whether the attribute at the given index was specified in the
+ * underlying XML source or created by default.
+ */
+ boolean isAttributeSpecified(int index);
+
+ /**
+ * Returns the number of namespaces declared on this event.
+ * This method is only valid on a START_ELEMENT, END_ELEMENT, or NAMESPACE
+ * event.
+ */
+ int getNamespaceCount();
+
+ /**
+ * Returns the prefix of the namespace at the given index, or null if this
+ * is the default namespace declaration.
+ */
+ String getNamespacePrefix(int index);
+
+ /**
+ * Returns the URI of the namespace at the given index.
+ */
+ String getNamespaceURI(int index);
+
+ /**
+ * Returns the namespace context for the current position.
+ */
+ NamespaceContext getNamespaceContext();
+
+ /**
+ * Returns the type of the current event.
+ */
+ int getEventType();
+
+ /**
+ * Returns the string value of the current event.
+ */
+ String getText();
+
+ /**
+ * Returns the string value of the current event as a character array.
+ */
+ char[] getTextCharacters();
+
+ /**
+ * Copies the string value of the current event into the specified
+ * character array.
+ */
+ int getTextCharacters(int sourceStart, char[] target,
+ int targetStart, int length)
+ throws XMLStreamException;
+
+ /**
+ * Returns the offset of the first character in the text character array.
+ */
+ int getTextStart();
+
+ /**
+ * Returns the length of the characters in the text character array.
+ */
+ int getTextLength();
+
+ /**
+ * Returns the input encoding.
+ */
+ String getEncoding();
+
+ /**
+ * Indicates whether the current event has text.
+ */
+ boolean hasText();
+
+ /**
+ * Returns the current location of the parser cursor in the underlying
+ * input source.
+ */
+ Location getLocation();
+
+ /**
+ * Returns the QName of the current element.
+ * This method is only valid on a START_ELEMENT or END_ELEMENT event.
+ */
+ QName getName();
+
+ /**
+ * Returns the local-name of the current element.
+ */
+ String getLocalName();
+
+ /**
+ * Indicates whether the current event has a name.
+ */
+ boolean hasName();
+
+ /**
+ * Returns the namespace URI of the current element.
+ */
+ String getNamespaceURI();
+
+ /**
+ * Returns the namespace prefix of the current element.
+ */
+ String getPrefix();
+
+ /**
+ * Returns the XML version declared in the XML declaration.
+ */
+ String getVersion();
+
+ /**
+ * Returns the standalone flag declared in the XML declaration.
+ */
+ boolean isStandalone();
+
+ /**
+ * Indicates whether the standalone flag was set in the document.
+ */
+ boolean standaloneSet();
+
+ /**
+ * Returns the encoding declared in the XML declaration.
+ */
+ String getCharacterEncodingScheme();
+
+ /**
+ * Returns the target of the current processing instruction event.
+ */
+ String getPITarget();
+
+ /**
+ * Returns the data of the current processing instruction event.
+ */
+ String getPIData();
+
+}
+
--- /dev/null
+/* XMLStreamWriter.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., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 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 javax.xml.stream;
+
+import javax.xml.namespace.NamespaceContext;
+
+/**
+ * Interface for writing XML to a stream.
+ */
+public interface XMLStreamWriter
+{
+
+ /**
+ * Write the start of a tag.
+ */
+ void writeStartElement(String localName)
+ throws XMLStreamException;
+
+ /**
+ * Write the start of a tag.
+ */
+ void writeStartElement(String namespaceURI, String localName)
+ throws XMLStreamException;
+
+ /**
+ * Write the start of a tag.
+ */
+ void writeStartElement(String prefix, String localName, String namespaceURI)
+ throws XMLStreamException;
+
+ /**
+ * Write an empty tag.
+ */
+ void writeEmptyElement(String namespaceURI, String localName)
+ throws XMLStreamException;
+
+ /**
+ * Write an empty tag.
+ */
+ void writeEmptyElement(String prefix, String localName, String namespaceURI)
+ throws XMLStreamException;
+
+ /**
+ * Write an empty tag.
+ */
+ void writeEmptyElement(String localName)
+ throws XMLStreamException;
+
+ /**
+ * Closes the currently open tag.
+ */
+ void writeEndElement()
+ throws XMLStreamException;
+
+ /**
+ * Closes any currently open tags.
+ */
+ void writeEndDocument()
+ throws XMLStreamException;
+
+ /**
+ * Frees any resources used by this writer.
+ * This will not close the underlying output sink.
+ */
+ void close()
+ throws XMLStreamException;
+
+ /**
+ * Flushes any cached information to the underlying output sink.
+ */
+ void flush()
+ throws XMLStreamException;
+
+ /**
+ * Write an attribute.
+ */
+ void writeAttribute(String localName, String value)
+ throws XMLStreamException;
+
+ /**
+ * Write an attribute.
+ */
+ void writeAttribute(String prefix, String namespaceURI,
+ String localName, String value)
+ throws XMLStreamException;
+
+ /**
+ * Write an attribute.
+ */
+ void writeAttribute(String namespaceURI, String localName, String value)
+ throws XMLStreamException;
+
+ /**
+ * Write a namespace declaration.
+ */
+ void writeNamespace(String prefix, String namespaceURI)
+ throws XMLStreamException;
+
+ /**
+ * Write a default namespace declaration.
+ */
+ void writeDefaultNamespace(String namespaceURI)
+ throws XMLStreamException;
+
+ /**
+ * Write a comment.
+ */
+ void writeComment(String data)
+ throws XMLStreamException;
+
+ /**
+ * Write a processing instruction.
+ */
+ void writeProcessingInstruction(String target)
+ throws XMLStreamException;
+
+ /**
+ * Write a processing instruction.
+ */
+ void writeProcessingInstruction(String target, String data)
+ throws XMLStreamException;
+
+ /**
+ * Write a CDATA section.
+ */
+ void writeCData(String data)
+ throws XMLStreamException;
+
+ /**
+ * Write a DOCTYPE declaration.
+ */
+ void writeDTD(String dtd)
+ throws XMLStreamException;
+
+ /**
+ * Write an entity reference.
+ */
+ void writeEntityRef(String name)
+ throws XMLStreamException;
+
+ /**
+ * Write an XML declaration.
+ */
+ void writeStartDocument()
+ throws XMLStreamException;
+
+ /**
+ * Write an XML declaration with the specified XML version.
+ */
+ void writeStartDocument(String version)
+ throws XMLStreamException;
+
+ /**
+ * Write an XML declaration with the specifed XML version and encoding.
+ */
+ void writeStartDocument(String encoding, String version)
+ throws XMLStreamException;
+
+ /**
+ * Write the specified text.
+ */
+ void writeCharacters(String text)
+ throws XMLStreamException;
+
+ /**
+ * Write the specified text.
+ */
+ void writeCharacters(char[] text, int start, int len)
+ throws XMLStreamException;
+
+ /**
+ * Returns the prefix associated with the given namespace URI.
+ */
+ String getPrefix(String uri)
+ throws XMLStreamException;
+
+ /**
+ * Sets the prefix for the given namespace URI.
+ */
+ void setPrefix(String prefix, String uri)
+ throws XMLStreamException;
+
+ /**
+ * Sets the URI for the default namespace.
+ */
+ void setDefaultNamespace(String uri)
+ throws XMLStreamException;
+
+ /**
+ * Sets the namespace context for namespace resolution.
+ */
+ void setNamespaceContext(NamespaceContext context)
+ throws XMLStreamException;
+
+ /**
+ * Returns the current namespace context.
+ */
+ NamespaceContext getNamespaceContext();
+
+ /**
+ * Returns the implementation-specific feature or property of the given
+ * name.
+ * @exception IllegalArgumentException if the property is not supported
+ */
+ Object getProperty(String name)
+ throws IllegalArgumentException;
+
+}
+
--- /dev/null
+/* Attribute.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., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 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 javax.xml.stream.events;
+
+import javax.xml.namespace.QName;
+
+/**
+ * An attribute event.
+ */
+public interface Attribute
+ extends XMLEvent
+{
+
+ /**
+ * Returns the name of this attribute.
+ */
+ QName getName();
+
+ /**
+ * Returns the normalized value of this attribute.
+ */
+ String getValue();
+
+ /**
+ * Returns the type of this attribute.
+ */
+ QName getDTDType();
+
+ /**
+ * Indicates whether this attribute was specified in the input source, or
+ * just defaulted by the DTD.
+ */
+ boolean isSpecified();
+
+}
+
--- /dev/null
+/* Characters.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., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 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 javax.xml.stream.events;
+
+/**
+ * A character data (text) event.
+ */
+public interface Characters
+ extends XMLEvent
+{
+
+ /**
+ * Returns the character data assocated with this event.
+ */
+ String getData();
+
+ /**
+ * Indicates whether this text is all whitespace.
+ */
+ boolean isWhiteSpace();
+
+ /**
+ * Indicates whether this is a CDATA section.
+ */
+ boolean isCData();
+
+ /**
+ * Indicates whether this text is all ignorable whitespace.
+ */
+ boolean isIgnorableWhiteSpace();
+
+}
+
--- /dev/null
+/* Comment.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., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 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 javax.xml.stream.events;
+
+/**
+ * A comment event.
+ */
+public interface Comment
+ extends XMLEvent
+{
+
+ /**
+ * Returns the comment text.
+ */
+ String getText();
+
+}
+
--- /dev/null
+/* DTD.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., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 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 javax.xml.stream.events;
+
+import java.util.List;
+
+/**
+ * A DOCTYPE declaration event.
+ */
+public interface DTD
+ extends XMLEvent
+{
+
+ /**
+ * Returns the body of the DTD, including the internal DTD subset.
+ */
+ String getDocumentTypeDeclaration();
+
+ /**
+ * Returns an implementation-specific representation of the DTD, or null
+ * if no such representation is available.
+ */
+ Object getProcessedDTD();
+
+ /**
+ * Returns the notations declared in the DTD.
+ */
+ List getNotations();
+
+ /**
+ * Returns the entities declared in the DTD.
+ */
+ List getEntities();
+
+}
+
--- /dev/null
+/* EndDocument.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., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 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 javax.xml.stream.events;
+
+/**
+ * An end-document event.
+ */
+public interface EndDocument
+ extends XMLEvent
+{
+}
+
--- /dev/null
+/* EndElement.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., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 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 javax.xml.stream.events;
+
+import java.util.Iterator;
+import javax.xml.namespace.QName;
+
+/**
+ * An end-element event.
+ */
+public interface EndElement
+ extends XMLEvent
+{
+
+ /**
+ * Returns the element name.
+ */
+ QName getName();
+
+ /**
+ * Returns the namespaces that have gone out of scope.
+ */
+ Iterator getNamespaces();
+
+}
+
--- /dev/null
+/* EndEntity.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., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 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 javax.xml.stream.events;
+
+/**
+ * An end-entity event.
+ */
+public interface EndEntity
+ extends XMLEvent
+{
+
+ /**
+ * Returns the entity name.
+ */
+ String getName();
+
+}
+
--- /dev/null
+/* EntityDeclaration.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., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 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 javax.xml.stream.events;
+
+/**
+ * An entity declaration event.
+ */
+public interface EntityDeclaration
+ extends XMLEvent
+{
+
+ /**
+ * Returns the public identifier of the entity.
+ */
+ String getPublicId();
+
+ /**
+ * Returns the system identifier of the entity.
+ */
+ String getSystemId();
+
+ /**
+ * Returns the name of the entity.
+ */
+ String getName();
+
+ /**
+ * Returns the name of the associated notation.
+ */
+ String getNotationName();
+
+ /**
+ * Returns the replacement text for the entity.
+ */
+ //String getReplacementText();
+
+ /**
+ * Returns the base URI for the entity.
+ */
+ //String getBaseURI();
+
+}
+
--- /dev/null
+/* EntityReference.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., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 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 javax.xml.stream.events;
+
+/**
+ * An entity reference event.
+ */
+public interface EntityReference
+ extends XMLEvent
+{
+
+ /**
+ * Returns the base URI for the entity.
+ */
+ String getBaseUri();
+
+ /**
+ * Returns the public identifier for the entity.
+ */
+ String getPublicId();
+
+ /**
+ * Returns the system identifierfor the entity.
+ */
+ String getSystemId();
+
+ /**
+ * Returns the declaration of this reference.
+ */
+ //EntityDeclaration getDeclaration();
+
+ /**
+ * Returns the entity name.
+ */
+ String getName();
+
+ /**
+ * Returns the replacement text for the entity.
+ */
+ String getReplacementText();
+
+}
+
--- /dev/null
+/* Namespace.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., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 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 javax.xml.stream.events;
+
+/**
+ * A namespace declaration event.
+ */
+public interface Namespace
+ extends XMLEvent
+{
+
+ /**
+ * Returns the namespace prefix, if any.
+ */
+ String getPrefix();
+
+ /**
+ * Returns the namespace URI.
+ */
+ String getNamespaceURI();
+
+ /**
+ * Indicates whether this event declares the default namespace.
+ */
+ boolean isDefaultNamespaceDeclaration();
+
+}
+
--- /dev/null
+/* NotationDeclaration.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., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 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 javax.xml.stream.events;
+
+/**
+ * A notation declaration event.
+ */
+public interface NotationDeclaration
+ extends XMLEvent
+{
+
+ /**
+ * Returns the name of the notation.
+ */
+ String getName();
+
+ /**
+ * Returns the public identifier of the notation.
+ */
+ String getPublicId();
+
+ /**
+ * Returns the system identifier of the notation.
+ */
+ String getSystemId();
+
+}
+
--- /dev/null
+/* ProcessingInstruction.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., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 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 javax.xml.stream.events;
+
+/**
+ * A processing instruction event.
+ */
+public interface ProcessingInstruction
+ extends XMLEvent
+{
+
+ /**
+ * Returns the processing instruction target.
+ */
+ String getTarget();
+
+ /**
+ * Returns the processing instruction data.
+ */
+ String getData();
+
+}
+
--- /dev/null
+/* StartDocument.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., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 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 javax.xml.stream.events;
+
+/**
+ * A start-document event.
+ */
+public interface StartDocument
+ extends XMLEvent
+{
+
+ /**
+ * Returns the system identifier of the document entity.
+ */
+ String getSystemId();
+
+ /**
+ * Returns the character encoding of the document.
+ */
+ String getCharacterEncodingScheme();
+
+ /**
+ * Indicates whether the character encoding was set in the XML
+ * declaration.
+ */
+ boolean encodingSet();
+
+ /**
+ * Indicates whether the document is standalone.
+ */
+ boolean isStandalone();
+
+ /**
+ * Indicates whether the standalone parameter was set in the XML
+ * declaration.
+ */
+ boolean standaloneSet();
+
+ /**
+ * Returns the XML version of the document.
+ */
+ String getVersion();
+
+}
+
--- /dev/null
+/* StartElement.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., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 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 javax.xml.stream.events;
+
+import java.util.Iterator;
+import javax.xml.namespace.NamespaceContext;
+import javax.xml.namespace.QName;
+
+/**
+ * A start-element event.
+ */
+public interface StartElement
+ extends XMLEvent
+{
+
+ /**
+ * Returns the element name.
+ */
+ QName getName();
+
+ /**
+ * Returns the attributes declared on this element.
+ */
+ Iterator getAttributes();
+
+ /**
+ * Returns the namespaces declared on this element.
+ */
+ Iterator getNamespaces();
+
+ /**
+ * Returns an attribute by name.
+ */
+ Attribute getAttributeByName(QName name);
+
+ /**
+ * Returns a read-only namespace context associated with this event.
+ */
+ NamespaceContext getNamespaceContext();
+
+ /**
+ * Returns the namespace URI associated with the given prefix.
+ */
+ String getNamespaceURI(String prefix);
+
+}
+
--- /dev/null
+/* StartEntity.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., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 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 javax.xml.stream.events;
+
+/**
+ * An start-entity event.
+ */
+public interface StartEntity
+ extends XMLEvent
+{
+
+ /**
+ * Returns the entity name.
+ */
+ String getName();
+
+}
+
--- /dev/null
+/* XMLEvent.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., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 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 javax.xml.stream.events;
+
+import java.io.Writer;
+import javax.xml.namespace.QName;
+import javax.xml.stream.Location;
+import javax.xml.stream.XMLStreamConstants;
+import javax.xml.stream.XMLStreamException;
+
+/**
+ * An XML stream event.
+ */
+public interface XMLEvent
+ extends XMLStreamConstants
+{
+
+ /**
+ * Returns the type of this event.
+ */
+ int getEventType();
+
+ /**
+ * Returns the location of this event.
+ */
+ Location getLocation();
+
+ /**
+ * Indicates whether this event is a start-element event.
+ */
+ boolean isStartElement();
+
+ /**
+ * Indicates whether this event is an attribute event.
+ */
+ boolean isAttribute();
+
+ /**
+ * Indicates whether this event is a namespace declaration event.
+ */
+ boolean isNamespace();
+
+ /**
+ * Indicates whether this event is an end-element event.
+ */
+ boolean isEndElement();
+
+ /**
+ * Indicates whether this event is an entity reference event.
+ */
+ boolean isEntityReference();
+
+ /**
+ * Indicates whether this event is a processing instruction event.
+ */
+ boolean isProcessingInstruction();
+
+ /**
+ * Indicates whether this event is a text event.
+ */
+ boolean isCharacters();
+
+ /**
+ * Indicates whether this event is a start-document event.
+ */
+ boolean isStartDocument();
+
+ /**
+ * Indicates whether this event is an end-document event.
+ */
+ boolean isEndDocument();
+
+ /**
+ * Indicates whether this event is a start-entity event.
+ */
+ boolean isStartEntity();
+
+ /**
+ * Indicates whether this event is an end-entity event.
+ */
+ boolean isEndEntity();
+
+ /**
+ * Returns this event as a start-element event.
+ */
+ StartElement asStartElement();
+
+ /**
+ * Returns this event as an end-element event.
+ */
+ EndElement asEndElement();
+
+ /**
+ * Returns this event as a text event.
+ */
+ Characters asCharacters();
+
+ /**
+ * Returns schema-related type information about this event, or null if
+ * not available.
+ */
+ QName getSchemaType();
+
+ /**
+ * Writes this event to the specified writer.
+ */
+ void writeAsEncodedUnicode(Writer writer)
+ throws XMLStreamException;
+
+}
+
--- /dev/null
+/* EventReaderDelegate.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., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 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 javax.xml.stream.util;
+
+import java.util.NoSuchElementException;
+import javax.xml.stream.XMLStreamException;
+import javax.xml.stream.XMLEventReader;
+import javax.xml.stream.events.XMLEvent;
+
+/**
+ * Base class for event reader filters.
+ */
+public class EventReaderDelegate
+ implements XMLEventReader
+{
+
+ private XMLEventReader parent;
+
+ /**
+ * Constructs an empty filter with no parent set.
+ */
+ public EventReaderDelegate()
+ {
+ }
+
+ /**
+ * Constructs an empty filter with the given parent.
+ */
+ public EventReaderDelegate(XMLEventReader reader)
+ {
+ parent = reader;
+ }
+
+ /**
+ * Sets the parent.
+ */
+ public void setParent(XMLEventReader reader)
+ {
+ parent = reader;
+ }
+
+ /**
+ * Returns the parent.
+ */
+ public XMLEventReader getParent()
+ {
+ return parent;
+ }
+
+ public XMLEvent next()
+ throws XMLStreamException
+ {
+ if (parent != null)
+ return parent.next();
+ throw new NoSuchElementException();
+ }
+
+ public boolean hasNext()
+ throws XMLStreamException
+ {
+ if (parent != null)
+ return parent.hasNext();
+ return false;
+ }
+
+ public XMLEvent peek()
+ throws XMLStreamException
+ {
+ if (parent != null)
+ return parent.peek();
+ return null;
+ }
+
+ public String getElementText()
+ throws XMLStreamException
+ {
+ if (parent != null)
+ return parent.getElementText();
+ throw new XMLStreamException();
+ }
+
+ public XMLEvent nextTag()
+ throws XMLStreamException
+ {
+ if (parent != null)
+ return parent.nextTag();
+ throw new XMLStreamException();
+ }
+
+ public Object getProperty(String name)
+ throws IllegalArgumentException
+ {
+ if (parent != null)
+ return parent.getProperty(name);
+ throw new IllegalArgumentException(name);
+ }
+
+}
+
--- /dev/null
+/* ReaderDelegate.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., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 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 javax.xml.stream.util;
+
+import javax.xml.namespace.NamespaceContext;
+import javax.xml.namespace.QName;
+import javax.xml.stream.Location;
+import javax.xml.stream.XMLStreamConstants;
+import javax.xml.stream.XMLStreamException;
+import javax.xml.stream.XMLStreamReader;
+
+/**
+ * Base class for XML stream reader filters.
+ */
+public class ReaderDelegate
+ implements XMLStreamReader, XMLStreamConstants
+{
+
+ private XMLStreamReader parent;
+
+ /**
+ * Constructs an empty filter with no parent set.
+ */
+ public ReaderDelegate()
+ {
+ }
+
+ /**
+ * Constructs an empty filter with the specfied parent.
+ */
+ public ReaderDelegate(XMLStreamReader reader)
+ {
+ parent = reader;
+ }
+
+ /**
+ * Sets the parent.
+ */
+ public void setParent(XMLStreamReader reader)
+ {
+ parent = reader;
+ }
+
+ /**
+ * Returns the parent.
+ */
+ public XMLStreamReader getParent()
+ {
+ return parent;
+ }
+
+ public int next()
+ throws XMLStreamException
+ {
+ if (parent != null)
+ return parent.next();
+ throw new XMLStreamException();
+ }
+
+ public int nextTag()
+ throws XMLStreamException
+ {
+ if (parent != null)
+ return parent.nextTag();
+ throw new XMLStreamException();
+ }
+
+ public String getElementText()
+ throws XMLStreamException
+ {
+ if (parent != null)
+ return parent.getElementText();
+ throw new XMLStreamException();
+ }
+
+ public void require(int type, String namespaceURI, String localName)
+ throws XMLStreamException
+ {
+ if (parent != null)
+ parent.require(type, namespaceURI, localName);
+ }
+
+ public boolean hasNext()
+ throws XMLStreamException
+ {
+ if (parent != null)
+ return parent.hasNext();
+ return false;
+ }
+
+ public void close()
+ throws XMLStreamException
+ {
+ if (parent != null)
+ parent.close();
+ }
+
+ public String getNamespaceURI(String prefix)
+ {
+ if (parent != null)
+ return parent.getNamespaceURI(prefix);
+ return null;
+ }
+
+ public NamespaceContext getNamespaceContext()
+ {
+ if (parent != null)
+ return parent.getNamespaceContext();
+ return null;
+ }
+
+ public boolean isStartElement()
+ {
+ if (parent != null)
+ return parent.isStartElement();
+ return false;
+ }
+
+ public boolean isEndElement()
+ {
+ if (parent != null)
+ return parent.isEndElement();
+ return false;
+ }
+
+ public boolean isCharacters()
+ {
+ if (parent != null)
+ return parent.isCharacters();
+ return false;
+ }
+
+ public boolean isWhiteSpace()
+ {
+ if (parent != null)
+ return parent.isWhiteSpace();
+ return false;
+ }
+
+ public String getAttributeValue(String namespaceUri, String localName)
+ {
+ if (parent != null)
+ return parent.getAttributeValue(namespaceUri, localName);
+ return null;
+ }
+
+ public int getAttributeCount()
+ {
+ if (parent != null)
+ return parent.getAttributeCount();
+ return 0;
+ }
+
+ public QName getAttributeQName(int index)
+ {
+ if (parent != null)
+ return parent.getAttributeQName(index);
+ return null;
+ }
+
+ public String getAttributePrefix(int index)
+ {
+ if (parent != null)
+ return parent.getAttributePrefix(index);
+ return null;
+ }
+
+ public String getAttributeNamespace(int index)
+ {
+ if (parent != null)
+ return parent.getAttributeNamespace(index);
+ return null;
+ }
+
+ public String getAttributeName(int index)
+ {
+ if (parent != null)
+ return parent.getAttributeName(index);
+ return null;
+ }
+
+ public String getAttributeType(int index)
+ {
+ if (parent != null)
+ return parent.getAttributeType(index);
+ return null;
+ }
+
+ public String getAttributeValue(int index)
+ {
+ if (parent != null)
+ return parent.getAttributeValue(index);
+ return null;
+ }
+
+ public boolean isAttributeSpecified(int index)
+ {
+ if (parent != null)
+ return parent.isAttributeSpecified(index);
+ return false;
+ }
+
+ public int getNamespaceCount()
+ {
+ if (parent != null)
+ return parent.getNamespaceCount();
+ return 0;
+ }
+
+ public String getNamespacePrefix(int index)
+ {
+ if (parent != null)
+ return parent.getNamespacePrefix(index);
+ return null;
+ }
+
+ public String getNamespaceURI(int index)
+ {
+ if (parent != null)
+ return parent.getNamespaceURI(index);
+ return null;
+ }
+
+ public int getEventType()
+ {
+ if (parent != null)
+ return parent.getEventType();
+ return 0;
+ }
+
+ public String getText()
+ {
+ if (parent != null)
+ return parent.getText();
+ return null;
+ }
+
+ public int getTextCharacters(int sourceStart, char[] target,
+ int targetStart, int length)
+ throws XMLStreamException
+ {
+ if (parent != null)
+ return parent.getTextCharacters(sourceStart, target, targetStart, length);
+ return 0;
+ }
+
+ public char[] getTextCharacters()
+ {
+ if (parent != null)
+ return parent.getTextCharacters();
+ return null;
+ }
+
+ public int getTextStart()
+ {
+ if (parent != null)
+ return parent.getTextStart();
+ return 0;
+ }
+
+ public int getTextLength()
+ {
+ if (parent != null)
+ return parent.getTextLength();
+ return 0;
+ }
+
+ public String getEncoding()
+ {
+ if (parent != null)
+ return parent.getEncoding();
+ return null;
+ }
+
+ public boolean hasText()
+ {
+ if (parent != null)
+ return parent.hasText();
+ return false;
+ }
+
+ public Location getLocation()
+ {
+ if (parent != null)
+ return parent.getLocation();
+ return null;
+ }
+
+ public QName getName()
+ {
+ if (parent != null)
+ return parent.getName();
+ return null;
+ }
+
+ public String getLocalName()
+ {
+ if (parent != null)
+ return parent.getLocalName();
+ return null;
+ }
+
+ public boolean hasName()
+ {
+ if (parent != null)
+ return parent.hasName();
+ return false;
+ }
+
+ public String getNamespaceURI()
+ {
+ if (parent != null)
+ return parent.getNamespaceURI();
+ return null;
+ }
+
+ public String getPrefix()
+ {
+ if (parent != null)
+ return parent.getPrefix();
+ return null;
+ }
+
+ public String getVersion()
+ {
+ if (parent != null)
+ return parent.getVersion();
+ return null;
+ }
+
+ public boolean isStandalone()
+ {
+ if (parent != null)
+ return parent.isStandalone();
+ return false;
+ }
+
+ public boolean standaloneSet()
+ {
+ if (parent != null)
+ return parent.standaloneSet();
+ return false;
+ }
+
+ public String getCharacterEncodingScheme()
+ {
+ if (parent != null)
+ return parent.getCharacterEncodingScheme();
+ return null;
+ }
+
+ public String getPITarget()
+ {
+ if (parent != null)
+ return parent.getPITarget();
+ return null;
+ }
+
+ public String getPIData()
+ {
+ if (parent != null)
+ return parent.getPIData();
+ return null;
+ }
+
+ public Object getProperty(String name)
+ {
+ if (parent != null)
+ return parent.getProperty(name);
+ throw new IllegalArgumentException();
+ }
+
+}
+
--- /dev/null
+/* XMLEventAllocator.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., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 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 javax.xml.stream.util;
+
+import javax.xml.stream.XMLStreamReader;
+import javax.xml.stream.XMLStreamException;
+import javax.xml.stream.events.XMLEvent;
+
+/**
+ * Interface for allocating events according to a stream reader.
+ */
+public interface XMLEventAllocator
+{
+
+ /**
+ * Creates a new allocator.
+ */
+ XMLEventAllocator newInstance();
+
+ /**
+ * Allocates an event based on the current state of the stream reader.
+ */
+ XMLEvent allocate(XMLStreamReader reader)
+ throws XMLStreamException;
+
+ /**
+ * Allocates one or more events based on the current state of the stream
+ * reader and adds those events to the specified consumer.
+ */
+ void allocate(XMLStreamReader reader, XMLEventConsumer consumer)
+ throws XMLStreamException;
+
+}
+
--- /dev/null
+/* XMLEventConsumer.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., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 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 javax.xml.stream.util;
+
+import javax.xml.stream.XMLStreamException;
+import javax.xml.stream.events.XMLEvent;
+
+/**
+ * Interface for consuming XML events.
+ */
+public interface XMLEventConsumer
+{
+
+ /**
+ * Consumes an event.
+ */
+ void add(XMLEvent event)
+ throws XMLStreamException;
+
+}
+
--- /dev/null
+*.o
+*.a
+*.lo
+*.la
+.libs
+.deps
+Makefile
+Makefile.in
--- /dev/null
+pkglib_LTLIBRARIES = libjawtgnu.la
+
+libjawtgnu_la_SOURCES = jawt.c
+libjawtgnu_la_LIBADD = $(top_builddir)/native/jni/gtk-peer/libgtkpeer.la
+# FIXME: libtool doesn't allow overriding SONAME, but we need to set
+# it to libjawt.so for binary compatibility.
+#
+# libjawtgnu_la_LDFLAGS = -Wl,-soname -Wl,libjawt.so
+
+AM_LDFLAGS = @CLASSPATH_MODULE@ @GTK_LIBS@ @CAIRO_LIBS@ @PANGOFT2_LIBS@ @X_LIBS@ -lXtst
+AM_CPPFLAGS = @CLASSPATH_INCLUDES@
+
+# Just the WARNING_CFLAGS. We cannot use the strict flags since the gtk
+# headers contain broken prototypes (by design, see gtkitemfactory.h).
+AM_CFLAGS = @WARNING_CFLAGS@ @ERROR_CFLAGS@ \
+ @GTK_CFLAGS@ @CAIRO_CFLAGS@ @PANGOFT2_CFLAGS@
--- /dev/null
+/* jawt.c -- X11 implementation of the AWT Native Interface
+ 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., 51 Franklin Street, Fifth Floor, Boston, MA
+ 02110-1301 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 <stdlib.h>
+#include <jni.h>
+#include <jawt.h>
+#include <jawt_md.h>
+#include "classpath_jawt.h"
+
+#ifndef __GNUC__
+#define __attribute__(x) /* nothing */
+#endif
+
+static jint (JNICALL _Jv_Lock) (JAWT_DrawingSurface* surface);
+static void (JNICALL _Jv_Unlock) (JAWT_DrawingSurface* surface);
+static JAWT_DrawingSurfaceInfo* (JNICALL _Jv_GetDrawingSurfaceInfo)
+ (JAWT_DrawingSurface* surface);
+static void (JNICALL _Jv_FreeDrawingSurfaceInfo)
+ (JAWT_DrawingSurfaceInfo* surface_info);
+static JAWT_DrawingSurface* (JNICALL _Jv_GetDrawingSurface) (JNIEnv* env,
+ jobject canvas);
+static void (JNICALL _Jv_FreeDrawingSurface) (JAWT_DrawingSurface* surface);
+static void (JNICALL _Jv_AWTLock) (JNIEnv*);
+static void (JNICALL _Jv_AWTUnlock) (JNIEnv*);
+
+JNIEXPORT jboolean JNICALL
+JAWT_GetAWT (JNIEnv* env __attribute__((unused)), JAWT* awt)
+{
+ jint retrieved_version;
+
+ retrieved_version = classpath_jawt_get_awt_version ();
+
+ if (awt->version > retrieved_version)
+ return JNI_FALSE;
+
+ awt->GetDrawingSurface = _Jv_GetDrawingSurface;
+ awt->FreeDrawingSurface = _Jv_FreeDrawingSurface;
+ awt->Lock = _Jv_AWTLock;
+ awt->Unlock = _Jv_AWTUnlock;
+
+ return JNI_TRUE;
+}
+
+/* JAWT_DrawingSurface functions */
+
+static jint
+(JNICALL _Jv_Lock) (JAWT_DrawingSurface* surface __attribute__((unused)))
+{
+ return classpath_jawt_lock ();
+}
+
+static void
+(JNICALL _Jv_Unlock) (JAWT_DrawingSurface* surface __attribute__((unused)))
+{
+ classpath_jawt_unlock ();
+}
+
+static JAWT_DrawingSurfaceInfo*
+(JNICALL _Jv_GetDrawingSurfaceInfo) (JAWT_DrawingSurface* surface)
+{
+ JAWT_DrawingSurfaceInfo* surface_info;
+ JAWT_X11DrawingSurfaceInfo* surface_info_x11;
+
+ if (surface == NULL || surface->target == NULL)
+ return NULL;
+
+ surface_info = (JAWT_DrawingSurfaceInfo*) malloc (sizeof (JAWT_DrawingSurfaceInfo));
+
+ if (surface_info == NULL)
+ return NULL;
+
+ surface_info->platformInfo = malloc (sizeof (JAWT_X11DrawingSurfaceInfo));
+
+ if (surface_info->platformInfo == NULL)
+ return NULL;
+
+ surface_info_x11 = (JAWT_X11DrawingSurfaceInfo*) surface_info->platformInfo;
+
+ surface_info_x11->display = classpath_jawt_get_default_display (surface->env,
+ surface->target);
+ surface_info_x11->drawable = classpath_jawt_get_drawable (surface->env,
+ surface->target);
+ surface_info_x11->visualID = classpath_jawt_get_visualID (surface->env,
+ surface->target);
+
+ /* FIXME: also include bounding rectangle of drawing surface */
+ /* FIXME: also include current clipping region */
+
+ return surface_info;
+}
+
+static void
+(JNICALL _Jv_FreeDrawingSurfaceInfo) (JAWT_DrawingSurfaceInfo* surface_info)
+{
+ JAWT_X11DrawingSurfaceInfo* surface_info_x11;
+
+ if (surface_info == NULL)
+ return;
+
+ surface_info_x11 = (JAWT_X11DrawingSurfaceInfo*) surface_info->platformInfo;
+
+ surface_info_x11->display = NULL;
+ surface_info_x11->drawable = 0;
+ surface_info_x11->visualID = 0;
+
+ free (surface_info->platformInfo);
+ free (surface_info);
+ surface_info = NULL;
+}
+
+/* JAWT functions */
+
+static JAWT_DrawingSurface*
+(JNICALL _Jv_GetDrawingSurface) (JNIEnv* env, jobject canvas)
+{
+ JAWT_DrawingSurface* surface;
+
+ surface = (JAWT_DrawingSurface*) malloc (sizeof (JAWT_DrawingSurface));
+
+ if (surface == NULL)
+ return NULL;
+
+ surface->env = env;
+ surface->target = canvas;
+
+ /* initialize function pointers */
+ surface->GetDrawingSurfaceInfo = _Jv_GetDrawingSurfaceInfo;
+ surface->FreeDrawingSurfaceInfo = _Jv_FreeDrawingSurfaceInfo;
+
+ surface->Lock = _Jv_Lock;
+ surface->Unlock = _Jv_Unlock;
+
+ return surface;
+}
+
+static void
+(JNICALL _Jv_FreeDrawingSurface) (JAWT_DrawingSurface* surface)
+{
+ free (surface);
+}
+
+static void
+(JNICALL _Jv_AWTLock) (JNIEnv* env __attribute__((unused)))
+{
+ classpath_jawt_lock ();
+}
+
+static void
+(JNICALL _Jv_AWTUnlock) (JNIEnv* env __attribute__((unused)))
+{
+ classpath_jawt_unlock ();
+}
--- /dev/null
+/* gtkselection.c -- Native C functions for GtkSelection class using gtk+.
+ 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., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 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 "jcl.h"
+#include "gtkpeer.h"
+#include "gnu_java_awt_peer_gtk_GtkSelection.h"
+
+static jmethodID mimeTypesAvailableID;
+
+/* Note this is actually just a GtkClipboardReceivedFunc, not a real
+ GtkClipboardTargetsReceivedFunc, see requestMimeTypes. */
+static void
+clipboard_targets_received (GtkClipboard *clipboard
+ __attribute__((unused)),
+ GtkSelectionData *target_data,
+ gpointer selection)
+{
+ GdkAtom *targets = NULL;
+ gint targets_len = 0;
+ gchar **target_strings = NULL;
+ jobjectArray strings = NULL;
+ int strings_len = 0;
+ gboolean include_text = FALSE;
+ gboolean include_image = FALSE;
+ gboolean include_uris = FALSE;
+ jobject selection_obj = (jobject) selection;
+ JNIEnv *env = cp_gtk_gdk_env ();
+
+ if (target_data != NULL && target_data->length > 0)
+ {
+ include_text = gtk_selection_data_targets_include_text (target_data);
+
+#if GTK_MINOR_VERSION > 4
+ include_image = gtk_selection_data_targets_include_image (target_data,
+ TRUE);
+#endif
+ if (gtk_selection_data_get_targets (target_data, &targets, &targets_len))
+ {
+ int i;
+ GdkAtom uri_list_atom = gdk_atom_intern ("text/uri-list", FALSE);
+ target_strings = g_new (gchar*, targets_len);
+ if (target_strings != NULL)
+ for (i = 0; i < targets_len; i++)
+ {
+ gchar *name = gdk_atom_name (targets[i]);
+ if (strchr (name, '/') != NULL)
+ {
+ target_strings[i] = name;
+ strings_len++;
+ if (! include_uris && targets[i] == uri_list_atom)
+ include_uris = TRUE;
+ }
+ else
+ target_strings[i] = NULL;
+ }
+ }
+
+ if (target_strings != NULL)
+ {
+ int i = 0, j = 0;
+ jclass stringClass;
+
+ if (include_text)
+ strings_len++;
+ if (include_image)
+ strings_len++;
+ if (include_uris)
+ strings_len++;
+
+ stringClass = (*env)->FindClass (env, "java/lang/String");
+ strings = (*env)->NewObjectArray (env, strings_len, stringClass,
+ NULL);
+ if (strings != NULL)
+ {
+ if (include_text)
+ (*env)->SetObjectArrayElement (env, strings, i++,
+ cp_gtk_stringTarget);
+ if (include_image)
+ (*env)->SetObjectArrayElement (env, strings, i++,
+ cp_gtk_imageTarget);
+ if (include_uris)
+ (*env)->SetObjectArrayElement (env, strings, i++,
+ cp_gtk_filesTarget);
+
+ while(i < strings_len)
+ {
+ if (target_strings[j] == NULL)
+ j++;
+ else
+ {
+ jstring string;
+ string = (*env)->NewStringUTF (env,
+ target_strings[j++]);
+ if (string == NULL)
+ break;
+ (*env)->SetObjectArrayElement (env, strings, i++,
+ string);
+ }
+ }
+ }
+
+ for (i = 0; i < targets_len; i++)
+ g_free (target_strings[i]);
+ g_free (target_strings);
+ }
+ }
+
+ (*env)->CallVoidMethod (env, selection_obj,
+ mimeTypesAvailableID,
+ strings);
+ (*env)->DeleteGlobalRef (env, selection_obj);
+}
+
+JNIEXPORT void JNICALL
+Java_gnu_java_awt_peer_gtk_GtkSelection_requestMimeTypes
+(JNIEnv *env, jobject selection)
+{
+ jobject selection_obj;
+ selection_obj = (*env)->NewGlobalRef(env, selection);
+ if (selection_obj == NULL)
+ return;
+
+ if (mimeTypesAvailableID == NULL)
+ {
+ jclass gtk_selection_class;
+ gtk_selection_class = (*env)->GetObjectClass (env, selection_obj);
+ mimeTypesAvailableID = (*env)->GetMethodID (env, gtk_selection_class,
+ "mimeTypesAvailable",
+ "([Ljava/lang/String;)V");
+ if (mimeTypesAvailableID == NULL)
+ return;
+ }
+
+ /* We would have liked to call gtk_clipboard_request_targets ()
+ since that is more general. But the result of that, an array of
+ GdkAtoms, cannot be used with the
+ gtk_selection_data_targets_include_<x> functions (despite what
+ the name suggests). */
+ gdk_threads_enter ();
+ gtk_clipboard_request_contents (cp_gtk_clipboard,
+ gdk_atom_intern ("TARGETS", FALSE),
+ clipboard_targets_received,
+ (gpointer) selection_obj);
+ gdk_threads_leave ();
+}
+
+
+static jmethodID textAvailableID;
+
+static void
+clipboard_text_received (GtkClipboard *clipboard
+ __attribute__((unused)),
+ const gchar *text,
+ gpointer selection)
+{
+ jstring string;
+ jobject selection_obj = (jobject) selection;
+
+ JNIEnv *env = cp_gtk_gdk_env ();
+ if (text != NULL)
+ string = (*env)->NewStringUTF (env, text);
+ else
+ string = NULL;
+
+ (*env)->CallVoidMethod (env, selection_obj,
+ textAvailableID,
+ string);
+ (*env)->DeleteGlobalRef (env, selection_obj);
+}
+
+JNIEXPORT void JNICALL
+Java_gnu_java_awt_peer_gtk_GtkSelection_requestText
+(JNIEnv *env, jobject selection)
+{
+ jobject selection_obj;
+ selection_obj = (*env)->NewGlobalRef(env, selection);
+ if (selection_obj == NULL)
+ return;
+
+ if (textAvailableID == NULL)
+ {
+ jclass gtk_selection_class;
+ gtk_selection_class = (*env)->GetObjectClass (env, selection_obj);
+ textAvailableID = (*env)->GetMethodID (env, gtk_selection_class,
+ "textAvailable",
+ "(Ljava/lang/String;)V");
+ if (textAvailableID == NULL)
+ return;
+ }
+
+ gdk_threads_enter ();
+ gtk_clipboard_request_text (cp_gtk_clipboard,
+ clipboard_text_received,
+ (gpointer) selection_obj);
+ gdk_threads_leave ();
+}
+
+static jmethodID imageAvailableID;
+
+static void
+clipboard_image_received (GtkClipboard *clipboard
+ __attribute__((unused)),
+ GdkPixbuf *pixbuf,
+ gpointer selection)
+{
+ jobject pointer = NULL;
+ jobject selection_obj = (jobject) selection;
+ JNIEnv *env = cp_gtk_gdk_env ();
+
+ if (pixbuf != NULL)
+ {
+ g_object_ref (pixbuf);
+ pointer = JCL_NewRawDataObject (env, (void *) pixbuf);
+ }
+
+ (*env)->CallVoidMethod (env, selection_obj,
+ imageAvailableID,
+ pointer);
+ (*env)->DeleteGlobalRef (env, selection_obj);
+}
+
+JNIEXPORT void JNICALL
+Java_gnu_java_awt_peer_gtk_GtkSelection_requestImage (JNIEnv *env, jobject obj)
+{
+ jobject selection_obj;
+ selection_obj = (*env)->NewGlobalRef(env, obj);
+ if (selection_obj == NULL)
+ return;
+
+ if (imageAvailableID == NULL)
+ {
+ jclass gtk_selection_class;
+ gtk_selection_class = (*env)->GetObjectClass (env, selection_obj);
+ imageAvailableID = (*env)->GetMethodID (env, gtk_selection_class,
+ "imageAvailable",
+ "(Lgnu/classpath/Pointer;)V");
+ if (imageAvailableID == NULL)
+ return;
+ }
+
+#if GTK_MINOR_VERSION > 4
+ gdk_threads_enter ();
+ gtk_clipboard_request_image (cp_gtk_clipboard,
+ clipboard_image_received,
+ (gpointer) selection_obj);
+ gdk_threads_leave ();
+#else
+ clipboard_image_received (cp_gtk_clipboard, NULL, (gpointer) selection_obj);
+#endif
+}
+
+static jmethodID urisAvailableID;
+
+static void
+clipboard_uris_received (GtkClipboard *clipboard
+ __attribute__((unused)),
+ GtkSelectionData *uri_data,
+ gpointer selection)
+{
+ gchar **uris = NULL;
+ jobjectArray strings = NULL;
+ jobject selection_obj = (jobject) selection;
+ JNIEnv *env = cp_gtk_gdk_env ();
+
+#if GTK_MINOR_VERSION > 4
+ if (uri_data != NULL)
+ uris = gtk_selection_data_get_uris (uri_data);
+#else
+ if (uri_data != NULL)
+ uris = NULL;
+#endif
+
+ if (uris != NULL)
+ {
+ int len, i;
+ gchar **count = uris;
+ jclass stringClass = (*env)->FindClass (env, "java/lang/String");
+
+ len = 0;
+ while (count[len])
+ len++;
+
+ strings = (*env)->NewObjectArray (env, len, stringClass, NULL);
+ if (strings != NULL)
+ {
+ for (i = 0; i < len; i++)
+ {
+ jstring string = (*env)->NewStringUTF (env, uris[i]);
+ if (string == NULL)
+ break;
+ (*env)->SetObjectArrayElement (env, strings, i, string);
+ }
+ }
+ g_strfreev (uris);
+ }
+
+ (*env)->CallVoidMethod (env, selection_obj,
+ urisAvailableID,
+ strings);
+ (*env)->DeleteGlobalRef (env, selection_obj);
+}
+
+JNIEXPORT void JNICALL
+Java_gnu_java_awt_peer_gtk_GtkSelection_requestURIs (JNIEnv *env, jobject obj)
+{
+#if GTK_MINOR_VERSION > 4
+ GdkAtom uri_atom;
+#endif
+ jobject selection_obj;
+ selection_obj = (*env)->NewGlobalRef(env, obj);
+ if (selection_obj == NULL)
+ return;
+
+ if (urisAvailableID == NULL)
+ {
+ jclass gtk_selection_class;
+ gtk_selection_class = (*env)->GetObjectClass (env, selection_obj);
+ urisAvailableID = (*env)->GetMethodID (env, gtk_selection_class,
+ "urisAvailable",
+ "([Ljava/lang/String;)V");
+ if (urisAvailableID == NULL)
+ return;
+ }
+
+#if GTK_MINOR_VERSION > 4
+ /* There is no real request_uris so we have to make one ourselves. */
+ gdk_threads_enter ();
+ uri_atom = gdk_atom_intern ("text/uri-list", FALSE);
+ gtk_clipboard_request_contents (cp_gtk_clipboard,
+ uri_atom,
+ clipboard_uris_received,
+ (gpointer) selection_obj);
+ gdk_threads_leave ();
+#else
+ clipboard_uris_received (cp_gtk_clipboard, NULL, (gpointer) selection_obj);
+#endif
+}
+
+static jmethodID bytesAvailableID;
+
+static void
+clipboard_bytes_received (GtkClipboard *clipboard
+ __attribute__((unused)),
+ GtkSelectionData *selection_data,
+ gpointer selection)
+{
+ jbyteArray bytes = NULL;
+ jobject selection_obj = (jobject) selection;
+ JNIEnv *env = cp_gtk_gdk_env ();
+
+ if (selection_data != NULL && selection_data->length > 0)
+ {
+ bytes = (*env)->NewByteArray (env, selection_data->length);
+ if (bytes != NULL)
+ (*env)->SetByteArrayRegion(env, bytes, 0, selection_data->length,
+ (jbyte *) selection_data->data);
+ }
+
+ (*env)->CallVoidMethod (env, selection_obj,
+ bytesAvailableID,
+ bytes);
+ (*env)->DeleteGlobalRef (env, selection_obj);
+}
+
+JNIEXPORT void JNICALL
+Java_gnu_java_awt_peer_gtk_GtkSelection_requestBytes (JNIEnv *env,
+ jobject obj,
+ jstring target_string)
+{
+ int len;
+ const gchar *target_text;
+ GdkAtom target_atom;
+ jobject selection_obj;
+ selection_obj = (*env)->NewGlobalRef(env, obj);
+ if (selection_obj == NULL)
+ return;
+
+ if (bytesAvailableID == NULL)
+ {
+ jclass gtk_selection_class;
+ gtk_selection_class = (*env)->GetObjectClass (env, selection_obj);
+ bytesAvailableID = (*env)->GetMethodID (env, gtk_selection_class,
+ "bytesAvailable",
+ "([B)V");
+ if (bytesAvailableID == NULL)
+ return;
+ }
+
+ len = (*env)->GetStringUTFLength (env, target_string);
+ if (len == -1)
+ return;
+ target_text = (*env)->GetStringUTFChars (env, target_string, NULL);
+ if (target_text == NULL)
+ return;
+
+ gdk_threads_enter ();
+ target_atom = gdk_atom_intern (target_text, FALSE);
+ gtk_clipboard_request_contents (cp_gtk_clipboard,
+ target_atom,
+ clipboard_bytes_received,
+ (gpointer) selection_obj);
+ gdk_threads_leave ();
+
+ (*env)->ReleaseStringUTFChars (env, target_string, target_text);
+}
--- /dev/null
+/* gtk_jawt.c -- GTK implementation of classpath_jawt.h
+ 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., 51 Franklin Street, Fifth Floor, Boston, MA
+ 02110-1301 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 <gtk/gtk.h>
+#include <gdk/gdkx.h>
+#include "classpath_jawt.h"
+
+jint
+classpath_jawt_get_awt_version ()
+{
+ return CLASSPATH_JAWT_VERSION;
+}
+
+/* Does not require locking: meant to be called after the drawing
+ surface is locked. */
+Display*
+classpath_jawt_get_default_display (JNIEnv* env, jobject canvas)
+{
+ GdkDisplay *display;
+ Display *xdisplay;
+ GtkWidget *widget;
+ void *ptr;
+ jobject peer;
+ jclass class_id;
+ jmethodID method_id;
+
+ /* retrieve peer object */
+ class_id = (*env)->GetObjectClass (env, canvas);
+
+ method_id = (*env)->GetMethodID (env, class_id,
+ "getPeer",
+ "()Ljava/awt/peer/ComponentPeer;");
+
+ peer = (*env)->CallObjectMethod (env, canvas, method_id);
+
+ ptr = NSA_GET_PTR (env, peer);
+
+ widget = GTK_WIDGET (ptr);
+
+ if (GTK_WIDGET_REALIZED (widget))
+ {
+ display = gtk_widget_get_display (widget);
+
+ xdisplay = GDK_DISPLAY_XDISPLAY (display);
+
+ return xdisplay;
+ }
+ else
+ return NULL;
+}
+
+/* Does not require locking: meant to be called after the drawing
+ surface is locked. */
+VisualID
+classpath_jawt_get_visualID (JNIEnv* env, jobject canvas)
+{
+ GtkWidget *widget;
+ Visual *visual;
+ void *ptr;
+ jobject peer;
+ jclass class_id;
+ jmethodID method_id;
+
+ class_id = (*env)->GetObjectClass (env, canvas);
+
+ method_id = (*env)->GetMethodID (env, class_id,
+ "getPeer",
+ "()Ljava/awt/peer/ComponentPeer;");
+
+ peer = (*env)->CallObjectMethod (env, canvas, method_id);
+
+ ptr = NSA_GET_PTR (env, peer);
+
+ widget = GTK_WIDGET (ptr);
+
+ if (GTK_WIDGET_REALIZED (widget))
+ {
+ visual = gdk_x11_visual_get_xvisual (gtk_widget_get_visual (widget));
+ g_assert (visual != NULL);
+
+ return visual->visualid;
+ }
+ else
+ return (VisualID) NULL;
+}
+
+/* Does not require locking: meant to be called after the drawing
+ surface is locked. */
+Drawable
+classpath_jawt_get_drawable (JNIEnv* env, jobject canvas)
+{
+ GtkWidget *widget;
+ int drawable;
+ void *ptr;
+ jobject peer;
+ jclass class_id;
+ jmethodID method_id;
+
+ class_id = (*env)->GetObjectClass (env, canvas);
+
+ method_id = (*env)->GetMethodID (env, class_id,
+ "getPeer",
+ "()Ljava/awt/peer/ComponentPeer;");
+
+ peer = (*env)->CallObjectMethod (env, canvas, method_id);
+
+ ptr = NSA_GET_PTR (env, peer);
+
+ widget = GTK_WIDGET (ptr);
+
+ if (GTK_WIDGET_REALIZED (widget))
+ {
+ drawable = GDK_DRAWABLE_XID (widget->window);
+
+ return drawable;
+ }
+ else
+ return (Drawable) NULL;
+}
+
+jint
+classpath_jawt_lock ()
+{
+ gdk_threads_enter ();
+ return 0;
+}
+
+void
+classpath_jawt_unlock ()
+{
+ gdk_threads_leave ();
+}
--- /dev/null
+*.o
+*.a
+*.lo
+*.la
+.libs
+.deps
+Makefile
+Makefile.in
+slotcallbacks.moc.h
--- /dev/null
+# Qt AWT backend for Classpath
+#
+
+pkglib_LTLIBRARIES = libqtpeer.la
+
+AM_LDFLAGS = @CLASSPATH_MODULE@ @QT_LIBS@
+AM_CPPFLAGS = @CLASSPATH_INCLUDES@
+
+AM_CXXFLAGS = @QT_CFLAGS@
+
+libqtpeer_la_MOC = \
+ slotcallbacks.moc.h
+
+slotcallbacks.moc.h: slotcallbacks.cpp
+ $(MOC) -o slotcallbacks.moc.h $(srcdir)/slotcallbacks.cpp
+
+nodist_libqtpeer_la_SOURCES = \
+ $(libqtpeer_la_MOC)
+
+libqtpeer_la_SOURCES = \
+ buttonevent.h \
+ componentevent.cpp \
+ componentevent.h \
+ containers.h \
+ eventmethods.h \
+ keybindings.cpp \
+ keybindings.h \
+ mainqtthread.cpp \
+ mainthreadinterface.cpp \
+ mainthreadinterface.h \
+ nativewrapper.cpp \
+ nativewrapper.h \
+ qmatrix.cpp \
+ qpainterpath.cpp \
+ qpen.cpp \
+ qtaudioclip.cpp \
+ qtbuttonpeer.cpp \
+ qtcanvaspeer.cpp \
+ qtcheckboxpeer.cpp \
+ qtchoicepeer.cpp \
+ qtcomponent.cpp \
+ qtcomponent.h \
+ qtcomponentpeer.cpp \
+ qtdialogpeer.cpp \
+ qtembeddedwindowpeer.cpp \
+ qtfiledialogpeer.cpp \
+ qtfont.h \
+ qtfontmetrics.cpp \
+ qtfontpeer.cpp \
+ qtframepeer.cpp \
+ qtgraphics.cpp \
+ qtgraphics.h \
+ qtimage.cpp \
+ qtimage.h \
+ qtlabelpeer.cpp \
+ qtlistpeer.cpp \
+ qtmenubarpeer.cpp \
+ qtmenucomponentpeer.cpp \
+ qtmenuitempeer.cpp \
+ qtmenupeer.cpp \
+ qtpanelpeer.cpp \
+ qtpopupmenupeer.cpp \
+ qtscreendevice.cpp \
+ qtscrollbarpeer.cpp \
+ qtscrollpanepeer.cpp \
+ qtstrings.cpp \
+ qtstrings.h \
+ qttextareapeer.cpp \
+ qttextfieldpeer.cpp \
+ qttoolkit.cpp \
+ qtvolatileimage.cpp \
+ qtwindowpeer.cpp \
+ slotcallbacks.cpp \
+ slotcallbacks.h
+
+BUILT_SOURCES = $(libqtpeer_la_MOC)
+
+CLEANFILES = so_locations $(BUILT_SOURCES)
--- /dev/null
+#ifndef BUTTONEVENT_H
+#define BUTTONEVENT_H
+
+#include <QAbstractButton>
+#include "mainthreadinterface.h"
+
+class AWTLabelEvent : public AWTEvent {
+
+ private:
+ QAbstractButton *widget;
+ QString *string;
+
+ public:
+ AWTLabelEvent(QAbstractButton *w, QString *s) : AWTEvent()
+ {
+ widget = w;
+ string = s;
+ }
+
+ void runEvent()
+ {
+ widget->setText( *string );
+ delete string;
+ }
+};
+
+#endif
--- /dev/null
+/* componentevent.cpp --
+ 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., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 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 <QWidget>
+#include <QPoint>
+
+#include "componentevent.h"
+
+AWTInitEvent::AWTInitEvent(JNIEnv *env, jobject obj) : AWTEvent()
+{
+ env->GetJavaVM( &vm );
+ target = env->NewGlobalRef( obj );
+}
+
+void AWTInitEvent::runEvent()
+{
+ JNIEnv *env;
+ vm->GetEnv((void **)&env, JNI_VERSION_1_1);
+ jclass targetCls = env->GetObjectClass( target );
+ // call init()
+ jmethodID mID = env->GetMethodID( targetCls,
+ "init",
+ "()V" );
+ env->CallVoidMethod( target, mID );
+
+ // call notify()
+ mID = env->GetMethodID( targetCls,
+ "notify",
+ "()V" );
+ assert(mID != NULL);
+ env->MonitorEnter( target );
+ env->CallVoidMethod( target, mID );
+ env->MonitorExit( target );
+
+ env->DeleteGlobalRef( target );
+}
+
+AWTShowEvent::AWTShowEvent(QWidget *w, bool v) : AWTEvent()
+{
+ widget = w;
+ visible = v;
+}
+
+void AWTShowEvent::runEvent()
+{
+ widget->setVisible( visible );
+}
+
+AWTEnableEvent::AWTEnableEvent(QWidget *w, bool v) : AWTEvent()
+{
+ widget = w;
+ enabled = v;
+}
+
+void AWTEnableEvent::runEvent()
+{
+ widget->setEnabled( enabled );
+}
+
+AWTCursorEvent::AWTCursorEvent(QWidget *w, Qt::CursorShape s) : AWTEvent()
+{
+ widget = w;
+ shape = s;
+}
+
+void AWTCursorEvent::runEvent()
+{
+ QCursor *s = new QCursor(shape);
+ widget->setCursor( *s );
+}
+
+AWTResizeEvent::AWTResizeEvent(QWidget *wid, int x0, int y0, int w0, int h0)
+{
+ widget = wid;
+ x = x0; y = y0;
+ w = w0; h = h0;
+ if(w == 0 && h == 0) w = h = 10;
+}
+
+void AWTResizeEvent::runEvent()
+{
+ QRect g = widget->geometry();
+ if(g.x() != x || g.y() != y || g.width() != w || g.height() != h)
+ widget->setGeometry( x, y, w, h );
+}
+
+AWTBackgroundEvent::AWTBackgroundEvent(QWidget *wid, bool fg, QColor *clr)
+{
+ widget = wid;
+ foreground = fg;
+ color = clr;
+}
+
+void AWTBackgroundEvent::runEvent()
+{
+ QPalette p = widget->palette();
+ if (foreground)
+ {
+ p.setColor(QPalette::Active, QPalette::Foreground, *color);
+ p.setColor(QPalette::Active, QPalette::Text, *color);
+ }
+ else
+ {
+ p.setColor(QPalette::Active, QPalette::Background, *color);
+ p.setColor(QPalette::Active, QPalette::Button, *color);
+ p.setColor(QPalette::Active, QPalette::Base, *color);
+ p.setColor(QPalette::Active, QPalette::AlternateBase, *color);
+ }
+ widget->setPalette(p);
+ widget->repaint();
+ delete color;
+}
+
+AWTGetOriginEvent::AWTGetOriginEvent(QWidget *w, JNIEnv *env, jobject obj) : AWTEvent()
+{
+ widget = w;
+ env->GetJavaVM( &vm );
+ target = env->NewGlobalRef( obj );
+}
+
+void AWTGetOriginEvent::runEvent()
+{
+ JNIEnv *env;
+ vm->GetEnv((void **)&env, JNI_VERSION_1_1);
+ jclass targetCls = env->GetObjectClass( target );
+
+ QPoint *p = new QPoint( widget->mapToGlobal( QPoint(0, 0) ) );
+ // call init()
+ jmethodID mID = env->GetMethodID( targetCls,
+ "setLocation",
+ "(II)V" );
+ env->CallVoidMethod( target, mID, p->x(), p->y() );
+ delete p;
+
+ // call notify()
+ mID = env->GetMethodID( targetCls,
+ "notify",
+ "()V" );
+ assert(mID != NULL);
+ env->MonitorEnter( target );
+ env->CallVoidMethod( target, mID );
+ env->MonitorExit( target );
+
+ env->DeleteGlobalRef( target );
+}
+
+GetSizeEvent::GetSizeEvent(QWidget *w, JNIEnv *env, jobject obj, bool p) : AWTEvent()
+{
+ widget = w;
+ env->GetJavaVM( &vm );
+ target = env->NewGlobalRef( obj );
+ pref = p;
+}
+
+void GetSizeEvent::runEvent()
+{
+ JNIEnv *env;
+ vm->GetEnv((void **)&env, JNI_VERSION_1_1);
+ jclass targetCls = env->GetObjectClass( target );
+
+ QPoint *p = new QPoint( widget->mapToGlobal( QPoint(0, 0) ) );
+ QSize s;
+ if( pref )
+ s = widget->sizeHint();
+ else
+ s = widget->minimumSizeHint();
+
+ // call init()
+ jmethodID mID = env->GetMethodID( targetCls,
+ "setSize",
+ "(II)V" );
+ env->CallVoidMethod( target, mID, s.width(), s.height() );
+
+ // call notify()
+ mID = env->GetMethodID( targetCls,
+ "notify",
+ "()V" );
+ assert(mID != NULL);
+ env->MonitorEnter( target );
+ env->CallVoidMethod( target, mID );
+ env->MonitorExit( target );
+
+ env->DeleteGlobalRef( target );
+}
+
+
+
+
--- /dev/null
+#ifndef CALLBACKEVENT_H
+#define CALLBACKEVENT_H
+
+#include <jni.h>
+#include <QWidget>
+#include <QEvent>
+#include <QColor>
+#include <QCursor>
+#include <QFont>
+#include <QPoint>
+#include <QWidget>
+#include <QSize>
+
+#include "mainthreadinterface.h"
+
+class AWTInitEvent : public AWTEvent {
+
+ private:
+ JavaVM* vm;
+ jobject target;
+
+ public:
+ AWTInitEvent(JNIEnv *env, jobject obj);
+ void runEvent();
+};
+
+class AWTDestroyEvent : public AWTEvent {
+
+ private:
+ QWidget *widget;
+
+ public:
+ AWTDestroyEvent(QWidget *w)
+ {
+ widget = w;
+ }
+
+ void runEvent()
+ {
+ if( widget != NULL )
+ delete widget;
+ }
+};
+
+class AWTFontEvent : public AWTEvent {
+
+ private:
+ QWidget *widget;
+ QFont *font;
+
+ public:
+ AWTFontEvent(QWidget *w, QFont *f)
+ {
+ widget = w;
+ font = f;
+ }
+
+ void runEvent()
+ {
+ widget->setFont( *font );
+ }
+};
+
+class AWTUpdateEvent : public AWTEvent {
+
+ private:
+ QWidget *widget;
+ int x,y,w,h;
+ bool updateAll;
+
+ public:
+ AWTUpdateEvent(QWidget *src, bool all, int x0, int y0, int w0, int h0)
+ {
+ widget = src;
+ updateAll = all;
+ x = x0; y = y0; w = w0; h = h0;
+ }
+
+ void runEvent()
+ {
+ if(updateAll)
+ widget->update();
+ else
+ widget->update(x,y,w,h);
+ }
+};
+
+class AWTShowEvent : public AWTEvent {
+
+ private:
+ QWidget *widget;
+ bool visible;
+
+ public:
+ AWTShowEvent(QWidget *w, bool v);
+ void runEvent();
+};
+
+class AWTEnableEvent : public AWTEvent {
+
+ private:
+ QWidget *widget;
+ bool enabled;
+
+ public:
+ AWTEnableEvent(QWidget *w, bool v);
+ void runEvent();
+};
+
+class AWTCursorEvent : public AWTEvent {
+
+ private:
+ QWidget *widget;
+ Qt::CursorShape shape;
+
+ public:
+ AWTCursorEvent(QWidget *w, Qt::CursorShape s);
+ void runEvent();
+};
+
+class AWTResizeEvent : public AWTEvent {
+
+ private:
+ QWidget *widget;
+ int x, y, w, h;
+
+ public:
+ AWTResizeEvent(QWidget *wid, int x0, int y0, int w0, int h0);
+ void runEvent();
+};
+
+class AWTBackgroundEvent : public AWTEvent {
+
+ private:
+ QWidget *widget;
+ bool foreground;
+ QColor *color;
+
+ public:
+ AWTBackgroundEvent(QWidget *wid, bool fg, QColor *clr);
+ void runEvent();
+};
+
+class AWTReqFocusEvent : public AWTEvent {
+
+ private:
+ QWidget *widget;
+
+ public:
+ AWTReqFocusEvent(QWidget *w) : AWTEvent()
+ {
+ widget = w;
+ }
+ void runEvent()
+ {
+ widget->setFocus();
+ }
+};
+
+class AWTGetOriginEvent : public AWTEvent {
+
+ private:
+ JavaVM* vm;
+ jobject target;
+ QWidget *widget;
+
+ public:
+ AWTGetOriginEvent(QWidget *w, JNIEnv *env, jobject obj);
+ void runEvent();
+};
+
+class GetSizeEvent : public AWTEvent {
+
+ private:
+ JavaVM* vm;
+ jobject target;
+ QWidget *widget;
+ bool pref;
+
+ public:
+ GetSizeEvent(QWidget *w, JNIEnv *env, jobject obj, bool p);
+ void runEvent();
+};
+
+class AWTReparent : public AWTEvent {
+
+ private:
+ QWidget *widget;
+ QWidget *parent;
+
+ public:
+ AWTReparent(QWidget *w, QWidget *p) : AWTEvent()
+ {
+ widget = w;
+ parent = p;
+ }
+ void runEvent()
+ {
+ widget->setParent( parent );
+ }
+};
+
+#endif
--- /dev/null
+#ifndef QTFRAME_H
+#define QTFRAME_H
+
+#include <jni.h>
+#include <QWidget>
+
+QWidget *frameChildWidget( JNIEnv *env, jobject component );
+QWidget *scrollPaneChildWidget( JNIEnv *env, jobject component);
+
+#endif
--- /dev/null
+/* eventmethods.cpp --
+ 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., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 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. */
+
+#ifdef I_KNOW_WHAT_IM_DOING
+
+bool draw;
+
+private:
+ JavaVM* vm;
+ jobject target;
+ jclass componentCls;
+
+ void setup(JNIEnv *env, jobject obj)
+ {
+ env->GetJavaVM(&vm);
+ componentCls = NULL;
+ target = env->NewGlobalRef(obj);
+ componentCls = (jclass)env->NewGlobalRef(env->GetObjectClass( target ));
+ setMouseTracking( true );
+ draw = true;
+ }
+
+ void destroy()
+ {
+ JNIEnv *env;
+ vm->GetEnv((void **)&env, JNI_VERSION_1_1);
+ env->DeleteGlobalRef(target);
+ env->DeleteGlobalRef(componentCls);
+ }
+
+ void callVoidMethod(char *methodName)
+ {
+ JNIEnv *env;
+ vm->GetEnv((void **)&env, JNI_VERSION_1_1);
+ jmethodID fireEventID = env->GetMethodID( componentCls,
+ methodName,
+ "()V" );
+ env->CallVoidMethod( target, fireEventID );
+ }
+
+ void callMouseMethod(char *methodName,
+ int modifiers, int x, int y, int clickCount)
+ {
+ JNIEnv *env;
+ vm->GetEnv((void **)&env, JNI_VERSION_1_1);
+ jmethodID fireEventID = env->GetMethodID( componentCls,
+ methodName,
+ "(IIII)V" );
+ env->CallVoidMethod( target, fireEventID, modifiers, x, y, clickCount );
+ }
+
+protected:
+
+ void closeEvent( QCloseEvent *e )
+ {
+ PARENT::closeEvent(e);
+ callVoidMethod("closeEvent");
+ }
+
+ void focusInEvent( QFocusEvent *e )
+ {
+ PARENT::focusInEvent(e);
+ callVoidMethod("focusInEvent");
+ }
+
+ void focusOutEvent( QFocusEvent *e )
+ {
+ PARENT::focusOutEvent(e);
+ callVoidMethod("focusOutEvent");
+ }
+
+ void enterEvent( QEvent *e )
+ {
+ PARENT::enterEvent(e);
+ QPoint p = mapFromGlobal( QCursor::pos() );
+ int modifiers = getKeyModifiers( QApplication::keyboardModifiers() );
+ callMouseMethod("enterEvent", modifiers, p.x(), p.y(), 0);
+ }
+
+ void keyPressEvent( QKeyEvent *e )
+ {
+ PARENT::keyPressEvent(e);
+ int modifiers, x, y;
+ modifiers = getKeyModifiers(e->modifiers());
+ x = mapKeyCode(e);
+ y = getUnicode(e);
+ callMouseMethod("keyPressEvent", modifiers, x, y, 0);
+ }
+
+ void keyReleaseEvent( QKeyEvent *e )
+ {
+ PARENT::keyReleaseEvent(e);
+ int modifiers, x, y;
+ modifiers = getKeyModifiers(e->modifiers());
+ x = mapKeyCode(e);
+ y = getUnicode(e);
+ callMouseMethod("keyReleaseEvent", modifiers, x, y, 0);
+ }
+
+ void leaveEvent( QEvent *e )
+ {
+ PARENT::leaveEvent(e);
+ QPoint p = mapFromGlobal( QCursor::pos() );
+ int modifiers = getKeyModifiers( QApplication::keyboardModifiers() );
+ callMouseMethod("leaveEvent", modifiers, p.x(), p.y(), 0);
+ }
+
+ void mouseDoubleClickEvent( QMouseEvent *e )
+ {
+ PARENT::mouseDoubleClickEvent(e);
+ int modifiers, x, y, clickCount;
+ clickCount = 2;
+ modifiers = getMouseModifiers(e);
+ x = e->x();
+ y = e->y();
+ callMouseMethod("mouseDoubleClickEvent", modifiers, x, y, clickCount);
+ }
+
+ void mouseMoveEvent( QMouseEvent *e )
+ {
+ PARENT::mouseMoveEvent(e);
+ int modifiers, x, y, clickCount;
+ clickCount = 0;
+ modifiers = getMouseModifiers(e);
+ x = e->x();
+ y = e->y();
+ callMouseMethod("mouseMoveEvent", modifiers, x, y, clickCount);
+ }
+
+ void mousePressEvent( QMouseEvent *e )
+ {
+ PARENT::mousePressEvent(e);
+ int modifiers, x, y, clickCount;
+ clickCount = 0;
+ modifiers = getMouseModifiers(e);
+ x = e->x();
+ y = e->y();
+ callMouseMethod("mousePressEvent", modifiers, x, y, clickCount);
+ }
+
+ void mouseReleaseEvent( QMouseEvent *e )
+ {
+ PARENT::mouseReleaseEvent(e);
+ int modifiers, x, y, clickCount;
+ modifiers = 0;
+
+ modifiers |= getReleaseModifiers( e );
+ x = e->x();
+ y = e->y();
+ callMouseMethod("mouseReleaseEvent", modifiers, x, y, 0);
+ }
+
+ void moveEvent( QMoveEvent *e )
+ {
+ PARENT::moveEvent(e);
+ callMouseMethod("moveEvent", e->pos().x(), e->pos().y(),
+ e->oldPos().x(), e->oldPos().y());
+ }
+
+ void resizeEvent( QResizeEvent *e )
+ {
+ PARENT::resizeEvent(e);
+ callMouseMethod("resizeEvent",
+ e->oldSize().width(), e->oldSize().height(),
+ e->size().width(), e->size().height());
+ }
+
+ void hideEvent( QHideEvent *e )
+ {
+ PARENT::hideEvent(e);
+ callVoidMethod("hideEvent");
+ }
+
+ void showEvent( QShowEvent *e )
+ {
+ PARENT::showEvent(e);
+ callVoidMethod("showEvent");
+ }
+
+ void paintEvent ( QPaintEvent * e )
+ {
+ PARENT::paintEvent( e );
+ if ( draw )
+ {
+ // Create a QPainter
+ GraphicsPainter painter( this );
+ int x, y, w, h;
+ e->rect().getRect ( &x, &y, &w, &h );
+
+ // Get the environment.
+ JNIEnv *env;
+ vm->GetEnv((void **)&env, JNI_VERSION_1_1);
+
+ // create a QtGraphics wrapper for the QPainter
+ jclass cls = env->FindClass( "gnu/java/awt/peer/qt/QtComponentGraphics" );
+ jmethodID mid = env->GetMethodID(cls, "<init>", "(JLgnu/java/awt/peer/qt/QtComponentPeer;IIII)V");
+ jobject graphics = env->NewObject(cls, mid, (jlong)&painter, target,
+ (jint)x, (jint)y, (jint)w, (jint)h);
+
+ // call QtComponentPeer.paintEvent()
+ jmethodID paintEventID = env->GetMethodID( componentCls,
+ "paint",
+ "(Ljava/awt/Graphics;)V" );
+ env->CallVoidMethod( target, paintEventID, graphics );
+ env->DeleteLocalRef( cls );
+ env->DeleteLocalRef( graphics );
+ painter.end();
+ }
+ }
+
+#endif
--- /dev/null
+/* keybindings.cpp --
+ 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., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 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 "keybindings.h"
+
+/* InputEvent key modifiers */
+#define SHIFT_MASK 1
+#define CTRL_MASK 2
+#define META_MASK 4
+#define ALT_MASK 8
+#define ALT_GRAPH_MASK 0x20
+#define BUTTON1_MASK 0x10
+#define BUTTON2_MASK 8
+#define BUTTON3_MASK 4
+
+#define SHIFT_DOWN_MASK 0x0040
+#define CTRL_DOWN_MASK 0x0080
+#define META_DOWN_MASK 0x0100
+#define ALT_DOWN_MASK 0x0200
+#define BUTTON1_DOWN_MASK 0x0400
+#define BUTTON2_DOWN_MASK 0x0800
+#define BUTTON3_DOWN_MASK 0x1000
+#define ALT_GRAPH_DOWN_MASK 0x2000
+
+/* Virtual Keys */
+/* This list should be kept in the same order as the VK_ field
+ declarations in KeyEvent.java. */
+#define VK_ENTER '\n'
+#define VK_BACK_SPACE '\b'
+#define VK_TAB '\t'
+#define VK_CANCEL 3
+#define VK_CLEAR 12
+#define VK_SHIFT 16
+#define VK_CONTROL 17
+#define VK_ALT 18
+#define VK_PAUSE 19
+#define VK_CAPS_LOCK 20
+#define VK_ESCAPE 27
+#define VK_SPACE ' '
+#define VK_PAGE_UP 33
+#define VK_PAGE_DOWN 34
+#define VK_END 35
+#define VK_HOME 36
+#define VK_LEFT 37
+#define VK_UP 38
+#define VK_RIGHT 39
+#define VK_DOWN 40
+#define VK_COMMA ','
+#define VK_MINUS '-'
+#define VK_PERIOD '.'
+#define VK_SLASH '/'
+#define VK_0 '0'
+#define VK_1 '1'
+#define VK_2 '2'
+#define VK_3 '3'
+#define VK_4 '4'
+#define VK_5 '5'
+#define VK_6 '6'
+#define VK_7 '7'
+#define VK_8 '8'
+#define VK_9 '9'
+#define VK_SEMICOLON ';'
+#define VK_EQUALS '='
+#define VK_A 'A'
+#define VK_B 'B'
+#define VK_C 'C'
+#define VK_D 'D'
+#define VK_E 'E'
+#define VK_F 'F'
+#define VK_G 'G'
+#define VK_H 'H'
+#define VK_I 'I'
+#define VK_J 'J'
+#define VK_K 'K'
+#define VK_L 'L'
+#define VK_M 'M'
+#define VK_N 'N'
+#define VK_O 'O'
+#define VK_P 'P'
+#define VK_Q 'Q'
+#define VK_R 'R'
+#define VK_S 'S'
+#define VK_T 'T'
+#define VK_U 'U'
+#define VK_V 'V'
+#define VK_W 'W'
+#define VK_X 'X'
+#define VK_Y 'Y'
+#define VK_Z 'Z'
+#define VK_OPEN_BRACKET '['
+#define VK_BACK_SLASH '\\'
+#define VK_CLOSE_BRACKET ']'
+#define VK_NUMPAD0 96
+#define VK_NUMPAD1 97
+#define VK_NUMPAD2 98
+#define VK_NUMPAD3 99
+#define VK_NUMPAD4 100
+#define VK_NUMPAD5 101
+#define VK_NUMPAD6 102
+#define VK_NUMPAD7 103
+#define VK_NUMPAD8 104
+#define VK_NUMPAD9 105
+#define VK_MULTIPLY 106
+#define VK_ADD 107
+#define VK_SEPARATER 108
+#define VK_SEPARATOR 108
+#define VK_SUBTRACT 109
+#define VK_DECIMAL 110
+#define VK_DIVIDE 111
+#define VK_DELETE 127
+#define VK_NUM_LOCK 144
+#define VK_SCROLL_LOCK 145
+#define VK_F1 112
+#define VK_F2 113
+#define VK_F3 114
+#define VK_F4 115
+#define VK_F5 116
+#define VK_F6 117
+#define VK_F7 118
+#define VK_F8 119
+#define VK_F9 120
+#define VK_F10 121
+#define VK_F11 122
+#define VK_F12 123
+#define VK_F13 61440
+#define VK_F14 61441
+#define VK_F15 61442
+#define VK_F16 61443
+#define VK_F17 61444
+#define VK_F18 61445
+#define VK_F19 61446
+#define VK_F20 61447
+#define VK_F21 61448
+#define VK_F22 61449
+#define VK_F23 61450
+#define VK_F24 61451
+#define VK_PRINTSCREEN 154
+#define VK_INSERT 155
+#define VK_HELP 156
+#define VK_META 157
+#define VK_BACK_QUOTE 192
+#define VK_QUOTE 222
+#define VK_KP_UP 224
+#define VK_KP_DOWN 225
+#define VK_KP_LEFT 226
+#define VK_KP_RIGHT 227
+#define VK_DEAD_GRAVE 128
+#define VK_DEAD_ACUTE 129
+#define VK_DEAD_CIRCUMFLEX 130
+#define VK_DEAD_TILDE 131
+#define VK_DEAD_MACRON 132
+#define VK_DEAD_BREVE 133
+#define VK_DEAD_ABOVEDOT 134
+#define VK_DEAD_DIAERESIS 135
+#define VK_DEAD_ABOVERING 136
+#define VK_DEAD_DOUBLEACUTE 137
+#define VK_DEAD_CARON 138
+#define VK_DEAD_CEDILLA 139
+#define VK_DEAD_OGONEK 140
+#define VK_DEAD_IOTA 141
+#define VK_DEAD_VOICED_SOUND 142
+#define VK_DEAD_SEMIVOICED_SOUND 143
+#define VK_AMPERSAND 150
+#define VK_ASTERISK 151
+#define VK_QUOTEDBL 152
+#define VK_LESS 153
+#define VK_GREATER 160
+#define VK_BRACELEFT 161
+#define VK_BRACERIGHT 162
+#define VK_AT 512
+#define VK_COLON 513
+#define VK_CIRCUMFLEX 514
+#define VK_DOLLAR 515
+#define VK_EURO_SIGN 516
+#define VK_EXCLAMATION_MARK 517
+#define VK_INVERTED_EXCLAMATION_MARK 518
+#define VK_LEFT_PARENTHESIS 519
+#define VK_NUMBER_SIGN 520
+#define VK_PLUS 521
+#define VK_RIGHT_PARENTHESIS 522
+#define VK_UNDERSCORE 523
+#define VK_FINAL 24
+#define VK_CONVERT 28
+#define VK_NONCONVERT 29
+#define VK_ACCEPT 30
+#define VK_MODECHANGE 31
+#define VK_KANA 21
+#define VK_KANJI 25
+#define VK_ALPHANUMERIC 240
+#define VK_KATAKANA 241
+#define VK_HIRAGANA 242
+#define VK_FULL_WIDTH 243
+#define VK_HALF_WIDTH 244
+#define VK_ROMAN_CHARACTERS 245
+#define VK_ALL_CANDIDATES 256
+#define VK_PREVIOUS_CANDIDATE 257
+#define VK_CODE_INPUT 258
+#define VK_JAPANESE_KATAKANA 259
+#define VK_JAPANESE_HIRAGANA 260
+#define VK_JAPANESE_ROMAN 261
+#define VK_KANA_LOCK 262
+#define VK_INPUT_METHOD_ON_OFF 263
+#define VK_CUT 65489
+#define VK_COPY 65485
+#define VK_PASTE 65487
+#define VK_UNDO 65483
+#define VK_AGAIN 65481
+#define VK_FIND 65488
+#define VK_PROPS 65482
+#define VK_STOP 65480
+#define VK_COMPOSE 65312
+#define VK_ALT_GRAPH 65406
+#define VK_UNDEFINED 0
+
+
+int mapKeyCode(QKeyEvent *key)
+{
+ switch(key->key())
+ {
+ case Qt::Key_Escape:
+ return VK_ESCAPE;
+ case Qt::Key_Tab:
+ return VK_TAB;
+ case Qt::Key_Backspace:
+ return VK_BACK_SPACE;
+ case Qt::Key_Return:
+ case Qt::Key_Enter:
+ return VK_ENTER;
+ case Qt::Key_Insert:
+ return VK_INSERT;
+ case Qt::Key_Delete:
+ return VK_DELETE;
+ case Qt::Key_Pause:
+ return VK_PAUSE;
+ case Qt::Key_Print:
+ case Qt::Key_SysReq:
+ return VK_PRINTSCREEN;
+ case Qt::Key_Home:
+ return VK_HOME;
+ case Qt::Key_End:
+ return VK_END;
+ case Qt::Key_Left:
+ return VK_LEFT;
+ case Qt::Key_Up:
+ return VK_UP;
+ case Qt::Key_Right:
+ return VK_RIGHT;
+ case Qt::Key_Down:
+ return VK_DOWN;
+ case Qt::Key_PageUp:
+ return VK_PAGE_UP;
+ case Qt::Key_PageDown:
+ return VK_PAGE_DOWN;
+ case Qt::Key_Shift:
+ return VK_SHIFT;
+ case Qt::Key_Control:
+ return VK_CONTROL;
+ case Qt::Key_Meta:
+ return VK_META;
+ case Qt::Key_Alt:
+ return VK_ALT;
+ case Qt::Key_CapsLock:
+ return VK_CAPS_LOCK;
+ case Qt::Key_NumLock:
+ return VK_NUM_LOCK;
+ case Qt::Key_ScrollLock:
+ return VK_SCROLL_LOCK;
+ case Qt::Key_Clear:
+ return VK_CLEAR;
+ case Qt::Key_F1:
+ return VK_F1;
+ case Qt::Key_F2:
+ return VK_F2;
+ case Qt::Key_F3:
+ return VK_F3;
+ case Qt::Key_F4:
+ return VK_F4;
+ case Qt::Key_F5:
+ return VK_F5;
+ case Qt::Key_F6:
+ return VK_F6;
+ case Qt::Key_F7:
+ return VK_F7;
+ case Qt::Key_F8:
+ return VK_F8;
+ case Qt::Key_F9:
+ return VK_F9;
+ case Qt::Key_F10:
+ return VK_F10;
+ case Qt::Key_F11:
+ return VK_F11;
+ case Qt::Key_F12:
+ return VK_F12;
+ case Qt::Key_F13:
+ return VK_F13;
+ case Qt::Key_F14:
+ return VK_F14;
+ case Qt::Key_F15:
+ return VK_F15;
+ case Qt::Key_F16:
+ return VK_F16;
+ case Qt::Key_F17:
+ return VK_F17;
+ case Qt::Key_F18:
+ return VK_F18;
+ case Qt::Key_F19:
+ return VK_F19;
+ case Qt::Key_F20:
+ return VK_F20;
+ case Qt::Key_F21:
+ return VK_F21;
+ case Qt::Key_F22:
+ return VK_F22;
+ case Qt::Key_F23:
+ return VK_F23;
+ case Qt::Key_F24:
+ return VK_F24;
+ case Qt::Key_Help:
+ return VK_HELP;
+
+ case Qt::Key_Space:
+ return VK_SPACE;
+
+ case Qt::Key_Exclam:
+ return VK_EXCLAMATION_MARK;
+ case Qt::Key_QuoteDbl:
+ return VK_QUOTEDBL;
+ case Qt::Key_NumberSign:
+ return VK_NUMBER_SIGN;
+
+ case Qt::Key_Dollar:
+ return VK_DOLLAR;
+
+
+ case Qt::Key_Ampersand:
+ return VK_AMPERSAND;
+
+ case Qt::Key_ParenLeft:
+ return VK_LEFT_PARENTHESIS;
+ case Qt::Key_ParenRight:
+ return VK_RIGHT_PARENTHESIS;
+ case Qt::Key_Asterisk:
+ return VK_ASTERISK;
+ case Qt::Key_Plus:
+ return VK_PLUS;
+ case Qt::Key_Comma:
+ return VK_COMMA;
+ case Qt::Key_Minus:
+ return VK_MINUS;
+ case Qt::Key_Period:
+ return VK_PERIOD;
+ case Qt::Key_Slash:
+ return VK_SLASH;
+
+ case Qt::Key_0:
+ return VK_0;
+ case Qt::Key_1:
+ return VK_1;
+ case Qt::Key_2:
+ return VK_2;
+ case Qt::Key_3:
+ return VK_3;
+ case Qt::Key_4:
+ return VK_4;
+ case Qt::Key_5:
+ return VK_5 ;
+ case Qt::Key_6:
+ return VK_6;
+ case Qt::Key_7:
+ return VK_7;
+ case Qt::Key_8:
+ return VK_8;
+ case Qt::Key_9:
+ return VK_9;
+
+ case Qt::Key_Colon:
+ return VK_COLON;
+ case Qt::Key_Semicolon:
+ return VK_SEMICOLON;
+ case Qt::Key_Less:
+ return VK_LESS;
+ case Qt::Key_Equal:
+ return VK_EQUALS;
+ case Qt::Key_Greater:
+ return VK_GREATER;
+ case Qt::Key_Question:
+ case Qt::Key_At:
+
+ case Qt::Key_A:
+ return VK_A;
+ case Qt::Key_B:
+ return VK_B;
+ case Qt::Key_C:
+ return VK_C;
+ case Qt::Key_D:
+ return VK_D;
+ case Qt::Key_E:
+ return VK_E;
+ case Qt::Key_F:
+ return VK_F;
+ case Qt::Key_G:
+ return VK_G;
+ case Qt::Key_H:
+ return VK_H;
+ case Qt::Key_I:
+ return VK_I;
+ case Qt::Key_J:
+ return VK_J;
+ case Qt::Key_K:
+ return VK_K;
+ case Qt::Key_L:
+ return VK_L;
+ case Qt::Key_M:
+ return VK_M;
+ case Qt::Key_N:
+ return VK_N;
+ case Qt::Key_O:
+ return VK_O;
+ case Qt::Key_P:
+ return VK_P;
+ case Qt::Key_Q:
+ return VK_Q;
+ case Qt::Key_R:
+ return VK_R;
+ case Qt::Key_S:
+ return VK_S;
+ case Qt::Key_T:
+ return VK_T;
+ case Qt::Key_U:
+ return VK_U;
+ case Qt::Key_V:
+ return VK_V;
+ case Qt::Key_W:
+ return VK_W;
+ case Qt::Key_X:
+ return VK_X;
+ case Qt::Key_Y:
+ return VK_Y;
+ case Qt::Key_Z:
+ return VK_Z;
+ case Qt::Key_division:
+ return VK_DIVIDE;
+ case Qt::Key_BracketLeft:
+ return VK_OPEN_BRACKET;
+ case Qt::Key_Backslash:
+ return VK_BACK_SLASH;
+ case Qt::Key_BracketRight:
+ return VK_CLOSE_BRACKET;
+ case Qt::Key_BraceLeft:
+ return VK_BRACELEFT;
+ case Qt::Key_BraceRight:
+ return VK_BRACERIGHT;
+ case Qt::Key_brokenbar:
+ return VK_SEPARATOR; // correct?
+
+ default:
+ return VK_UNDEFINED;
+ }
+}
+
+int getUnicode(QKeyEvent *key)
+{
+ QString s = key->text();
+ if(s.isEmpty())
+ return 0; // CHAR_UNDEFINED
+ QChar c = s.at(0);
+ return (int)c.unicode();
+}
+
+/**
+ * Returns the key modifiers in KeyEvent format
+ */
+int getKeyModifiers(Qt::KeyboardModifiers state)
+{
+ int modifier = 0;
+ if( state & Qt::ShiftModifier )
+ modifier |= SHIFT_DOWN_MASK;
+ if( state & Qt::ControlModifier )
+ modifier |= CTRL_DOWN_MASK;
+ if( state & Qt::AltModifier )
+ modifier |= ALT_DOWN_MASK;
+ if( state & Qt::MetaModifier )
+ modifier |= META_DOWN_MASK;
+
+ return modifier;
+}
+
+/**
+ * Returns the key modifiers in ActionEvent format
+ */
+int getAEKeyModifiers(Qt::KeyboardModifiers state)
+{
+ int modifier = 0;
+ if( state & Qt::ShiftModifier )
+ modifier |= SHIFT_MASK;
+ if( state & Qt::ControlModifier )
+ modifier |= CTRL_MASK;
+ if( state & Qt::AltModifier )
+ modifier |= ALT_MASK;
+ if( state & Qt::MetaModifier )
+ modifier |= META_MASK;
+
+ return modifier;
+}
+
+/**
+ * Returns the mouse modifiers in InputEvent format
+ */
+int getMouseModifiers(QMouseEvent *e)
+{
+ int modifier = 0;
+ int buttons = e->buttons();
+ int state = e->modifiers();
+
+ if( buttons & Qt::LeftButton )
+ modifier |= BUTTON1_DOWN_MASK;
+ if( buttons & Qt::MidButton )
+ modifier |= BUTTON2_DOWN_MASK;
+ if( buttons & Qt::RightButton )
+ modifier |= BUTTON3_DOWN_MASK;
+
+ if( state & Qt::ShiftModifier )
+ modifier |= SHIFT_DOWN_MASK;
+ if( state & Qt::ControlModifier )
+ modifier |= CTRL_DOWN_MASK;
+ if( state & Qt::AltModifier )
+ modifier |= ALT_DOWN_MASK;
+ if( state & Qt::MetaModifier )
+ modifier |= META_DOWN_MASK;
+
+ // FIXME: Alt Gr?
+ return modifier;
+}
+
+/**
+ * Returns the mouse modifiers in InputEvent format
+ * We need a different method here because e->buttons() doesn't work for,
+ * mouseReleased events. (But strangely enough it does for pressed ones)
+ */
+int getReleaseModifiers(QMouseEvent *e)
+{
+ int modifier = 0;
+ int button = e->button();
+ int state = e->modifiers();
+
+ if( button & Qt::LeftButton )
+ modifier |= BUTTON1_DOWN_MASK;
+ if( button & Qt::MidButton )
+ modifier |= BUTTON2_DOWN_MASK;
+ if( button & Qt::RightButton )
+ modifier |= BUTTON3_DOWN_MASK;
+
+ if( state & Qt::ShiftModifier )
+ modifier |= SHIFT_DOWN_MASK;
+ if( state & Qt::ControlModifier )
+ modifier |= CTRL_DOWN_MASK;
+ if( state & Qt::AltModifier )
+ modifier |= ALT_DOWN_MASK;
+ if( state & Qt::MetaModifier )
+ modifier |= META_DOWN_MASK;
+
+ // FIXME: Alt Gr?
+ return modifier;
+}
+
+
--- /dev/null
+#ifndef KEYBINDINGS_H
+#define KEYBINDINGS_H
+
+#include <QApplication>
+#include <QKeyEvent>
+#include <QMouseEvent>
+#include <QPainter>
+#include <QPoint>
+#include <qwidget.h>
+#include <qstring.h>
+#include "qtgraphics.h"
+
+int mapKeyCode(QKeyEvent *key);
+int getUnicode(QKeyEvent *key);
+int getKeyModifiers(Qt::KeyboardModifiers state);
+int getAEKeyModifiers(Qt::KeyboardModifiers state);
+int getMouseModifiers(QMouseEvent *event);
+int getReleaseModifiers(QMouseEvent *e);
+
+#endif
--- /dev/null
+/* mainqtthread.cpp --
+ 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., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 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 <assert.h>
+#include <jni.h>
+#include <QApplication>
+#include <QThread>
+#include <gnu_java_awt_peer_qt_MainQtThread.h>
+#include "mainthreadinterface.h"
+
+MainThreadInterface *mainThread;
+QApplication *qApplication;
+
+#if defined(Q_WS_X11)
+extern void qt_x11_set_global_double_buffer( bool );
+#endif
+
+/**
+ * Starts up a QApplication
+ */
+JNIEXPORT jlong JNICALL Java_gnu_java_awt_peer_qt_MainQtThread_init
+(JNIEnv *env, jobject obj, jstring theme, jboolean doublebuffer)
+{
+ int *argc;
+ char **argv;
+
+ if(theme != NULL)
+ {
+ argc = (int*)malloc(sizeof(int));
+ *argc = 3;
+ argv = (char **)malloc( 3 * sizeof(char *) );
+ argv[0] = (char *)malloc(10 * sizeof(char));
+ argv[1] = (char *)malloc(10 * sizeof(char));
+ argv[2] = (char *)malloc(100 * sizeof(char));
+ strncpy(argv[0], "\0", 2);
+ strncpy(argv[1], "-style\0", 8);
+ strncpy(argv[2], (char *)env->GetStringUTFChars( theme, NULL ), 100);
+ }
+ else
+ {
+ argc = (int*)malloc(sizeof(int));
+ *argc = 1;
+ argv = (char **)malloc( 3 * sizeof(char *) );
+ argv[0] = (char *)malloc(10 * sizeof(char));
+ strncpy(argv[0], " \0", 3);
+ }
+ QApplication *qtApp = new QApplication( *argc, argv );
+ assert( qtApp );
+
+ qApplication = qtApp;
+
+ if( theme != NULL)
+ env->ReleaseStringUTFChars( theme, argv[1] );
+
+ mainThread = new MainThreadInterface( qtApp );
+
+ jclass cls = env->GetObjectClass(obj);
+ jfieldID nofid = env->GetFieldID( cls, "mainThreadInterface", "J" );
+ env->SetLongField( obj, nofid, (jlong)mainThread );
+
+#if defined(Q_WS_X11)
+ // turn off double-buffering.
+ qt_x11_set_global_double_buffer( (doublebuffer == JNI_TRUE) );
+#endif
+
+ return (jlong)qtApp;
+}
+
+/*
+ * Calls QApplication::exec()
+ */
+JNIEXPORT void JNICALL Java_gnu_java_awt_peer_qt_MainQtThread_exec
+(JNIEnv *env, jobject obj, jlong ptr)
+{
+ QApplication *app = (QApplication *)ptr;
+ if(app)
+ app->exec();
+}
--- /dev/null
+/* mainthreadinterface.cpp --
+ 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., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 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 <QWidget>
+#include <QThread>
+#include "mainthreadinterface.h"
+
+MainThreadInterface::MainThreadInterface(QApplication *parent) : QObject( parent )
+{
+ mainApp = parent;
+}
+
+/**
+ * This is called from the main Qt event loop, and delegates the work to
+ * the AWTEvent runEvent method.
+ */
+bool MainThreadInterface::event ( QEvent * e )
+{
+ QObject::event( e );
+ if( e->type() == QEvent::User)
+ {
+ AWTEvent *fe = (AWTEvent *)e;
+ fe->runEvent();
+ }
+ return true;
+}
+
+/**
+ * Posts the event to the main Qt event loop for execution.
+ */
+void MainThreadInterface::postEventToMain(AWTEvent *event)
+{
+ mainApp->postEvent(this, event);
+}
+
--- /dev/null
+#ifndef MAINTHREADINTERFACE_H
+#define MAINTHREADINTERFACE_H
+
+#include <jni.h>
+#include <QApplication>
+#include <QObject>
+#include <QWidget>
+#include <QEvent>
+
+class AWTEvent : public QEvent {
+
+ public:
+ AWTEvent() : QEvent( QEvent::User )
+ {
+ }
+
+ virtual void runEvent()
+ {
+ }
+
+};
+
+class MainThreadInterface : public QObject {
+
+ private:
+ QApplication *mainApp;
+
+ public:
+ MainThreadInterface(QApplication *parent);
+ bool event ( QEvent * e );
+ void postEventToMain(AWTEvent *event);
+};
+
+extern MainThreadInterface *mainThread;
+
+#endif
--- /dev/null
+/* nativewrapper.cpp --
+ 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., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 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 "nativewrapper.h"
+
+#define WRAPPER_CLASS "gnu/java/awt/peer/qt/NativeWrapper"
+
+/*
+ * Sets the native object field.
+ */
+void setNativeObject( JNIEnv *env, jobject qtcomponent, void *ptr )
+{
+ jclass cls = env->GetObjectClass( qtcomponent );
+ jlong value = (jlong) ptr;
+ jfieldID nofid = env->GetFieldID( cls, "nativeObject", "J" );
+ env->SetLongField( qtcomponent, nofid, value );
+ env->DeleteLocalRef( cls );
+}
+
+/**
+ * Gets the native object field.
+ */
+void *getNativeObject( JNIEnv *env, jobject qtcomponent )
+{
+ jclass cls = env->GetObjectClass( qtcomponent );
+ jfieldID nofid = env->GetFieldID( cls, "nativeObject", "J" );
+ jlong value = env->GetLongField( qtcomponent, nofid );
+ env->DeleteLocalRef( cls );
+ return (void *) value;
+}
--- /dev/null
+#ifndef NATIVEWRAPPER_H
+#define NATIVEWRAPPER_H
+
+#include <jni.h>
+
+void *getNativeObject( JNIEnv *env, jobject qtcomponent );
+
+void setNativeObject( JNIEnv *env, jobject qtcomponent, void *ptr );
+
+#endif
--- /dev/null
+/* qmatrix.cpp --
+ 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., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 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 <assert.h>
+#include <QMatrix>
+#include <gnu_java_awt_peer_qt_QMatrix.h>
+#include "nativewrapper.h"
+
+/*
+ * Creates a QMatrix
+ */
+JNIEXPORT void JNICALL Java_gnu_java_awt_peer_qt_QMatrix_init
+(JNIEnv *env, jobject obj, jdouble m00, jdouble m10, jdouble m01, jdouble m11,
+ jdouble m02, jdouble m12 )
+{
+ QMatrix *matrix = new QMatrix( (qreal) m00, (qreal) m10,
+ (qreal) m01, (qreal) m11,
+ (qreal) m02, (qreal) m12 );
+ assert( matrix );
+ setNativeObject(env, obj, matrix);
+}
+
+/*
+ * Returns the matrix a java array of doubles,
+ * in m00, m10, m01, m11, m02, m12 (java notation) format.
+ * Note that qt has different notations for the array elements.
+ */
+JNIEXPORT jdoubleArray JNICALL Java_gnu_java_awt_peer_qt_QMatrix_getMatrix
+(JNIEnv *env, jobject obj)
+{
+ QMatrix *matrix = (QMatrix *)getNativeObject(env, obj);
+ assert( matrix );
+
+ jdoubleArray result_array;
+ jdouble *dst;
+
+ result_array = env->NewDoubleArray( 6 );
+ dst = env->GetDoubleArrayElements(result_array, NULL);
+
+ dst[0] = (jdouble)matrix->m11(); // qt m11 = java m00
+ dst[1] = (jdouble)matrix->m12(); // qt m12 = java m10
+ dst[2] = (jdouble)matrix->m21(); // qt m21 = java m01
+ dst[3] = (jdouble)matrix->m22(); // qt m22 = java m11
+ dst[4] = (jdouble)matrix->dx(); // qt dx = java m02
+ dst[5] = (jdouble)matrix->dy(); // qt dy = java m12
+
+ env->ReleaseDoubleArrayElements (result_array, dst, 0);
+ return result_array;
+}
+
+/*
+ * Dispose of the thing.
+ */
+JNIEXPORT void JNICALL Java_gnu_java_awt_peer_qt_QMatrix_dispose
+(JNIEnv *env, jobject obj)
+{
+ QMatrix *matrix = (QMatrix *)getNativeObject(env, obj);
+ if( matrix )
+ delete matrix;
+ setNativeObject(env, obj, NULL);
+}
+
--- /dev/null
+/* qpainterpath.cpp --
+ 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., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 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 <assert.h>
+#include <QPainterPath>
+#include <gnu_java_awt_peer_qt_QPainterPath.h>
+#include "nativewrapper.h"
+
+// java.awt.geom.PathIterator constants.
+#define WIND_EVEN_ODD 0
+#define WIND_NON_ZERO 1
+
+
+/*
+ * Creates an empty QPainterPath.
+ */
+JNIEXPORT void JNICALL Java_gnu_java_awt_peer_qt_QPainterPath_init
+(JNIEnv *env, jobject obj, jint windingRule)
+{
+ QPainterPath *path = new QPainterPath();
+ assert( path );
+ path->setFillRule( (windingRule == WIND_EVEN_ODD) ?
+ Qt::OddEvenFill : Qt::WindingFill );
+ setNativeObject(env, obj, path);
+}
+
+/*
+ * MoveTo
+ */
+JNIEXPORT void JNICALL Java_gnu_java_awt_peer_qt_QPainterPath_moveTo
+(JNIEnv *env, jobject obj, jdouble x, jdouble y)
+{
+ QPainterPath *path = (QPainterPath *)getNativeObject(env, obj);
+ assert( path );
+ path->moveTo( (qreal)x, (qreal)y );
+}
+
+/*
+ * Closes the subpath.
+ */
+JNIEXPORT void JNICALL Java_gnu_java_awt_peer_qt_QPainterPath_close
+(JNIEnv *env, jobject obj)
+{
+ QPainterPath *path = (QPainterPath *)getNativeObject(env, obj);
+ assert( path );
+ path->closeSubpath();
+}
+
+/*
+ * LineTo
+ */
+JNIEXPORT void JNICALL Java_gnu_java_awt_peer_qt_QPainterPath_lineTo
+(JNIEnv *env, jobject obj, jdouble x, jdouble y)
+{
+ QPainterPath *path = (QPainterPath *)getNativeObject(env, obj);
+ assert( path );
+ path->lineTo( (qreal)x, (qreal)y );
+}
+
+/*
+ * QuadraticTo
+ */
+JNIEXPORT void JNICALL Java_gnu_java_awt_peer_qt_QPainterPath_quadTo
+(JNIEnv *env, jobject obj, jdouble x, jdouble y, jdouble x2, jdouble y2)
+{
+ QPainterPath *path = (QPainterPath *)getNativeObject(env, obj);
+ assert( path );
+ path->quadTo( (qreal)x, (qreal)y, (qreal)x2, (qreal)y2 );
+}
+
+/*
+ * CubicTo
+ */
+JNIEXPORT void JNICALL Java_gnu_java_awt_peer_qt_QPainterPath_cubicTo
+(JNIEnv *env, jobject obj, jdouble x, jdouble y, jdouble x2, jdouble y2,
+ jdouble x3, jdouble y3)
+{
+ QPainterPath *path = (QPainterPath *)getNativeObject(env, obj);
+ assert( path );
+ path->cubicTo( (qreal)x, (qreal)y,
+ (qreal)x2, (qreal)y2,
+ (qreal)x3, (qreal)y3 );
+}
+
+/*
+ * Delete the native object
+ */
+JNIEXPORT void JNICALL Java_gnu_java_awt_peer_qt_QPainterPath_dispose
+ (JNIEnv *env, jobject obj)
+{
+ QPainterPath *path = (QPainterPath *)getNativeObject(env, obj);
+ if ( path )
+ delete path;
+}
+
+/********* GeneralPath functions *****************************/
+
+// FIXME : Cache method ids.
+
+static void gp_moveTo( JNIEnv *env,
+ jobject gp,
+ jclass cls,
+ double x1,
+ double y1 )
+{
+ jmethodID method;
+ jvalue values[2];
+
+ values[0].f = (jfloat) x1;
+ values[1].f = (jfloat) y1;
+
+ method = env->GetMethodID(cls, "moveTo", "(FF)V");
+ env->CallVoidMethodA( gp, method, values );
+}
+
+static void gp_lineTo( JNIEnv *env,
+ jobject gp,
+ jclass cls,
+ double x1,
+ double y1 )
+{
+ jmethodID method;
+ jvalue values[2];
+
+ values[0].f = (jfloat) x1;
+ values[1].f = (jfloat) y1;
+
+ method = env->GetMethodID(cls, "lineTo", "(FF)V");
+ env->CallVoidMethodA( gp, method, values );
+}
+
+static void gp_curveTo( JNIEnv *env,
+ jobject gp,
+ jclass cls,
+ double x1,
+ double y1,
+ double x2,
+ double y2,
+ double x3,
+ double y3 )
+{
+ jmethodID method;
+ jvalue values[6];
+
+ values[0].f = (jfloat) x1;
+ values[1].f = (jfloat) y1;
+ values[2].f = (jfloat) x2;
+ values[3].f = (jfloat) y2;
+ values[4].f = (jfloat) x3;
+ values[5].f = (jfloat) y3;
+
+ method = env->GetMethodID(cls, "curveTo", "(FFFFFF)V");
+ env->CallVoidMethodA( gp, method, values );
+}
+
+/**
+ * Returns the QPainterPath obj as a java.awt.geom.GeneralPath.
+ */
+JNIEXPORT jobject JNICALL Java_gnu_java_awt_peer_qt_QPainterPath_getPath
+(JNIEnv *env, jobject obj)
+{
+ jclass cls;
+ jmethodID method;
+ jobject gp;
+ QPainterPath::Element currElement;
+ int windingRule;
+
+ QPainterPath *path = new QPainterPath();
+ assert( path );
+
+ windingRule = (path->fillRule() == Qt::OddEvenFill) ?
+ WIND_EVEN_ODD : WIND_NON_ZERO;
+
+ cls = env->FindClass("java/awt/geom/GeneralPath");
+ method = env->GetMethodID(cls, "<init>", "(I)V");
+ gp = env->NewObject(cls, method, windingRule);
+
+ for( int i = 0; i < path->elementCount(); i++)
+ {
+ currElement = path->elementAt( i );
+ switch(currElement.type)
+ {
+ case QPainterPath::MoveToElement:
+ gp_moveTo(env, gp, cls, currElement.x, currElement.y);
+ break;
+ case QPainterPath::LineToElement:
+ gp_lineTo(env, gp, cls, currElement.x, currElement.y);
+ break;
+ case QPainterPath::CurveToElement:
+ if( i + 2 >= path->elementCount() )
+ break;
+ if(path->elementAt(i + 1).type != QPainterPath::CurveToDataElement ||
+ path->elementAt(i + 2).type != QPainterPath::CurveToDataElement)
+ break;
+ gp_curveTo(env, gp, cls, currElement.x, currElement.y,
+ path->elementAt(i + 1).x, path->elementAt(i + 1).y,
+ path->elementAt(i + 2).x, path->elementAt(i + 2).y );
+ i += 2;
+ break;
+ }
+ }
+ env->DeleteLocalRef( cls );
+ return gp;
+}
+
--- /dev/null
+/* qpen.cpp --
+ 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., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 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 <assert.h>
+#include <QColor>
+#include <QPen>
+#include <gnu_java_awt_peer_qt_QPen.h>
+#include "nativewrapper.h"
+
+/*
+ * java.awt.geom.BasicStroke constants.
+ */
+#define JOIN_MITER 0
+#define JOIN_ROUND 1
+#define JOIN_BEVEL 2
+#define CAP_BUTT 0
+#define CAP_ROUND 1
+#define CAP_SQUARE 2
+
+/**
+ * Create a QPen object
+ */
+JNIEXPORT void JNICALL Java_gnu_java_awt_peer_qt_QPen_init
+(JNIEnv *env, jobject obj , jdouble width, jint cap, jint join, jdouble miterlimit)
+{
+ Qt::PenCapStyle qtCap;
+ Qt::PenJoinStyle qtJoin;
+
+ switch(cap)
+ {
+ case CAP_BUTT:
+ qtCap = Qt::FlatCap;
+ break;
+ case CAP_ROUND:
+ qtCap = Qt::RoundCap;
+ break;
+ case CAP_SQUARE:
+ qtCap = Qt::SquareCap;
+ break;
+ }
+
+ switch(join)
+ {
+ case JOIN_MITER:
+ qtJoin = Qt::MiterJoin;
+ break;
+ case JOIN_ROUND:
+ qtJoin = Qt::RoundJoin;
+ break;
+ case JOIN_BEVEL:
+ qtJoin = Qt::BevelJoin;
+ break;
+ }
+
+ QPen *pen = new QPen();
+ assert( pen );
+ pen->setWidthF( (qreal)width );
+ pen->setCapStyle( qtCap );
+ pen->setJoinStyle( qtJoin );
+
+ setNativeObject(env, obj, pen);
+}
+
+/**
+ * Dispose of the QPen object
+ */
+JNIEXPORT void JNICALL Java_gnu_java_awt_peer_qt_QPen_dispose
+(JNIEnv *env, jobject obj)
+{
+ QPen *pen = (QPen *)getNativeObject(env, obj);
+ if ( pen )
+ delete pen;
+}
+
--- /dev/null
+/* qtaudioclip.cpp --
+ 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., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 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 <jni.h>
+#include <assert.h>
+#include <QString>
+#include <QSound>
+#include <gnu_java_awt_peer_qt_QtAudioClip.h>
+#include "qtstrings.h"
+#include "nativewrapper.h"
+
+/*
+ * Loads an audio clip. Returns JNI_TRUE if the load succeded,
+ * JNI_FALSE otherwise.
+ */
+JNIEXPORT void JNICALL Java_gnu_java_awt_peer_qt_QtAudioClip_loadClip
+(JNIEnv *env, jobject obj, jstring filename)
+{
+ QString *qStr = getQString(env, filename);
+
+ QSound *sound = new QSound( *qStr );
+
+ delete qStr;
+
+ setNativeObject( env, obj, sound );
+}
+
+/*
+ * Plays the audio clip, plays looped if loop equals JNI_TRUE.
+ */
+JNIEXPORT void JNICALL Java_gnu_java_awt_peer_qt_QtAudioClip_play
+(JNIEnv *env, jobject obj, jboolean loop)
+{
+ QSound *sound = (QSound *)getNativeObject(env, obj);
+ if( sound != NULL )
+ {
+ sound->setLoops( (loop == JNI_TRUE) ? -1 : 1 );
+ sound->play();
+ }
+}
+
+/*
+ * Stops the audio playback.
+ */
+JNIEXPORT void JNICALL Java_gnu_java_awt_peer_qt_QtAudioClip_stop
+(JNIEnv *env, jobject obj)
+{
+ QSound *sound = (QSound *)getNativeObject(env, obj);
+ if( sound != NULL )
+ sound->stop();
+}
+
+/**
+ * Disposes the audio clip
+ */
+JNIEXPORT void JNICALL Java_gnu_java_awt_peer_qt_QtAudioClip_dispose
+(JNIEnv *env, jobject obj)
+{
+ QSound *sound = (QSound *)getNativeObject(env, obj);
+ if( sound != NULL )
+ {
+ setNativeObject( env, obj, NULL );
+ if( !sound->isFinished() )
+ sound->stop();
+ delete sound;
+ }
+}
+
+/**
+ * Returns whether sound is available.
+ */
+JNIEXPORT jboolean JNICALL Java_gnu_java_awt_peer_qt_QtAudioClip_isAvailable
+(JNIEnv *env, jobject obj)
+{
+ if( QSound::isAvailable() )
+ return JNI_TRUE;
+ else
+ return JNI_FALSE;
+}
+
--- /dev/null
+/* qtbuttonpeer.cpp --
+ 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., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 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 <assert.h>
+#include <QMainWindow>
+#include <QPushButton>
+#include <QFont>
+#include <gnu_java_awt_peer_qt_QtButtonPeer.h>
+#include "qtcomponent.h"
+#include "qtstrings.h"
+#include "keybindings.h"
+#include "buttonevent.h"
+#include "slotcallbacks.h"
+
+
+class MyButton : public QPushButton
+{
+public:
+ MyButton(JNIEnv *env, jobject obj, QWidget *parent) : QPushButton(parent)
+ {
+ setup(env, obj);
+ }
+
+ ~MyButton()
+ {
+ destroy();
+ }
+#define I_KNOW_WHAT_IM_DOING
+#define PARENT QPushButton
+#include "eventmethods.h"
+};
+
+/**
+ * Init method
+ */
+JNIEXPORT void JNICALL Java_gnu_java_awt_peer_qt_QtButtonPeer_init
+(JNIEnv *env, jobject obj)
+{
+
+ QWidget *parentWidget = (QWidget *) getParentWidget( env, obj );
+ MyButton *button = new MyButton( env, obj, parentWidget );
+ assert( button );
+ setNativeObject( env, obj, button );
+ connectButton(button, env, obj); // connect the fireClick method.
+}
+
+/**
+ * Sets the button label.
+ */
+JNIEXPORT void JNICALL Java_gnu_java_awt_peer_qt_QtButtonPeer_setLabel
+(JNIEnv *env, jobject obj, jstring str)
+{
+ QPushButton *button = (QPushButton *) getNativeObject( env, obj );
+ assert( button );
+
+ QString *qStr = getQString(env, str); // AWTLabelEvent takes care of disposal.
+ mainThread->postEventToMain( new AWTLabelEvent( button, qStr ) );
+}
+
+
--- /dev/null
+/* qtcanvaspeer.cpp --
+ 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., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 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 <assert.h>
+#include <QMainWindow>
+#include <QWidget>
+#include <gnu_java_awt_peer_qt_QtCanvasPeer.h>
+#include "qtcomponent.h"
+#include "keybindings.h"
+
+class MyCanvas : public QWidget
+{
+public:
+ MyCanvas(JNIEnv *env, jobject obj, QWidget *parent) : QWidget( parent )
+ {
+ setup(env, obj);
+ }
+
+ ~MyCanvas()
+ {
+ destroy();
+ }
+
+#define I_KNOW_WHAT_IM_DOING
+#define PARENT QWidget
+#include "eventmethods.h"
+};
+
+/*
+ * Construct a QWidget object
+ */
+JNIEXPORT void JNICALL Java_gnu_java_awt_peer_qt_QtCanvasPeer_init
+(JNIEnv *env, jobject obj)
+{
+ QWidget *parentWidget = (QWidget *)getParentWidget(env, obj);
+ // QWidget *canvas = new QWidget( parentWidget );
+ QWidget *canvas = new MyCanvas( env, obj, parentWidget );
+ assert( canvas );
+
+ setNativeObject( env, obj, canvas );
+}
--- /dev/null
+/* qtcheckboxpeer.cpp --
+ 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., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 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 <assert.h>
+#include <QAbstractButton>
+#include <QCheckBox>
+#include <QRadioButton>
+#include <gnu_java_awt_peer_qt_QtCheckboxPeer.h>
+#include "qtstrings.h"
+#include "qtcomponent.h"
+#include "keybindings.h"
+#include "buttonevent.h"
+#include "slotcallbacks.h"
+
+class CheckboxCheckEvent : public AWTEvent {
+
+ private:
+ QAbstractButton *widget;
+ bool checked;
+
+ public:
+ CheckboxCheckEvent(QAbstractButton *w, bool c)
+ {
+ widget = w;
+ checked = c;
+ }
+
+ void runEvent()
+ {
+ if (checked != widget->isChecked())
+ widget->setChecked( checked );
+ }
+};
+
+class MyCheckBox : public QCheckBox
+{
+public:
+ MyCheckBox(JNIEnv *env, jobject obj, QWidget *parent) : QCheckBox( parent )
+ {
+ setup(env, obj);
+ }
+
+ ~MyCheckBox()
+ {
+ destroy();
+ }
+
+#define I_KNOW_WHAT_IM_DOING
+#define PARENT QCheckBox
+#include "eventmethods.h"
+};
+
+/**
+ * Determines whether the darn native object should be a radio button or not
+ */
+static bool isRadioButton( JNIEnv *env, jobject obj )
+{
+ jclass cls = env->FindClass( "gnu/java/awt/peer/qt/QtCheckboxPeer" );
+ jfieldID field = env->GetFieldID( cls, "group", "Ljava/awt/CheckboxGroup;" );
+ if (env->GetObjectField( obj, field ) != NULL)
+ return true;
+ return false;
+}
+
+/**
+ * Construct the native object.
+ */
+JNIEXPORT void JNICALL Java_gnu_java_awt_peer_qt_QtCheckboxPeer_init
+(JNIEnv *env, jobject obj)
+{
+ QWidget *parentWidget = (QWidget *)getParentWidget(env, obj);
+
+ QAbstractButton *cb = (QAbstractButton *) getNativeObject( env, obj );
+ if (cb)
+ delete cb;
+
+ bool radioButton;
+ {
+ jclass cls = env->GetObjectClass( obj );
+ jfieldID field = env->GetFieldID( cls, "owner", "Ljava/awt/Component;" );
+ assert(field != NULL);
+ jobject owner = env->GetObjectField( obj, field );
+ assert(owner != NULL);
+ cls = env->GetObjectClass( owner );
+ jmethodID method = env->GetMethodID( cls,
+ "getCheckboxGroup",
+ "()Ljava/awt/CheckboxGroup;" );
+ assert(method != NULL);
+ jobject group = env->CallObjectMethod( owner, method, 0);
+ radioButton = (group != NULL);
+ }
+
+ if(radioButton)
+ cb = new QRadioButton( parentWidget );
+ else
+ cb = new QCheckBox( parentWidget );
+ // cb = new MyCheckBox( env, obj, parentWidget );
+ assert( cb );
+
+ connectToggle(cb, env, obj); // connect the native event.
+
+ setNativeObject( env, obj, cb );
+}
+
+/*
+ * Sets the checkbox label.
+ */
+JNIEXPORT void JNICALL Java_gnu_java_awt_peer_qt_QtCheckboxPeer_setLabel
+(JNIEnv *env, jobject obj, jstring label)
+{
+ /* Both QCheckbox and QRadioButton inherit QAbstractButton */
+ QAbstractButton *cb = (QAbstractButton *) getNativeObject( env, obj );
+ assert( cb );
+
+ QString *qStr = getQString(env, label);
+ mainThread->postEventToMain( new AWTLabelEvent( cb, qStr ) );
+ // AWTLabelEvent takes care of disposal of qStr
+}
+
+/*
+ * Sets the checkbox state.
+ */
+JNIEXPORT void JNICALL Java_gnu_java_awt_peer_qt_QtCheckboxPeer_setState
+(JNIEnv *env, jobject obj, jboolean state)
+{
+ QAbstractButton *cb = (QAbstractButton *) getNativeObject( env, obj );
+ assert( cb );
+ mainThread->postEventToMain( new CheckboxCheckEvent( cb, (state == JNI_TRUE) ) );
+}
+
--- /dev/null
+/* qtchoicepeer.cpp --
+ 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., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 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 <assert.h>
+#include <QComboBox>
+#include <gnu_java_awt_peer_qt_QtChoicePeer.h>
+#include "qtcomponent.h"
+#include "qtstrings.h"
+#include "mainthreadinterface.h"
+#include "slotcallbacks.h"
+
+class InsertEvent : public AWTEvent {
+
+ private:
+ QComboBox *widget;
+ QString *string;
+ int index;
+
+ public:
+ InsertEvent(QComboBox *w, QString *s, int i) : AWTEvent()
+ {
+ widget = w;
+ string = s;
+ index = i;
+ }
+
+ void runEvent()
+ {
+ widget->insertItem( index, *string );
+ delete string;
+ }
+};
+
+class RemoveSelectEvent : public AWTEvent {
+
+ private:
+ QComboBox *widget;
+ int index;
+ bool remove;
+
+ public:
+ RemoveSelectEvent(QComboBox *w, int i, bool r) : AWTEvent()
+ {
+ widget = w;
+ index = i;
+ remove = r;
+ }
+
+ void runEvent()
+ {
+ if (remove)
+ widget->removeItem( index );
+ else
+ widget->setCurrentIndex( index );
+ }
+};
+
+/*
+ * Constructs tha QComboBox object
+ */
+JNIEXPORT void JNICALL Java_gnu_java_awt_peer_qt_QtChoicePeer_init
+(JNIEnv *env, jobject obj)
+{
+ QWidget *parentWidget = (QWidget *)getParentWidget(env, obj);
+
+ QComboBox *box = new QComboBox( parentWidget );
+ assert( box );
+
+ setNativeObject( env, obj, box );
+
+ connectChoice(box, env, obj); // connect the fireChoice method.
+}
+
+/*
+ * Inserts a choice box item at index.
+ */
+JNIEXPORT void JNICALL Java_gnu_java_awt_peer_qt_QtChoicePeer_add
+(JNIEnv *env, jobject obj, jstring itemLabel, jint index)
+{
+ QComboBox *box = (QComboBox *) getNativeObject( env, obj );
+ assert( box );
+
+ QString *qStr = getQString( env, itemLabel );
+ mainThread->postEventToMain( new InsertEvent( box, qStr, index ) );
+}
+
+/*
+ * Removes a choice box item at index.
+ */
+JNIEXPORT void JNICALL Java_gnu_java_awt_peer_qt_QtChoicePeer_remove
+(JNIEnv *env, jobject obj, jint index)
+{
+ QComboBox *box = (QComboBox *) getNativeObject( env, obj );
+ assert( box );
+ mainThread->postEventToMain( new RemoveSelectEvent( box, index, true ) );
+}
+
+/**
+ * Selects a choice box item.
+ */
+JNIEXPORT void JNICALL Java_gnu_java_awt_peer_qt_QtChoicePeer_select
+(JNIEnv *env, jobject obj, jint index)
+{
+ QComboBox *box = (QComboBox *) getNativeObject( env, obj );
+ assert( box );
+ mainThread->postEventToMain( new RemoveSelectEvent( box, index, false ) );
+}
+
--- /dev/null
+/* qtcomponent.cpp --
+ 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., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 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 <jni.h>
+#include <assert.h>
+#include <qmainwindow.h>
+#include <qwidget.h>
+#include "qtcomponent.h"
+#include "containers.h"
+
+#define COMPONENT_CLASS "gnu/java/awt/peer/qt/QtComponentPeer"
+
+/*
+ * Returns the parent widget for a QtComponentPeer
+ */
+void *getParentWidget( JNIEnv *env, jobject qtcomponentpeer )
+{
+ jclass componentCls = env->GetObjectClass( qtcomponentpeer );
+ jfieldID ownerField = env->GetFieldID( componentCls,
+ "owner", "Ljava/awt/Component;" );
+ assert( ownerField );
+ jobject owner = env->GetObjectField( qtcomponentpeer, ownerField );
+ if (owner == NULL)
+ return NULL;
+
+ jclass ownerCls = env->GetObjectClass( owner );
+ jmethodID getParentMID = env->GetMethodID( ownerCls,
+ "getParent",
+ "()Ljava/awt/Container;" );
+ assert(getParentMID);
+
+ jobject parent = env->CallObjectMethod( owner, getParentMID, 0);
+ assert(parent);
+
+ // Get the parents peer
+ jclass parentCls = env->GetObjectClass( parent );
+ {
+ jclass frameCls = env->FindClass( "java/awt/Frame" );
+ if(env->IsInstanceOf( parent, frameCls ) == JNI_TRUE)
+ return frameChildWidget( env, parent );
+ }
+ {
+ jclass scrollpaneCls = env->FindClass( "java/awt/ScrollPane" );
+ if(env->IsInstanceOf( parent, scrollpaneCls ) == JNI_TRUE)
+ return scrollPaneChildWidget( env, parent );
+ }
+
+ jmethodID getPeerMID = env->GetMethodID( parentCls,
+ "getPeer",
+ "()Ljava/awt/peer/ComponentPeer;" );
+ assert(getPeerMID);
+ return getNativeObject(env, env->CallObjectMethod( parent, getPeerMID, 0));
+}
+
+/*
+ * Creates a java.awt.Dimension object from a QSize.
+ */
+jobject makeDimension(JNIEnv *env, QSize *size)
+{
+ if( size == NULL )
+ return NULL;
+ if( size->isNull() || !size->isValid() )
+ return NULL;
+ jclass cls = env->FindClass("java/awt/Dimension");
+ jmethodID mid = env->GetMethodID(cls, "<init>", "(II)V");
+ jvalue values[2];
+
+ values[0].i = (jint) size->width();
+ values[1].i = (jint) size->height();
+
+ return env->NewObjectA(cls, mid, values);
+}
+
+/*
+ * Creates a java.awt.Point object from a QPoint.
+ */
+jobject makePoint(JNIEnv *env, QPoint &p)
+{
+ jclass cls = env->FindClass("java/awt/Point");
+ jmethodID mid = env->GetMethodID(cls, "<init>", "(II)V");
+ jvalue values[2];
+
+ values[0].i = (jint) p.x();
+ values[1].i = (jint) p.y();
+
+ return env->NewObjectA(cls, mid, values);
+}
+
--- /dev/null
+#ifndef QTCOMPONENT_H
+#define QTCOMPONENT_H
+
+#include <QSize>
+#include <QPoint>
+//#include <cassert.h>
+#include <jni.h>
+#include "nativewrapper.h"
+
+void *getParentWidget( JNIEnv *env, jobject qtcomponentpeer );
+
+jobject makeDimension(JNIEnv *env, QSize *size);
+
+jobject makePoint(JNIEnv *env, QPoint &p);
+
+#endif
--- /dev/null
+/* qtcomponentpeer.cpp --
+ 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., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 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 <assert.h>
+#include <QApplication>
+#include <QDesktopWidget>
+#include <QShowEvent>
+#include <QHideEvent>
+#include <QColor>
+#include <QCursor>
+#include <QWidget>
+#include <gnu_java_awt_peer_qt_QtComponentPeer.h>
+#include "qtcomponent.h"
+#include "componentevent.h"
+#include "qtfont.h"
+
+extern QApplication *qApplication;
+
+// Java Cursor types.
+#define DEFAULT_CURSOR 0
+#define CROSSHAIR_CURSOR 1
+#define TEXT_CURSOR 2
+#define WAIT_CURSOR 3
+#define SW_RESIZE_CURSOR 4
+#define SE_RESIZE_CURSOR 5
+#define NW_RESIZE_CURSOR 6
+#define NE_RESIZE_CURSOR 7
+#define N_RESIZE_CURSOR 8
+#define S_RESIZE_CURSOR 9
+#define W_RESIZE_CURSOR 10
+#define E_RESIZE_CURSOR 11
+#define HAND_CURSOR 12
+#define MOVE_CURSOR 13
+
+/**
+ * Call back the init() method from the main thread.
+ */
+JNIEXPORT void JNICALL Java_gnu_java_awt_peer_qt_QtComponentPeer_callInit
+(JNIEnv *env, jobject obj)
+{
+ mainThread->postEventToMain( new AWTInitEvent( env, obj ) );
+}
+
+/*
+ * Generic disposal.
+ */
+JNIEXPORT void JNICALL Java_gnu_java_awt_peer_qt_QtComponentPeer_disposeNative
+(JNIEnv *env, jobject obj)
+{
+ QWidget *widget = (QWidget *) getNativeObject( env, obj );
+ setNativeObject(env, obj, NULL);
+ mainThread->postEventToMain( new AWTDestroyEvent( widget ) );
+}
+
+/**
+ * Returns the on-screen location of the component.
+ */
+JNIEXPORT void JNICALL Java_gnu_java_awt_peer_qt_QtComponentPeer_getLocationOnScreenNative
+(JNIEnv *env, jobject obj, jobject point)
+{
+ QWidget *widget = (QWidget *) getNativeObject( env, obj );
+ assert( widget );
+ mainThread->postEventToMain( new AWTGetOriginEvent( widget, env, point) );
+}
+
+/*
+ * Get the preferred/minimum size of the widget
+ */
+JNIEXPORT void JNICALL Java_gnu_java_awt_peer_qt_QtComponentPeer_getSizeNative
+(JNIEnv *env, jobject obj, jobject size, jboolean preferred)
+{
+ QWidget *widget = (QWidget *) getNativeObject( env, obj );
+ assert( widget );
+
+ mainThread->postEventToMain
+ (new GetSizeEvent( widget, env, size, (preferred == JNI_TRUE)));
+}
+
+/*
+ */
+JNIEXPORT jboolean JNICALL Java_gnu_java_awt_peer_qt_QtComponentPeer_isObscured
+(JNIEnv *env, jobject obj)
+{
+ jboolean retVal;
+
+ QWidget *widget = (QWidget *) getNativeObject( env, obj );
+ assert( widget );
+
+ retVal = (widget->isVisible() == TRUE) ? JNI_TRUE : JNI_FALSE;
+
+ return retVal;
+}
+
+/*
+ * Returns whether the widget is focusable or not.
+ */
+JNIEXPORT jboolean JNICALL Java_gnu_java_awt_peer_qt_QtComponentPeer_isFocusable
+(JNIEnv *env, jobject obj)
+{
+ jboolean retVal;
+
+ QWidget *widget = (QWidget *) getNativeObject( env, obj );
+ assert( widget );
+
+ retVal = (widget->focusPolicy() != Qt::NoFocus) ? JNI_TRUE : JNI_FALSE;
+
+ return retVal;
+}
+
+/**
+ * Requests the focus
+ */
+JNIEXPORT void JNICALL Java_gnu_java_awt_peer_qt_QtComponentPeer_requestFocus
+ (JNIEnv *env, jobject obj)
+{
+ QWidget *widget = (QWidget *) getNativeObject( env, obj );
+ assert( widget );
+ mainThread->postEventToMain( new AWTReqFocusEvent( widget ) );
+}
+
+/*
+ * Sets the size and position. Important.
+ */
+JNIEXPORT void JNICALL Java_gnu_java_awt_peer_qt_QtComponentPeer_setBoundsNative
+(JNIEnv *env, jobject obj, jint x, jint y, jint width, jint height)
+{
+ QWidget *widget = (QWidget *) getNativeObject( env, obj );
+ assert( widget );
+ mainThread->postEventToMain
+ (new AWTResizeEvent( widget, x, y, width, height ) );
+}
+
+/*
+ * Sets the mouse cursor
+ */
+JNIEXPORT void JNICALL Java_gnu_java_awt_peer_qt_QtComponentPeer_setCursor
+ (JNIEnv *env, jobject obj, jint cursortype)
+{
+ QWidget *widget = (QWidget *) getNativeObject( env, obj );
+ assert( widget );
+
+ Qt::CursorShape shape;
+ switch(cursortype)
+ {
+ case CROSSHAIR_CURSOR:
+ shape = Qt::CrossCursor;
+ break;
+
+ case W_RESIZE_CURSOR:
+ case E_RESIZE_CURSOR:
+ shape = Qt::SizeHorCursor;
+ break;
+ case N_RESIZE_CURSOR:
+ case S_RESIZE_CURSOR:
+ shape = Qt::SizeVerCursor;
+ break;
+ case HAND_CURSOR:
+ shape = Qt::PointingHandCursor;
+ break;
+ case MOVE_CURSOR:
+ shape = Qt::SizeAllCursor;
+ break;
+
+ case NE_RESIZE_CURSOR:
+ case SW_RESIZE_CURSOR:
+ shape = Qt::SizeBDiagCursor;
+ break;
+ case NW_RESIZE_CURSOR:
+ case SE_RESIZE_CURSOR:
+ shape = Qt::SizeFDiagCursor;
+ break;
+ case TEXT_CURSOR:
+ shape = Qt::IBeamCursor;
+ break;
+ case WAIT_CURSOR:
+ shape = Qt::WaitCursor;
+ break;
+
+ case DEFAULT_CURSOR:
+ default:
+ shape = Qt::ArrowCursor;
+ break;
+ }
+
+ mainThread->postEventToMain( new AWTCursorEvent( widget, shape ) );
+}
+
+/*
+ * Enable, disable.
+ */
+JNIEXPORT void JNICALL Java_gnu_java_awt_peer_qt_QtComponentPeer_setEnabled
+(JNIEnv *env, jobject obj, jboolean state)
+{
+ QWidget *widget = (QWidget *) getNativeObject( env, obj );
+ assert(widget != NULL);
+
+ mainThread->postEventToMain( new AWTEnableEvent( widget, (state == JNI_TRUE) ) );
+}
+
+/**
+ * Set the font
+ */
+JNIEXPORT void JNICALL Java_gnu_java_awt_peer_qt_QtComponentPeer_setFontNative
+(JNIEnv *env, jobject obj, jobject fontpeer)
+{
+ QWidget *widget = (QWidget *) getNativeObject( env, obj );
+ assert( widget );
+ QFont *font = (QFont *) getFont( env, fontpeer );
+ assert( font );
+
+ mainThread->postEventToMain( new AWTFontEvent(widget, font) );
+}
+
+/*
+ * Sets the back- or foreground color.
+ */
+JNIEXPORT void JNICALL Java_gnu_java_awt_peer_qt_QtComponentPeer_setGround
+(JNIEnv *env, jobject obj, jint r, jint g, jint b, jboolean isForeground)
+{
+ QColor *color = new QColor(r, g, b);
+
+ QWidget *widget = (QWidget *) getNativeObject( env, obj );
+ assert(widget);
+ mainThread->postEventToMain( new AWTBackgroundEvent(widget,
+ (isForeground == JNI_TRUE),
+ color) );
+}
+
+/*
+ * Sets the visibility.
+ */
+JNIEXPORT void JNICALL Java_gnu_java_awt_peer_qt_QtComponentPeer_setVisible
+(JNIEnv *env, jobject obj, jboolean state)
+{
+ QWidget *widget = (QWidget *) getNativeObject( env, obj );
+ assert(widget != NULL);
+ mainThread->postEventToMain( new AWTShowEvent( widget, (state == JNI_TRUE) ) );
+}
+
+/*
+ * Returns whether the widget handles wheel scrolling.
+ */
+JNIEXPORT jboolean JNICALL Java_gnu_java_awt_peer_qt_QtComponentPeer_handlesWheelScrolling
+(JNIEnv *env, jobject obj)
+{
+ jboolean handles = JNI_FALSE;
+
+ QWidget *cb = (QWidget *) getNativeObject( env, obj );
+ if( cb )
+ if( cb->focusPolicy() & Qt::WheelFocus )
+ handles = JNI_TRUE;
+
+ return handles;
+}
+
+/**
+ * calls qwidget::update on the compnent.
+ */
+JNIEXPORT void JNICALL Java_gnu_java_awt_peer_qt_QtComponentPeer_QtUpdateArea
+(JNIEnv *env, jobject obj, jint x, jint y, jint w, jint h)
+{
+ QWidget *cb = (QWidget *) getNativeObject( env, obj );
+ if( cb )
+ mainThread->postEventToMain( new AWTUpdateEvent
+ (cb, false, x, y, w, h ) );
+}
+
+/*
+ * calls qwidget::update on the compnent.
+ */
+JNIEXPORT void JNICALL Java_gnu_java_awt_peer_qt_QtComponentPeer_QtUpdate
+(JNIEnv *env, jobject obj)
+{
+ QWidget *cb = (QWidget *) getNativeObject( env, obj );
+ if( cb )
+ mainThread->postEventToMain( new AWTUpdateEvent
+ ( cb, true, 0, 0, 0, 0 ) );
+}
+
+/*
+ * Returns the native background color.
+ */
+JNIEXPORT jobject JNICALL Java_gnu_java_awt_peer_qt_QtComponentPeer_getNativeBackground
+(JNIEnv *env, jobject obj)
+{
+ QWidget *cb = (QWidget *) getNativeObject( env, obj );
+ assert(cb);
+ QColor c = cb->palette().background().color().toRgb();
+
+ jclass cls = env->FindClass("java/awt/Color");
+ jmethodID mid = env->GetMethodID(cls, "<init>", "(III)V");
+ jvalue values[3];
+
+ values[0].i = (jint) c.red();
+ values[1].i = (jint) c.green();
+ values[2].i = (jint) c.blue();
+
+ return env->NewObjectA(cls, mid, values);
+}
+
+/*
+ * Returns which screen the component is on.
+ */
+JNIEXPORT jint JNICALL Java_gnu_java_awt_peer_qt_QtComponentPeer_whichScreen
+(JNIEnv *env, jobject obj)
+{
+ QWidget *widget = (QWidget *) getNativeObject( env, obj );
+ assert( widget );
+ return (jint) qApplication->desktop()->screenNumber( widget );
+}
+
+/*
+ * Reparents the widget.
+ */
+JNIEXPORT void JNICALL Java_gnu_java_awt_peer_qt_QtComponentPeer_reparentNative
+(JNIEnv *env, jobject obj, jobject newparent)
+{
+ QWidget *widget = (QWidget *) getNativeObject( env, obj );
+ assert( widget );
+ QWidget *parentWidget = (QWidget *) getNativeObject( env, newparent );
+ assert( parentWidget );
+ mainThread->postEventToMain( new AWTReparent(widget, parentWidget ) );
+}
+
+/*
+ * Get the preferred size of the widget
+ */
+JNIEXPORT jobject JNICALL Java_gnu_java_awt_peer_qt_QtComponentPeer_getBounds
+
+(JNIEnv *env, jobject obj)
+{
+ QWidget *widget = (QWidget *) getNativeObject( env, obj );
+ assert( widget );
+
+ int x, y, w, h;
+ widget->geometry().getRect(&x, &y, &w, &h);
+
+ jclass cls = env->FindClass("java/awt/Rectangle");
+ assert( cls != NULL);
+ jmethodID mid = env->GetMethodID(cls, "<init>", "(IIII)V");
+ assert( mid != NULL);
+ jvalue values[4];
+
+ values[0].i = (jint) x;
+ values[1].i = (jint) y;
+ values[2].i = (jint) w;
+ values[3].i = (jint) h;
+
+ return env->NewObjectA(cls, mid, values);
+}
--- /dev/null
+/* qtdialogpeer.cpp --
+ 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., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 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 <assert.h>
+#include <qdialog.h>
+#include <gnu_java_awt_peer_qt_QtDialogPeer.h>
+#include "qtcomponent.h"
+#include "containers.h"
+#include "qtstrings.h"
+#include "keybindings.h"
+#include "mainthreadinterface.h"
+
+class MyDialog : public QDialog
+{
+public:
+ MyDialog(JNIEnv *env, jobject obj, QWidget *parent) : QDialog(parent)
+ {
+ setup(env, obj);
+ }
+
+ ~MyDialog()
+ {
+ destroy();
+ }
+
+#define I_KNOW_WHAT_IM_DOING
+#define PARENT QDialog
+#include "eventmethods.h"
+};
+
+class DialogSettingsEvent : public AWTEvent {
+
+ private:
+ QDialog *widget;
+ bool modal;
+ bool value;
+
+ public:
+ DialogSettingsEvent(QDialog *w, bool m, bool v) : AWTEvent()
+ {
+ widget = w;
+ modal = m;
+ value = v;
+ }
+
+ void runEvent()
+ {
+ if( modal )
+ widget->setModal( value );
+ else
+ widget->setSizeGripEnabled( value );
+ }
+};
+
+class DialogResizeEvent : public AWTEvent {
+
+ private:
+ QWidget *widget;
+ bool fixed;
+ int x, y, w, h;
+
+ public:
+ DialogResizeEvent(QWidget *wid, int x0, int y0, int w0, int h0, bool f)
+ {
+ widget = wid;
+ fixed = f;
+ x = x0; y = y0;
+ w = w0; h = h0;
+ if(w == 0 && h == 0) w = h = 10;
+ }
+
+ void runEvent()
+ {
+ if( fixed )
+ widget->setFixedSize( w, h );
+ widget->setGeometry( x, y, w, h );
+ }
+};
+
+/*
+ * Constructs a QDialog native object.
+ */
+JNIEXPORT void JNICALL Java_gnu_java_awt_peer_qt_QtDialogPeer_init
+(JNIEnv *env, jobject obj)
+{
+ QWidget *parentWidget = (QWidget *) getParentWidget( env, obj );
+ // QDialog *dialog = new QDialog(parentWidget);
+ MyDialog *dialog = new MyDialog(env, obj, parentWidget);
+ assert( dialog );
+ setNativeObject( env, obj, dialog );
+}
+
+
+/*
+ * Sets the modality of the dialog.
+ */
+JNIEXPORT void JNICALL Java_gnu_java_awt_peer_qt_QtDialogPeer_setModal
+(JNIEnv *env, jobject obj, jboolean flag)
+{
+ QDialog *dialog = (QDialog *) getNativeObject( env, obj );
+ assert( dialog );
+ mainThread->postEventToMain( new DialogSettingsEvent(dialog, true, (flag == JNI_TRUE)));
+}
+
+
+/*
+ * Set resizeable.
+ */
+JNIEXPORT void JNICALL Java_gnu_java_awt_peer_qt_QtDialogPeer_setResizable
+(JNIEnv *env, jobject obj, jboolean flag)
+{
+ QDialog *dialog = (QDialog *) getNativeObject( env, obj );
+ assert( dialog );
+ mainThread->postEventToMain( new DialogSettingsEvent(dialog, false, (flag == JNI_TRUE)));
+}
+
+/*
+ * Overloaded to allow for size locking.
+ */
+JNIEXPORT void JNICALL Java_gnu_java_awt_peer_qt_QtDialogPeer_setBoundsNative
+(JNIEnv *env, jobject obj, jint x, jint y, jint width, jint height, jboolean fixed)
+{
+ QWidget *widget = (QWidget *) getNativeObject( env, obj );
+ assert( widget );
+
+ QRect g = widget->geometry();
+ if(g.x() != x || g.y() != y ||
+ g.width() != width || g.height() != height)
+ mainThread->postEventToMain( new DialogResizeEvent( widget, x, y, width, height, (fixed == JNI_TRUE) ) );
+}
--- /dev/null
+/* qtembeddedwindowpeer.cpp --
+ 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., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 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 <assert.h>
+#include <QWidget>
+#include <QX11EmbedWidget>
+#include <gnu_java_awt_peer_qt_QtEmbeddedWindowPeer.h>
+#include "qtcomponent.h"
+#include "keybindings.h"
+#include "mainthreadinterface.h"
+
+/**
+ * Event wrapper for embedding.
+ */
+class EmbedEvent : public AWTEvent {
+
+ private:
+ QX11EmbedWidget *widget;
+ WId id;
+
+ public:
+ EmbedEvent(QX11EmbedWidget *w, WId i) : AWTEvent()
+ {
+ widget = w;
+ id = i;
+ }
+
+ void runEvent()
+ {
+ widget->embedInto( id );
+ }
+};
+
+
+class MyEmbeddedPanel : public QX11EmbedWidget
+{
+public:
+ MyEmbeddedPanel(JNIEnv *env, jobject obj, QWidget *parent) : QX11EmbedWidget( parent )
+ {
+ setup(env, obj);
+ }
+
+ ~MyEmbeddedPanel()
+ {
+ destroy();
+ }
+
+#define I_KNOW_WHAT_IM_DOING
+#define PARENT QX11EmbedWidget
+#include "eventmethods.h"
+#undef I_KNOW_WHAT_IM_DOING
+#undef PARENT
+};
+
+/**
+ * Init
+ */
+JNIEXPORT void JNICALL Java_gnu_java_awt_peer_qt_QtEmbeddedWindowPeer_init
+(JNIEnv *env, jobject obj)
+{
+ QWidget *parentWidget = (QWidget *) getParentWidget( env, obj );
+ QWidget *panel = new MyEmbeddedPanel( env, obj, parentWidget );
+ assert( panel );
+
+ setNativeObject( env, obj, panel );
+}
+
+/**
+ * Embed the thing.
+ */
+JNIEXPORT void JNICALL Java_gnu_java_awt_peer_qt_QtEmbeddedWindowPeer_embed
+(JNIEnv *env, jobject obj, jlong wid)
+{
+ MyEmbeddedPanel *panel = (MyEmbeddedPanel *)getNativeObject( env, obj );
+ assert( panel );
+
+ mainThread->postEventToMain( new EmbedEvent( panel, (WId)wid ) );
+}
+
--- /dev/null
+/* qtfiledialogpeer.cpp --
+ 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., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 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 <assert.h>
+#include <QFileDialog>
+#include <QDialog>
+#include <gnu_java_awt_peer_qt_QtFileDialogPeer.h>
+#include "qtcomponent.h"
+#include "qtstrings.h"
+#include "mainthreadinterface.h"
+
+// Constants from FileDialog
+#define LOAD 0
+#define SAVE 1
+
+class FileDialogMode : public AWTEvent {
+
+ private:
+ QFileDialog *widget;
+ bool open;
+
+ public:
+ FileDialogMode(QFileDialog *w, bool o) : AWTEvent()
+ {
+ widget = w;
+ open = o;
+ }
+
+ void runEvent()
+ {
+ if( open )
+ {
+ widget->setAcceptMode( QFileDialog::AcceptOpen );
+ widget->setFileMode( QFileDialog::ExistingFile );
+ }
+ else
+ {
+ widget->setAcceptMode( QFileDialog::AcceptSave );
+ widget->setFileMode( QFileDialog::AnyFile );
+ }
+ }
+};
+
+
+/*
+ * Constructs a QDialog native object.
+ */
+JNIEXPORT void JNICALL Java_gnu_java_awt_peer_qt_QtFileDialogPeer_init
+(JNIEnv *env, jobject obj)
+{
+ QWidget *parentWidget = (QWidget *) getParentWidget( env, obj );
+ QFileDialog *dialog = new QFileDialog(parentWidget);
+ assert( dialog );
+ setNativeObject( env, obj, dialog );
+}
+
+/**
+ * Sets the mode (LOAD or SAVE)
+ */
+JNIEXPORT void JNICALL Java_gnu_java_awt_peer_qt_QtFileDialogPeer_setMode
+(JNIEnv *env, jobject obj, jint mode)
+{
+ QFileDialog *filedialog = (QFileDialog *) getNativeObject( env, obj );
+ assert( filedialog );
+
+ mainThread->postEventToMain( new FileDialogMode( filedialog, (mode != SAVE) ) );
+}
--- /dev/null
+#ifndef QTFONT_H
+#define QTFONT_H
+
+#include <jni.h>
+
+QFont *getFont( JNIEnv *env, jobject obj );
+
+#endif
--- /dev/null
+/* qtfontmetrics.cpp --
+ 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., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 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 <assert.h>
+#include <QChar>
+#include <QFont>
+#include <QFontMetrics>
+#include <QString>
+#include <QPainter>
+#include <QStringList>
+#include <QFontDatabase>
+#include <gnu_java_awt_peer_qt_QtFontMetrics.h>
+#include "qtfont.h"
+#include "qtstrings.h"
+#include "qtgraphics.h"
+
+QFontMetrics *getFontMetrics( JNIEnv *env, jobject obj )
+{
+ jclass cls = env->GetObjectClass( obj );
+ jfieldID field = env->GetFieldID( cls, "nativeObject", "J" );
+ return (QFontMetrics *)env->GetLongField( obj, field );
+}
+
+static void setNativePtr( JNIEnv *env, jobject obj, void *value )
+{
+ jlong longValue = (jlong) value;
+ jclass cls = env->GetObjectClass( obj );
+ jfieldID field = env->GetFieldID( cls, "nativeObject", "J" );
+ env->SetLongField( obj, field, longValue );
+}
+
+static jobject makeRectangle(JNIEnv *env, QRect *rect)
+{
+ if( rect == NULL )
+ return NULL;
+ if( rect->isNull() || !rect->isValid() )
+ return NULL;
+ jclass cls = env->FindClass("java/awt/Rectangle");
+ jmethodID mid = env->GetMethodID(cls, "<init>", "(IIII)V");
+ jvalue values[4];
+
+ int x,y,w,h;
+ rect->getRect(&x, &y, &w, &h);
+ values[0].i = (jint) x;
+ values[1].i = (jint) y;
+ values[2].i = (jint) w;
+ values[3].i = (jint) h;
+
+ return env->NewObjectA(cls, mid, values);
+}
+
+/*
+ * Create font metrics from a font.
+ */
+JNIEXPORT void JNICALL Java_gnu_java_awt_peer_qt_QtFontMetrics_init
+(JNIEnv *env, jobject obj, jobject fontPeer)
+{
+ QFont *f = getFont(env, fontPeer);
+ assert( f );
+ QFontMetrics *fm = new QFontMetrics( *f );
+ assert( fm );
+ setNativePtr( env, obj, fm );
+}
+
+/*
+ * Create font metrics from a font.
+ */
+JNIEXPORT void JNICALL Java_gnu_java_awt_peer_qt_QtFontMetrics_initGraphics
+(JNIEnv *env, jobject obj, jobject fontPeer, jobject graphics)
+{
+ QFont *f = getFont(env, fontPeer);
+ assert( f );
+ QPainter *painter = getPainter( env, graphics );
+ assert( painter );
+ QFontMetrics *fm = new QFontMetrics( *f , painter->device());
+ assert( fm );
+ setNativePtr( env, obj, fm );
+}
+
+/*
+ * Dispose
+ */
+JNIEXPORT void JNICALL Java_gnu_java_awt_peer_qt_QtFontMetrics_dispose
+(JNIEnv *env, jobject obj)
+{
+ QFontMetrics *fm = getFontMetrics( env, obj );
+ if ( fm )
+ delete fm;
+ setNativePtr( env, obj, NULL );
+}
+
+/*
+ * Returns JNI_TRUE if a character is displayable.
+ */
+JNIEXPORT jboolean JNICALL Java_gnu_java_awt_peer_qt_QtFontMetrics_canDisplay
+(JNIEnv *env, jobject obj, jchar c)
+{
+ QFontMetrics *fm = getFontMetrics( env, obj );
+ assert( fm );
+ bool result = fm->inFont( QChar( (unsigned short)c ) );
+ return (result ? JNI_TRUE : JNI_FALSE);
+}
+
+/*
+ * Returns the ascent.
+ */
+JNIEXPORT jint JNICALL Java_gnu_java_awt_peer_qt_QtFontMetrics_getAscent
+(JNIEnv *env, jobject obj)
+{
+ QFontMetrics *fm = getFontMetrics( env, obj );
+ assert( fm );
+ return fm->ascent();
+}
+
+/*
+ * Returns the descent
+ */
+JNIEXPORT jint JNICALL Java_gnu_java_awt_peer_qt_QtFontMetrics_getDescent
+(JNIEnv *env, jobject obj)
+{
+ QFontMetrics *fm = getFontMetrics( env, obj );
+ assert( fm );
+ return fm->descent();
+}
+
+/*
+ * Returns the height.
+ */
+JNIEXPORT jint JNICALL Java_gnu_java_awt_peer_qt_QtFontMetrics_getHeight
+(JNIEnv *env, jobject obj)
+{
+ QFontMetrics *fm = getFontMetrics( env, obj );
+ assert( fm );
+ return fm->height();
+}
+
+/*
+ */
+JNIEXPORT jint JNICALL Java_gnu_java_awt_peer_qt_QtFontMetrics_getLeading
+(JNIEnv *env, jobject obj)
+{
+ QFontMetrics *fm = getFontMetrics( env, obj );
+ assert( fm );
+ return fm->leading();
+}
+
+/*
+ * getStringBounds
+ */
+JNIEXPORT jobject JNICALL Java_gnu_java_awt_peer_qt_QtFontMetrics_getStringBounds
+(JNIEnv *env, jobject obj, jstring str)
+{
+ QFontMetrics *fm = getFontMetrics( env, obj );
+ assert( fm );
+ QString *qStr = getQString(env, str);
+ QRect r = fm->boundingRect( *qStr );
+ delete qStr;
+
+ return makeRectangle( env, &r );
+}
+
+/*
+ * Returns the width of the widest character.
+ */
+JNIEXPORT jint JNICALL Java_gnu_java_awt_peer_qt_QtFontMetrics_getMaxAdvance
+(JNIEnv *env, jobject obj)
+{
+ QFontMetrics *fm = getFontMetrics( env, obj );
+ assert( fm );
+ return fm->maxWidth();
+}
+
+/*
+ * Returns the width of a given character.
+ */
+JNIEXPORT jint JNICALL Java_gnu_java_awt_peer_qt_QtFontMetrics_charWidth
+(JNIEnv *env, jobject obj, jchar c)
+{
+ QFontMetrics *fm = getFontMetrics( env, obj );
+ assert( fm );
+ return fm->width( QChar( (unsigned short)c ) );
+}
+
+/*
+ * Returns the width of a string.
+ */
+JNIEXPORT jint JNICALL Java_gnu_java_awt_peer_qt_QtFontMetrics_stringWidth
+(JNIEnv *env, jobject obj, jstring str)
+{
+ QFontMetrics *fm = getFontMetrics( env, obj );
+ assert( fm );
+ QString *qStr = getQString(env, str);
+ int width = fm->width( *qStr );
+ delete qStr;
+ return width;
+}
+
+
+
--- /dev/null
+/* qtfontpeer.cpp --
+ 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., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 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 <assert.h>
+#include <QFont>
+#include <QString>
+#include <gnu_java_awt_peer_qt_QtFontPeer.h>
+#include "qtfont.h"
+#include "qtstrings.h"
+
+// java.awt.Font constants
+#define PLAIN 0
+#define BOLD 1
+#define ITALIC 2
+
+QFont *getFont( JNIEnv *env, jobject obj )
+{
+ jclass cls = env->GetObjectClass( obj );
+ jfieldID field = env->GetFieldID( cls, "nativeObject", "J" );
+ return (QFont *)env->GetLongField( obj, field );
+}
+
+static void setNativePtr( JNIEnv *env, jobject obj, void *value )
+{
+ jlong longValue = (jlong) value;
+ jclass cls = env->GetObjectClass( obj );
+ jfieldID field = env->GetFieldID( cls, "nativeObject", "J" );
+ env->SetLongField( obj, field, longValue );
+}
+
+/*
+ * Creates a font.
+ */
+JNIEXPORT void JNICALL Java_gnu_java_awt_peer_qt_QtFontPeer_create
+(JNIEnv *env, jobject obj, jstring name, jint style, jint size)
+{
+ QString *str = getQString(env, name);
+ QFont *font = NULL;
+ font = new QFont( *str, size,
+ ((style & BOLD) != 0) ? QFont::Bold : QFont::Normal,
+ ((style & ITALIC) != 0) );
+ assert( font );
+ delete str;
+ setNativePtr( env, obj, font );
+}
+
+/*
+ * Destroys a font.
+ */
+JNIEXPORT void JNICALL Java_gnu_java_awt_peer_qt_QtFontPeer_dispose
+(JNIEnv *env, jobject obj)
+{
+ QFont *font = getFont( env, obj );
+ if( font )
+ delete font;
+ setNativePtr( env, obj, NULL );
+}
+
--- /dev/null
+/* qtframepeer.cpp --
+ 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., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 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 <assert.h>
+#include <QApplication>
+#include <QIcon>
+#include <QMainWindow>
+#include <QMenuBar>
+#include <QPixmap>
+#include <QToolBar>
+#include <QThread>
+#include <gnu_java_awt_peer_qt_QtFramePeer.h>
+#include "qtcomponent.h"
+#include "qtstrings.h"
+#include "qtimage.h"
+#include "containers.h"
+#include "keybindings.h"
+#include "mainthreadinterface.h"
+
+#define MenuSizeDefault 5
+
+/*
+ * Our QMainWindow subclass
+ */
+class MyFrame : public QMainWindow
+{
+public:
+ MyFrame(JNIEnv *env, jobject obj) : QMainWindow(0, Qt::Window )
+ {
+ setup(env, obj);
+ }
+
+ ~MyFrame()
+ {
+ destroy();
+ }
+
+#define I_KNOW_WHAT_IM_DOING
+#define PARENT QMainWindow
+#include "eventmethods.h"
+};
+
+/**
+ * Event wrapper for adding a menu bar to the frame
+ * if the QMenuBar pointer is NULL, the current menu bar is removed.
+ */
+class FrameMenuEvent : public AWTEvent {
+
+ private:
+ QMainWindow *widget;
+ QMenuBar *menu;
+
+ public:
+ FrameMenuEvent(QMainWindow *w, QMenuBar *mb) : AWTEvent()
+ {
+ widget = w;
+ menu = mb;
+ }
+
+ void runEvent()
+ {
+ if( menu != NULL)
+ widget->setMenuBar( menu );
+ else
+ delete widget->menuBar();
+ }
+};
+
+/**
+ * Returns the child widget for the frame (the centralWidget in qt terms)
+ */
+QWidget *frameChildWidget( JNIEnv *env, jobject component )
+{
+ jclass frameCls = env->FindClass( "java/awt/Frame" );
+ assert( frameCls );
+ jmethodID getPeerMID = env->GetMethodID( frameCls,
+ "getPeer",
+ "()Ljava/awt/peer/ComponentPeer;" );
+ assert(getPeerMID);
+
+ jobject framepeerobj = env->CallObjectMethod( component, getPeerMID, 0);
+ if( framepeerobj == NULL )
+ return (QWidget *)NULL;
+
+ MyFrame *window = (MyFrame *)getNativeObject(env, framepeerobj);
+ assert( window );
+ return window;
+}
+
+/*
+ * Constructs a QMainWindow native object.
+ */
+JNIEXPORT void JNICALL Java_gnu_java_awt_peer_qt_QtFramePeer_init
+(JNIEnv *env, jobject obj)
+{
+ MyFrame *frame = new MyFrame(env, obj);
+ assert( frame );
+ frame->addToolBarBreak ( Qt::BottomToolBarArea );
+ setNativeObject( env, obj, frame );
+}
+
+/**
+ * Sets the icon image.
+ */
+JNIEXPORT void JNICALL Java_gnu_java_awt_peer_qt_QtFramePeer_setIcon
+(JNIEnv *env, jobject obj, jobject image)
+{
+ QMainWindow *frame = (QMainWindow *) getNativeObject( env, obj );
+ assert( frame );
+
+ QIcon *i;
+ if( image == NULL )
+ {
+ // remove icon
+ i = new QIcon();
+ }
+ else
+ {
+ // set icon
+ QImage *img = getQtImage( env, image );
+ assert( img );
+ i = new QIcon( QPixmap::fromImage( *img ) );
+ }
+ frame->setWindowIcon( *i );
+ delete i;
+}
+
+/**
+ * Returns the menu bar height for insets.
+ */
+JNIEXPORT jint JNICALL Java_gnu_java_awt_peer_qt_QtFramePeer_menuBarHeight
+(JNIEnv *env, jobject obj)
+{
+ QMainWindow *frame = (QMainWindow *) getNativeObject( env, obj );
+ assert( frame );
+
+ QMenuBar *mb = frame->menuBar();
+
+ return ( mb != NULL ) ? mb->sizeHint().height() : 0 ;
+}
+
+/*
+ * set Menu bar.
+ */
+JNIEXPORT void JNICALL Java_gnu_java_awt_peer_qt_QtFramePeer_setMenu
+(JNIEnv *env, jobject obj, jobject mbPeer)
+{
+ QMainWindow *frame = (QMainWindow *) getNativeObject( env, obj );
+ assert( frame );
+
+ QMenuBar *menubar = NULL;
+
+ if( mbPeer != NULL )
+ {
+ menubar = (QMenuBar *) getNativeObject( env, mbPeer );
+ assert( menubar );
+ }
+
+ mainThread->postEventToMain( new FrameMenuEvent( frame, menubar ) );
+}
+
+/**
+ * Set the bounds of the maximized frame
+ */
+JNIEXPORT void JNICALL Java_gnu_java_awt_peer_qt_QtFramePeer_setMaximizedBounds (JNIEnv *env, jobject obj, jint w, jint h)
+{
+ QMainWindow *frame = (QMainWindow *) getNativeObject( env, obj );
+ assert( frame );
+ // FIXME
+}
+
--- /dev/null
+/* qtgraphics.cpp --
+ 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., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 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 <assert.h>
+#include <jni.h>
+#include <QPainter>
+#include <QBrush>
+#include <QLinearGradient>
+#include <QPen>
+#include <QPaintDevice>
+#include <QPainterPath>
+#include <QImage>
+#include <QColor>
+#include <gnu_java_awt_peer_qt_QtGraphics.h>
+#include "nativewrapper.h"
+#include "qtimage.h"
+#include "qtstrings.h"
+#include "qtcomponent.h"
+#include "qtgraphics.h"
+#include "qtfont.h"
+
+// Constants from java.awt.AlphaComposite
+#define CLEAR 1
+#define SRC 2
+#define DST 9
+#define SRC_OVER 3
+#define DST_OVER 4
+#define SRC_IN 5
+#define DST_IN 6
+#define SRC_OUT 7
+#define DST_OUT 8
+#define SRC_ATOP 10
+#define DST_ATOP 11
+#define XOR 12
+
+GraphicsPainter *getPainter( JNIEnv *env, jobject obj )
+{
+ jclass cls = env->GetObjectClass( obj );
+ jfieldID field = env->GetFieldID( cls, "nativeObject", "J" );
+ return (GraphicsPainter *)env->GetLongField( obj, field );
+}
+
+static void setNativePtr( JNIEnv *env, jobject obj, void *value )
+{
+ jlong longValue = (jlong) value;
+ jclass cls = env->GetObjectClass( obj );
+ jfieldID field = env->GetFieldID( cls, "nativeObject", "J" );
+ env->SetLongField( obj, field, longValue );
+}
+
+static jobject getToolkit( JNIEnv *env, jobject obj )
+{
+ jclass cls = env->FindClass( "gnu/java/awt/peer/qt/QtGraphics" );
+
+ jfieldID field = env->GetFieldID( cls, "toolkit",
+ "Lgnu/java/awt/peer/qt/QtToolkit;" );
+ return env->GetObjectField( obj, field );
+}
+
+///////////////////////// JNI methods ////////////////////////////////
+
+/**
+ * Clones the parent QPainter object.
+ */
+JNIEXPORT void JNICALL Java_gnu_java_awt_peer_qt_QtGraphics_cloneNativeContext
+(JNIEnv *env, jobject obj, jobject parent)
+{
+ GraphicsPainter *painter = (GraphicsPainter *)getPainter( env, parent );
+ assert( painter );
+ QPainter *newPainter = new GraphicsPainter( painter->device() );
+ assert( newPainter );
+ setNativePtr(env, obj, newPainter);
+}
+
+/*
+ * Start of JNI methods
+ */
+JNIEXPORT void JNICALL Java_gnu_java_awt_peer_qt_QtGraphics_initImage
+(JNIEnv *env, jobject obj, jobject image)
+{
+ QImage *im = getQtImage( env, image );
+ assert( im );
+ QPainter *painter = new GraphicsPainter( im );
+ assert( painter );
+ setNativePtr(env, obj, painter);
+ painter->setRenderHint(QPainter::TextAntialiasing);
+ painter->setRenderHint(QPainter::Antialiasing);
+ painter->setRenderHint(QPainter::SmoothPixmapTransform);
+}
+
+/*
+ * Start of JNI methods
+ */
+JNIEXPORT void JNICALL Java_gnu_java_awt_peer_qt_QtGraphics_initVolatileImage
+(JNIEnv *env, jobject obj, jobject image)
+{
+ QPixmap *im = getQtVolatileImage( env, image );
+ assert( im );
+ QPainter *painter = new GraphicsPainter( im );
+ assert( painter );
+ setNativePtr(env, obj, painter);
+ painter->setRenderHint(QPainter::TextAntialiasing);
+ painter->setRenderHint(QPainter::Antialiasing);
+ painter->setRenderHint(QPainter::SmoothPixmapTransform);
+}
+
+/**
+ * Deletes the QPainter
+ */
+JNIEXPORT void JNICALL Java_gnu_java_awt_peer_qt_QtGraphics_delete
+(JNIEnv *env, jobject obj)
+{
+ GraphicsPainter *painter = (GraphicsPainter *)getPainter( env, obj );
+ setNativePtr( env, obj, NULL );
+ if( painter )
+ {
+ if( painter->isActive() )
+ painter->end();
+ delete painter;
+ }
+}
+
+///////////////////////////////////////////////////////////
+/*
+ * Sets the clip to a path.
+ */
+JNIEXPORT void JNICALL Java_gnu_java_awt_peer_qt_QtGraphics_setClipNative
+(JNIEnv *env, jobject obj, jobject path)
+{
+ QPainter *painter = getPainter( env, obj );
+ assert( painter );
+ QPainterPath *pp = (QPainterPath *)getNativeObject( env, path );
+ assert( pp );
+ painter->setClipPath( *pp );
+}
+
+/*
+ * Sets the clip to a rectangle.
+ */
+JNIEXPORT void JNICALL Java_gnu_java_awt_peer_qt_QtGraphics_setClipRectNative
+(JNIEnv *env, jobject obj, jint x, jint y, jint w, jint h)
+{
+ QPainter *painter = getPainter( env, obj );
+ assert( painter );
+ painter->setClipRect( x, y, w, h );
+}
+
+/*
+ * Intersects a shape with the current clip.
+ */
+JNIEXPORT void JNICALL Java_gnu_java_awt_peer_qt_QtGraphics_intersectClipNative
+(JNIEnv *env, jobject obj, jobject path)
+{
+ QPainter *painter = getPainter( env, obj );
+ assert( painter );
+ QPainterPath *pp = (QPainterPath *)getNativeObject( env, path );
+ assert( pp );
+ painter->setClipPath( *pp, Qt::IntersectClip );
+}
+
+/*
+ * Intersect a rectangle with the current clip.
+ */
+JNIEXPORT void JNICALL Java_gnu_java_awt_peer_qt_QtGraphics_intersectClipRectNative
+(JNIEnv *env, jobject obj, jint x, jint y, jint w, jint h)
+{
+ QPainter *painter = getPainter( env, obj );
+ assert( painter );
+ painter->setClipRect( x, y, w, h, Qt::IntersectClip );
+}
+
+/*
+ * Returns a QPainterPath object with the clip path of this painter.
+ */
+JNIEXPORT jobject JNICALL Java_gnu_java_awt_peer_qt_QtGraphics_getClipNative
+(JNIEnv *env, jobject obj)
+{
+ QPainter *painter = getPainter( env, obj );
+ assert( painter );
+ jclass cls = env->FindClass("gnu/java/awt/peer/qt/QPainterPath");
+ jmethodID method = env->GetMethodID(cls, "<init>", "()V");
+
+ jobject ppo = env->NewObject(cls, method);
+ QPainterPath qpp = painter->clipPath();
+ setNativeObject(env, ppo, &qpp);
+
+ env->DeleteLocalRef( cls );
+ return ppo;
+}
+
+/*
+ * Returns a Rectangle with the bounds of this painters clip path.
+ */
+JNIEXPORT jobject JNICALL Java_gnu_java_awt_peer_qt_QtGraphics_getClipBounds
+(JNIEnv *env, jobject obj)
+{
+ QPainter *painter = getPainter( env, obj );
+ assert( painter );
+ qreal x, y, w, h;
+ painter->clipPath().boundingRect().getRect(&x, &y, &w, &h);
+
+ jclass cls = env->FindClass("java/awt/Rectangle");
+ assert( cls != NULL);
+ jmethodID mid = env->GetMethodID(cls, "<init>", "(IIII)V");
+ assert( mid != NULL);
+ jvalue values[4];
+
+ values[0].i = (jint) x;
+ values[1].i = (jint) y;
+ values[2].i = (jint) w;
+ values[3].i = (jint) h;
+
+ return env->NewObjectA(cls, mid, values);
+}
+
+///////////////////////// Color stuff ////////////////////////
+/**
+ *
+ */
+JNIEXPORT void JNICALL Java_gnu_java_awt_peer_qt_QtGraphics_setColor
+(JNIEnv *env, jobject obj, jint r, jint g, jint b, jint alpha)
+{
+ GraphicsPainter *painter = (GraphicsPainter *)getPainter( env, obj );
+ assert( painter );
+ painter->currentPen->setColor( QColor(r, g, b, alpha) );
+ painter->setPen( *painter->currentPen );
+ painter->currentBrush = new QBrush( QColor(r, g, b, alpha) );
+ painter->setBrush( *painter->currentBrush );
+ painter->currentColor = new QColor(r, g, b, alpha);
+}
+
+JNIEXPORT void JNICALL Java_gnu_java_awt_peer_qt_QtGraphics_setAlphaNative
+ (JNIEnv *env, jobject obj, jdouble alpha)
+{
+ GraphicsPainter *painter = (GraphicsPainter *)getPainter( env, obj );
+ assert( painter );
+
+ QColor c = painter->currentPen->color();
+ c.setAlphaF( (qreal)alpha );
+ painter->currentPen->setColor(c);
+
+ c = painter->currentBrush->color();
+ c.setAlphaF( (qreal)alpha );
+ painter->currentBrush->setColor( c );
+}
+
+/*
+ * Class: gnu_java_awt_peer_qt_QtGraphics
+ * Method: drawNative
+ * Signature: (Lgnu/java/awt/peer/qt/QPainterPath;)V
+ */
+JNIEXPORT void JNICALL Java_gnu_java_awt_peer_qt_QtGraphics_drawNative
+(JNIEnv *env, jobject obj, jobject path)
+{
+ GraphicsPainter *painter = (GraphicsPainter *)getPainter( env, obj );
+ assert( painter );
+ QPainterPath *pp = (QPainterPath *)getNativeObject( env, path );
+ assert( pp );
+ painter->setPen( *painter->currentPen );
+ painter->setBrush( Qt::NoBrush );
+ painter->drawPath( *pp );
+}
+
+/*
+ * Class: gnu_java_awt_peer_qt_QtGraphics
+ * Method: fillNative
+ * Signature: (Lgnu/java/awt/peer/qt/QPainterPath;)V
+ */
+JNIEXPORT void JNICALL Java_gnu_java_awt_peer_qt_QtGraphics_fillNative
+(JNIEnv *env, jobject obj, jobject path)
+{
+ GraphicsPainter *painter = (GraphicsPainter *)getPainter( env, obj );
+ assert( painter );
+ QPainterPath *pp = (QPainterPath *)getNativeObject( env, path );
+ assert( pp );
+
+ painter->setPen(Qt::NoPen);
+ painter->setBrush( *painter->currentBrush );
+ painter->drawPath( *pp );
+}
+
+/**
+ * Draws a string.
+ */
+JNIEXPORT void JNICALL Java_gnu_java_awt_peer_qt_QtGraphics_drawStringNative
+(JNIEnv *env, jobject obj, jstring str, jdouble x, jdouble y)
+{
+ GraphicsPainter *painter = getPainter( env, obj );
+ assert( painter );
+ QString *qStr = getQString(env, str);
+ painter->setBrush( Qt::NoBrush );
+ painter->setPen( *painter->currentPen );
+ painter->drawText(QPointF( (qreal)x, (qreal)y ), *qStr);
+ delete qStr;
+}
+
+/*
+ * Sets the native stroke
+ */
+JNIEXPORT void JNICALL Java_gnu_java_awt_peer_qt_QtGraphics_setNativeStroke
+(JNIEnv *env, jobject obj, jobject stroke)
+{
+ GraphicsPainter *painter = (GraphicsPainter *)getPainter( env, obj );
+ assert( painter );
+ QPen *pen = (QPen *)getNativeObject(env, stroke);
+ assert( pen );
+ painter->currentPen = new QPen( *pen );
+ painter->setPen( *painter->currentPen );
+}
+
+/*
+ * Sets the transform
+ */
+JNIEXPORT void JNICALL Java_gnu_java_awt_peer_qt_QtGraphics_setQtTransform
+(JNIEnv *env, jobject obj, jobject matrix)
+{
+ QPainter *painter = getPainter( env, obj );
+ assert( painter );
+ QMatrix *m = (QMatrix *)getNativeObject( env, matrix );
+ assert( m );
+ painter->setMatrix( *m );
+}
+
+/**
+ * Set the font
+ */
+JNIEXPORT void JNICALL Java_gnu_java_awt_peer_qt_QtGraphics_setFontNative
+(JNIEnv *env, jobject obj, jobject fontpeer)
+{
+ QPainter *painter = getPainter( env, obj );
+ assert( painter );
+ QFont *font = (QFont *) getFont( env, fontpeer );
+ assert( font );
+ painter->setFont( *font );
+}
+
+/*
+ * Sets Porter-Duff compositing.
+ */
+JNIEXPORT void JNICALL Java_gnu_java_awt_peer_qt_QtGraphics_setNativeComposite
+(JNIEnv *env, jobject obj, jint compositeMode)
+{
+ QPainter *painter = getPainter( env, obj );
+ assert( painter );
+ QPainter::CompositionMode mode;
+
+ switch( compositeMode )
+ {
+ case CLEAR:
+ mode = QPainter::CompositionMode_Clear;
+ break;
+ case SRC:
+ mode = QPainter::CompositionMode_Source;
+ break;
+ case DST:
+ mode = QPainter::CompositionMode_Destination;
+ break;
+ case SRC_OVER:
+ mode = QPainter::CompositionMode_SourceOver;
+ break;
+ case DST_OVER:
+ mode = QPainter::CompositionMode_DestinationOver;
+ break;
+ case SRC_IN:
+ mode = QPainter::CompositionMode_SourceIn;
+ break;
+ case DST_IN:
+ mode = QPainter::CompositionMode_DestinationIn;
+ break;
+ case SRC_OUT:
+ mode = QPainter::CompositionMode_SourceOut;
+ break;
+ case DST_OUT:
+ mode = QPainter::CompositionMode_DestinationOut;
+ break;
+ case SRC_ATOP:
+ mode = QPainter::CompositionMode_SourceAtop;
+ break;
+ case DST_ATOP:
+ mode = QPainter::CompositionMode_DestinationAtop;
+ break;
+ case XOR:
+ mode = QPainter::CompositionMode_Xor;
+ break;
+ }
+ painter->setCompositionMode( mode );
+}
+
+/**
+ * Sets the current brush to a linear gradient.
+ */
+JNIEXPORT void JNICALL Java_gnu_java_awt_peer_qt_QtGraphics_setLinearGradient
+(JNIEnv *env, jobject obj, jint r1, jint g1, jint b1, jint r2, jint g2,
+jint b2, jdouble x1, jdouble y1, jdouble x2, jdouble y2, jboolean cyclic)
+{
+ GraphicsPainter *painter = getPainter( env, obj );
+ assert( painter );
+ QLinearGradient *lg = new QLinearGradient(QPointF( (qreal)x1, (qreal)y1 ),
+ QPointF( (qreal)x2, (qreal)y2 ) );
+ lg->setColorAt( (qreal)0.0, QColor(r1, g1, b1) );
+ lg->setColorAt( (qreal)1.0, QColor(r2, g2, b2) );
+ if( cyclic == JNI_TRUE )
+ lg->setSpread( QGradient::ReflectSpread );
+ else
+ lg->setSpread( QGradient::PadSpread );
+ painter->currentBrush = new QBrush( *lg );
+ delete lg;
+}
+
+/*
+ */
+JNIEXPORT void JNICALL Java_gnu_java_awt_peer_qt_QtGraphics_fill3DRect
+(JNIEnv *env, jobject obj, jint x, jint y, jint w, jint h, jboolean raised)
+{
+ GraphicsPainter *painter = getPainter( env, obj );
+ assert( painter );
+ // FIXME: Adjust colors
+ painter->fillRect ( x, y, w, h, QBrush( *painter->currentColor) );
+ QPen *p = new QPen( *painter->currentColor );
+ p->setWidth( 1 );
+ painter->setPen( *p );
+ painter->drawLine( x + w, y, x + w, y + h);
+ painter->drawLine( x, y + h, x + w, y + h);
+}
+
+/*
+ */
+JNIEXPORT void JNICALL Java_gnu_java_awt_peer_qt_QtGraphics_draw3DRect
+(JNIEnv *env, jobject obj, jint x, jint y, jint w, jint h, jboolean raised)
+{
+ GraphicsPainter *painter = getPainter( env, obj );
+ assert( painter );
+ // FIXME: Adjust colors
+ QPen *p = new QPen( *painter->currentColor );
+ p->setWidth( 1 );
+ painter->setPen( *p );
+ painter->drawLine( x, y, x + w, y );
+ painter->drawLine( x, y, x, y + h);
+ painter->drawLine( x + w, y, x + w, y + h);
+ painter->drawLine( x, y + h, x + w, y + h);
+}
--- /dev/null
+#ifndef QTGRAPHICS_H
+#define QTGRAPHICS_H
+
+#include <jni.h>
+#include <QPainter>
+#include <QPaintDevice>
+#include <QPen>
+#include <QBrush>
+
+class GraphicsPainter : public QPainter
+{
+public:
+ QPen *currentPen;
+ QBrush *currentBrush;
+ QColor *currentColor;
+ GraphicsPainter(QPaintDevice *dev) : QPainter( dev )
+ {
+ currentPen = new QPen();
+ currentBrush = new QBrush();
+ currentColor = new QColor();
+ }
+};
+
+GraphicsPainter *getPainter( JNIEnv *env, jobject obj );
+
+#endif
--- /dev/null
+/* qtimage.cpp --
+ 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., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 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 <assert.h>
+#include <QImage>
+#include <QColor>
+#include <QMatrix>
+#include <QPainter>
+#include <gnu_java_awt_peer_qt_QtImage.h>
+#include "qtimage.h"
+#include "qtstrings.h"
+#include "qtgraphics.h"
+#include "nativewrapper.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
+
+QImage *getQtImage( JNIEnv *env, jobject obj )
+{
+ jclass cls = env->GetObjectClass( obj );
+ jfieldID field = env->GetFieldID( cls, "nativeObject", "J" );
+ return (QImage *)env->GetLongField( obj, field );
+}
+
+static void setNativePtr( JNIEnv *env, jobject obj, void *value )
+{
+ jlong longValue = (jlong) value;
+ jclass cls = env->GetObjectClass( obj );
+ jfieldID field = env->GetFieldID( cls, "nativeObject", "J" );
+ env->SetLongField( obj, field, longValue );
+}
+
+/*
+ * Creates a QImage.
+ */
+JNIEXPORT void JNICALL Java_gnu_java_awt_peer_qt_QtImage_createImage
+(JNIEnv *env, jobject obj)
+{
+ int width, height;
+ jclass cls;
+ jfieldID field;
+
+ cls = env->GetObjectClass( obj );
+ field = env->GetFieldID (cls, "width", "I");
+ assert (field != 0);
+ width = env->GetIntField(obj, field);
+
+ field = env->GetFieldID(cls, "height", "I");
+ assert (field != 0);
+ height = env->GetIntField(obj, field);
+
+ QImage *image = new QImage ( width, height,
+ QImage::Format_ARGB32_Premultiplied );
+ setNativePtr(env, obj, image);
+}
+
+/*
+ * Frees the image data.
+ */
+JNIEXPORT void JNICALL Java_gnu_java_awt_peer_qt_QtImage_freeImage
+(JNIEnv *env, jobject obj)
+{
+ QImage *image = getQtImage(env, obj);
+ setNativePtr(env, obj, NULL);
+ if ( image )
+ delete image;
+}
+
+/*
+ * Clears the image to zero.
+ */
+JNIEXPORT void JNICALL Java_gnu_java_awt_peer_qt_QtImage_clear
+(JNIEnv *env, jobject obj)
+{
+ QImage *image = getQtImage(env, obj);
+ assert( image );
+ image->fill(0);
+}
+
+/*
+ * Returns the pixel data in an int array.
+ */
+JNIEXPORT jintArray JNICALL Java_gnu_java_awt_peer_qt_QtImage_getPixels
+(JNIEnv *env, jobject obj)
+{
+ QImage *image = getQtImage(env, obj);
+ jintArray result_array;
+ jint *result_array_ptr, *dst;
+ int x, y;
+ jint pixel;
+ QRgb current;
+
+ assert( image );
+
+ result_array = env->NewIntArray (image->width() * image->height());
+ dst = result_array_ptr =
+ env->GetIntArrayElements(result_array, NULL);
+
+ // A bit inefficient.
+ for ( y = 0; y < image->height(); y++)
+ for ( x = 0; x < image->width(); x++)
+ {
+ current = image->pixel(x, y);
+ pixel = 0;
+ pixel = (qAlpha(current) & 0xFF) << 24 |
+ (qRed(current) & 0xFF) << 16 |
+ (qGreen(current) & 0xFF) << 8 |
+ (qBlue(current) & 0xFF);
+ *dst = pixel;
+ dst++;
+ }
+
+ env->ReleaseIntArrayElements (result_array, result_array_ptr, 0);
+ return result_array;
+}
+
+/*
+ * Sets the pixel data.
+ */
+JNIEXPORT void JNICALL Java_gnu_java_awt_peer_qt_QtImage_setPixels
+(JNIEnv *env, jobject obj, jintArray pixels)
+{
+ QImage *image = getQtImage(env, obj);
+ assert( image );
+
+ int width, height;
+ jint *src_array, *src;
+
+ width = image->width();
+ height = image->height();
+
+ src = src_array =
+ env->GetIntArrayElements(pixels, NULL);
+
+ for(int i = 0 ; i < height; i++)
+ {
+ uchar *scanline = image->scanLine( i );
+ memcpy((void *)scanline, (void *)src, width * 4);
+ src += width;
+ }
+
+ env->ReleaseIntArrayElements(pixels, src_array, 0);
+}
+
+
+/*
+ * Loads an image from a file,
+ * returns true on success, false on failure.
+ */
+JNIEXPORT jboolean JNICALL Java_gnu_java_awt_peer_qt_QtImage_loadImage
+(JNIEnv *env, jobject obj, jstring fn)
+{
+ QString *filename = getQString(env, fn);
+
+ QImage *image = new QImage();
+ bool retVal = image->load( *filename );
+ delete filename;
+
+ if(image->isNull() && !retVal)
+ {
+ setNativePtr(env, obj, NULL);
+ return JNI_FALSE;
+ }
+
+ setNativePtr(env, obj, image);
+
+ jclass cls = env->GetObjectClass( obj );
+ jfieldID field = env->GetFieldID( cls, "width", "I" );
+ env->SetIntField( obj, field, image->width() );
+ field = env->GetFieldID( cls, "height", "I" );
+ env->SetIntField( obj, field, image->height() );
+
+ return JNI_TRUE;
+}
+
+/*
+ * Creates the image from an array of java bytes.
+ */
+JNIEXPORT jboolean JNICALL Java_gnu_java_awt_peer_qt_QtImage_loadImageFromData
+(JNIEnv *env, jobject obj, jbyteArray data)
+{
+ jbyte *src_array, *src;
+ bool retVal;
+
+ src = env->GetByteArrayElements(data, NULL);
+ int len = env->GetArrayLength( data );
+
+ QImage *image = new QImage();
+ retVal = image->loadFromData( (uchar *) src, len);
+ env->ReleaseByteArrayElements(data, src, 0);
+
+ if(image->isNull() || retVal == false)
+ {
+ setNativePtr(env, obj, NULL);
+ return JNI_FALSE;
+ }
+
+ setNativePtr(env, obj, image);
+
+ jclass cls = env->GetObjectClass( obj );
+ jfieldID field = env->GetFieldID( cls, "width", "I" );
+ env->SetIntField( obj, field, image->width() );
+ field = env->GetFieldID( cls, "height", "I" );
+ env->SetIntField( obj, field, image->height() );
+
+ return JNI_TRUE;
+}
+
+
+/*
+ */
+JNIEXPORT void JNICALL Java_gnu_java_awt_peer_qt_QtImage_createScaledImage
+(JNIEnv *env, jobject obj, jobject src, jint hints)
+{
+ int w,h;
+ jclass cls;
+ jfieldID field;
+
+ cls = env->GetObjectClass( obj );
+ field = env->GetFieldID(cls, "width", "I");
+ assert (field != 0);
+ w = env->GetIntField(obj, field);
+
+ field = env->GetFieldID(cls, "height", "I");
+ assert (field != 0);
+ h = env->GetIntField(obj, field);
+
+ QImage *image = getQtImage(env, src);
+ assert( image );
+ QImage imageScaled;
+
+ if (hints == SCALE_SMOOTH || hints == SCALE_AREA_AVERAGING)
+ imageScaled = image->scaled(w, h,
+ Qt::IgnoreAspectRatio,
+ Qt::SmoothTransformation);
+ else
+ imageScaled = image->scaled(w, h,
+ Qt::IgnoreAspectRatio,
+ Qt::FastTransformation);
+ QImage *scaledPtr = new QImage( imageScaled );
+
+ // create new QtImage object
+ setNativePtr( env, obj, scaledPtr );
+}
+
+/*
+ * Simple draw without scaling.
+ */
+JNIEXPORT void JNICALL Java_gnu_java_awt_peer_qt_QtImage_drawPixels
+(JNIEnv *env, jobject obj, jobject graphics, jint bg_red, jint bg_green,
+ jint bg_blue, jint x, jint y, jboolean composite)
+{
+ QImage *image = getQtImage(env, obj);
+ assert( image );
+ QPainter *painter = getPainter( env, graphics );
+ assert( painter );
+ if(composite == JNI_TRUE)
+ painter->fillRect ( x, y, image->width(), image->height(),
+ QColor(bg_red, bg_green, bg_blue ) );
+ painter->drawImage ( QPoint(x, y), *image );
+}
+
+/*
+ * Draw the image with scaling.
+ */
+JNIEXPORT void JNICALL Java_gnu_java_awt_peer_qt_QtImage_drawPixelsScaled
+(JNIEnv *env, jobject obj, jobject graphics,
+ jint bg_red, jint bg_green, jint bg_blue,
+ jint x, jint y, jint w, jint h, jboolean composite)
+{
+ QImage *image = getQtImage(env, obj);
+ assert( image );
+ QPainter *painter = getPainter( env, graphics );
+ assert( painter );
+
+ if(composite == JNI_TRUE)
+ painter->fillRect ( x, y, w, h, QColor(bg_red, bg_green, bg_blue ) );
+
+ QRectF *srcRect = new QRectF((qreal)0, (qreal)0,
+ (qreal)image->width(), (qreal)image->height());
+ QRectF *dstRect = new QRectF((qreal)x, (qreal)y,
+ (qreal)w, (qreal)h);
+
+ if(composite == JNI_TRUE)
+ painter->fillRect( *dstRect, QColor(bg_red, bg_green, bg_blue ) );
+
+ painter->drawImage( *dstRect, *image, *srcRect);
+
+ delete srcRect;
+ delete dstRect;
+}
+
+/*
+ * Draws a transformed image.
+ */
+JNIEXPORT void JNICALL Java_gnu_java_awt_peer_qt_QtImage_drawPixelsTransformed
+(JNIEnv *env, jobject obj, jobject graphics, jobject transform)
+{
+ QImage *originalImage = getQtImage(env, obj);
+ assert( originalImage );
+ QPainter *painter = getPainter( env, graphics );
+ assert( painter );
+ QMatrix *matrix = (QMatrix *)getNativeObject(env, transform);
+ assert( matrix );
+
+ // FIXME : Add rendering hint support here.
+ QPoint p = matrix->map( QPoint(0,0) );
+ QImage image = originalImage->transformed ( *matrix, Qt::FastTransformation );
+ painter->drawImage(p, image);
+}
+
+/**
+ * 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_qt_QtImage_drawPixelsScaledFlipped
+(JNIEnv *env, jobject obj, jobject graphics,
+ 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)
+{
+ QImage *originalImage = getQtImage(env, obj);
+ assert( originalImage );
+ QPainter *painter = getPainter( env, graphics );
+ assert( painter );
+
+ QRectF *srcRect = new QRectF((qreal)srcx, (qreal)srcy,
+ (qreal)srcwidth, (qreal)srcheight);
+ QRectF *dstRect = new QRectF((qreal)dstx, (qreal)dsty,
+ (qreal)dstwidth, (qreal)dstheight);
+
+ QImage image;
+ if( flipx == JNI_TRUE || flipy == JNI_TRUE)
+ image = originalImage->mirrored ( (flipx == JNI_TRUE),
+ (flipy == JNI_TRUE) );
+ else
+ image = *originalImage;
+
+ if(composite == JNI_TRUE)
+ painter->fillRect( *dstRect, QColor(bg_red, bg_green, bg_blue ) );
+
+ painter->drawImage( *dstRect, image, *srcRect);
+
+ delete srcRect;
+ delete dstRect;
+}
+
+/**
+ * Copies an area of the image (used by Graphics)
+ */
+JNIEXPORT void JNICALL Java_gnu_java_awt_peer_qt_QtImage_copyArea
+(JNIEnv *env, jobject obj , jint x, jint y, jint w, jint h, jint dx, jint dy)
+{
+ QImage *image = getQtImage(env, obj);
+ assert( image );
+ QImage area = image->copy(x, y, w, h);
+ QPainter *p = new QPainter( image );
+ p->drawImage( x + dx, y + dy, area );
+ delete p;
+}
--- /dev/null
+#ifndef QTIMAGE_H
+#define QTIMAGE_H
+
+#include <QImage>
+#include <QPixmap>
+
+QImage *getQtImage( JNIEnv *env, jobject obj );
+QPixmap *getQtVolatileImage( JNIEnv *env, jobject obj );
+
+#endif
--- /dev/null
+/* qtlabelpeer.cpp --
+ 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., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 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 <assert.h>
+#include <QLabel>
+#include <QString>
+#include <gnu_java_awt_peer_qt_QtLabelPeer.h>
+#include "qtcomponent.h"
+#include "qtstrings.h"
+#include "mainthreadinterface.h"
+#include "keybindings.h"
+
+// java.awt.Label justification fields
+#define LEFT 0
+#define CENTER 1
+#define RIGHT 2
+
+class MyLabel : public QLabel
+{
+public:
+ MyLabel(JNIEnv *env, jobject obj, QWidget *parent) : QLabel( parent )
+ {
+ setup(env, obj);
+ }
+
+ ~MyLabel()
+ {
+ destroy();
+ }
+
+#define I_KNOW_WHAT_IM_DOING
+#define PARENT QLabel
+#include "eventmethods.h"
+};
+
+class LabelTitle : public AWTEvent {
+
+ private:
+ QLabel *widget;
+ QString *string;
+ Qt::Alignment alignment;
+
+ public:
+ LabelTitle(QLabel *w, QString *s, Qt::Alignment a) : AWTEvent()
+ {
+ widget = w;
+ string = s;
+ alignment = a;
+ }
+
+ void runEvent()
+ {
+ if( string != NULL)
+ {
+ widget->setText( *string );
+ delete string;
+ }
+ else
+ {
+ widget->setAlignment( alignment );
+ }
+ }
+};
+
+/*
+ * Init a QLabel
+ */
+JNIEXPORT void JNICALL Java_gnu_java_awt_peer_qt_QtLabelPeer_init
+(JNIEnv *env, jobject obj)
+{
+ QWidget *parentWidget = (QWidget *) getParentWidget( env, obj );
+ QLabel *label = new MyLabel( env, obj, parentWidget );
+ assert( label );
+ setNativeObject( env, obj, label );
+}
+
+/*
+ * Sets the text
+ */
+JNIEXPORT void JNICALL Java_gnu_java_awt_peer_qt_QtLabelPeer_setText
+(JNIEnv *env, jobject obj, jstring str)
+{
+ QLabel *label = (QLabel *) getNativeObject( env, obj );
+ assert( label );
+
+ QString *qStr = getQString(env, str);
+ mainThread->postEventToMain( new LabelTitle( label, qStr, 0 ) );
+}
+
+/*
+ * Sets the alignment
+ */
+JNIEXPORT void JNICALL Java_gnu_java_awt_peer_qt_QtLabelPeer_setAlignment
+(JNIEnv *env, jobject obj, jint align)
+{
+ Qt::Alignment alignment = Qt::AlignVCenter;
+
+ QLabel *label = (QLabel *) getNativeObject( env, obj );
+ assert( label );
+
+ switch(align)
+ {
+ case LEFT:
+ alignment |= Qt::AlignLeft;
+ break;
+
+ case RIGHT:
+ alignment |= Qt::AlignRight;
+ break;
+
+ default:
+ case CENTER:
+ alignment |= Qt::AlignHCenter;
+ break;
+ }
+ mainThread->postEventToMain( new LabelTitle( label, NULL, alignment ) );
+}
--- /dev/null
+/* qtlistpeer.cpp --
+ 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., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 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 <assert.h>
+#include <QWidget>
+#include <QListWidget>
+#include <gnu_java_awt_peer_qt_QtListPeer.h>
+#include "qtcomponent.h"
+#include "qtstrings.h"
+#include "mainthreadinterface.h"
+#include "slotcallbacks.h"
+
+class ListInsert : public AWTEvent {
+
+ private:
+ QListWidget *widget;
+ QString *string;
+ int index;
+
+ public:
+ ListInsert(QListWidget *w, QString *s, int i) : AWTEvent()
+ {
+ widget = w;
+ string = s;
+ index = i;
+ }
+
+ void runEvent()
+ {
+ widget->insertItem( index, *string );
+ delete string;
+ }
+};
+
+class SelectEvent : public AWTEvent {
+
+ private:
+ QListWidget *widget;
+ int index;
+ bool selected;
+
+ public:
+ SelectEvent(QListWidget *w, int i, bool s) : AWTEvent()
+ {
+ widget = w;
+ index = i;
+ selected = s;
+ }
+
+ void runEvent()
+ {
+ widget->setItemSelected ( widget->item(index), selected );
+ }
+};
+
+class ListDelete : public AWTEvent {
+
+ private:
+ QListWidget *widget;
+ int startIndex, endIndex;
+
+ public:
+ ListDelete(QListWidget *w, int starti, int endi) : AWTEvent()
+ {
+ widget = w;
+ startIndex = starti;
+ endIndex = endi;
+ }
+
+ void runEvent()
+ {
+ for (int i = endIndex; i >= startIndex; i--)
+ delete widget->takeItem(i);
+ }
+};
+
+/*
+ * Construct a QListWidget object
+ */
+JNIEXPORT void JNICALL Java_gnu_java_awt_peer_qt_QtListPeer_init
+(JNIEnv *env, jobject obj)
+{
+ QWidget *parentWidget = (QWidget *)getParentWidget(env, obj);
+ assert( parentWidget );
+ QListWidget *list = new QListWidget( parentWidget );
+ assert( list );
+
+ setNativeObject( env, obj, list );
+ connectList(list, env, obj);
+}
+
+/*
+ * Adds an element.
+ */
+JNIEXPORT void JNICALL Java_gnu_java_awt_peer_qt_QtListPeer_add
+(JNIEnv *env, jobject obj, jstring str, jint index)
+{
+ QListWidget *list = (QListWidget *) getNativeObject( env, obj );
+ assert( list );
+ QString *qStr = getQString(env, str);
+ mainThread->postEventToMain( new ListInsert(list, qStr, index) );
+}
+
+/*
+ * Delete items
+ */
+JNIEXPORT void JNICALL Java_gnu_java_awt_peer_qt_QtListPeer_delItems
+(JNIEnv *env, jobject obj, jint startindex, jint endindex)
+{
+ QListWidget *list = (QListWidget *) getNativeObject( env, obj );
+ assert( list );
+ mainThread->postEventToMain( new ListDelete(list, startindex, endindex) );
+}
+
+/*
+ * (De)select an element.
+ */
+JNIEXPORT void JNICALL Java_gnu_java_awt_peer_qt_QtListPeer_select
+(JNIEnv *env, jobject obj, jint index, jboolean sel)
+{
+ QListWidget *list = (QListWidget *) getNativeObject( env, obj );
+ assert( list );
+
+ mainThread->postEventToMain( new SelectEvent(list, index,
+ (sel == JNI_TRUE)) );
+}
+
+/**
+ * Returns the indices of the selected items.
+ */
+JNIEXPORT jintArray JNICALL Java_gnu_java_awt_peer_qt_QtListPeer_getSelectedIndexes
+ (JNIEnv *env, jobject obj)
+{
+ jintArray retArray;
+ jint *arr;
+
+ QListWidget *list = (QListWidget *) getNativeObject( env, obj );
+ assert( list );
+
+ QList<QListWidgetItem *> items = list->selectedItems();
+ retArray = env->NewIntArray( items.count() );
+ arr = env->GetIntArrayElements( retArray, NULL );
+
+ for(int i = 0; i < items.count(); i++)
+ arr[i] = list->row(items.at(i));
+
+ env->ReleaseIntArrayElements( retArray, arr, 0 );
+ return retArray;
+}
+
+/*
+ * Sets the current item and makes it visible.
+ */
+JNIEXPORT void JNICALL Java_gnu_java_awt_peer_qt_QtListPeer_makeVisible
+ (JNIEnv *env, jobject obj, jint index)
+{
+
+ QListWidget *list = (QListWidget *) getNativeObject( env, obj );
+ assert( list );
+
+ list->scrollToItem( list->item(index) );
+}
+
+/*
+ * Set multiple selection mode.
+ */
+JNIEXPORT void JNICALL Java_gnu_java_awt_peer_qt_QtListPeer_setMultipleMode
+(JNIEnv *env, jobject obj, jboolean allow)
+{
+ QListWidget *list = (QListWidget *) getNativeObject( env, obj );
+ assert( list );
+
+ // FIXME: Multiple selection is buggy in Qt4. Workaround needed.
+ list->setSelectionMode( ((allow == JNI_TRUE) ? QAbstractItemView::MultiSelection : QAbstractItemView::SingleSelection) );
+}
+
--- /dev/null
+/* qtmenubarpeer.cpp --
+ 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., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 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 <assert.h>
+#include <QMenuBar>
+#include <QToolBar>
+#include <QMenu>
+#include <QList>
+#include <QThread>
+#include <gnu_java_awt_peer_qt_QtMenuBarPeer.h>
+#include "nativewrapper.h"
+#include "qtstrings.h"
+#include "mainthreadinterface.h"
+
+/*
+ * Event wrapper to add a menu to a menu bar
+ */
+class MenuBarAdd : public AWTEvent {
+
+ private:
+ QMenuBar *widget;
+ QMenu *menu;
+ bool isHelp;
+
+ public:
+ MenuBarAdd(QMenuBar *w, QMenu *m, bool help) : AWTEvent()
+ {
+ widget = w;
+ menu = m;
+ isHelp = help;
+ }
+
+ void runEvent()
+ {
+ if ( isHelp )
+ widget->addSeparator();
+ QAction *ptr = widget->addMenu( menu );
+ }
+};
+
+/**
+ * Event wrapper to remove a menu from a menu bar.
+ */
+class MenuBarRemove : public AWTEvent {
+
+ private:
+ QMenuBar *widget;
+ QMenu *menu;
+
+ public:
+ MenuBarRemove(QMenuBar *w, QMenu *m) : AWTEvent()
+ {
+ widget = w;
+ menu = m;
+ }
+
+ void runEvent()
+ {
+ // FIXME
+ }
+};
+
+
+/*
+ * Constructs a QMenuBar object.
+ */
+JNIEXPORT void JNICALL Java_gnu_java_awt_peer_qt_QtMenuBarPeer_init
+ (JNIEnv *env, jobject obj)
+{
+ QMenuBar *menubar = new QMenuBar();
+ assert( menubar );
+ setNativeObject( env, obj, menubar );
+}
+
+/*
+ * Adds a menu item.
+ */
+JNIEXPORT void JNICALL Java_gnu_java_awt_peer_qt_QtMenuBarPeer_addMenu
+(JNIEnv *env, jobject obj, jobject menuPeer)
+{
+ QMenuBar *menubar = (QMenuBar *)getNativeObject(env, obj);
+ assert( menubar );
+ QMenu *menu = (QMenu *)getNativeObject(env, menuPeer);
+ assert( menu );
+ mainThread->postEventToMain( new MenuBarAdd( menubar, menu, false ) );
+}
+
+/*
+ * Add a help menu.
+ */
+JNIEXPORT void JNICALL Java_gnu_java_awt_peer_qt_QtMenuBarPeer_addHelpMenu
+(JNIEnv *env, jobject obj, jobject menuPeer)
+{
+ QMenuBar *menubar = (QMenuBar *)getNativeObject(env, obj);
+ assert( menubar );
+ QMenu *menu = (QMenu *)getNativeObject(env, menuPeer);
+ assert( menu );
+
+ mainThread->postEventToMain( new MenuBarAdd( menubar, menu, true ) );
+}
+
+/*
+ * Delete a menu.
+ */
+JNIEXPORT void JNICALL Java_gnu_java_awt_peer_qt_QtMenuBarPeer_delMenu
+(JNIEnv *env, jobject obj, jobject menuPeer)
+{
+ QMenuBar *menubar = (QMenuBar *)getNativeObject(env, obj);
+ assert( menubar );
+ QMenu *menu = (QMenu *)getNativeObject(env, menuPeer);
+ assert( menu );
+
+ // FIXME
+
+}
+
--- /dev/null
+/* qtmenucomponentpeer.cpp --
+ 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., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 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 <assert.h>
+#include <QWidget>
+#include <gnu_java_awt_peer_qt_QtMenuComponentPeer.h>
+#include "nativewrapper.h"
+#include "componentevent.h"
+
+
+/**
+ * Calls back init() from the main thread.
+ */
+JNIEXPORT void JNICALL Java_gnu_java_awt_peer_qt_QtMenuComponentPeer_callInit
+(JNIEnv *env, jobject obj)
+{
+ mainThread->postEventToMain( new AWTInitEvent( env, obj ) );
+ // wait for the thing to be created.
+}
+
+/*
+ * Generic disposal.
+ */
+JNIEXPORT void JNICALL Java_gnu_java_awt_peer_qt_QtMenuComponentPeer_dispose
+(JNIEnv *env, jobject obj)
+{
+ QWidget *widget = (QWidget *) getNativeObject( env, obj );
+ assert( widget );
+
+ setNativeObject(env, obj, NULL);
+ mainThread->postEventToMain( new AWTDestroyEvent( widget ) );
+}
--- /dev/null
+/* qtmenuitempeer.cpp --
+ 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., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 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 <assert.h>
+#include <QMenu>
+#include <QAction>
+#include <QThread>
+#include <gnu_java_awt_peer_qt_QtMenuItemPeer.h>
+#include "nativewrapper.h"
+#include "qtstrings.h"
+#include "mainthreadinterface.h"
+
+class MenuItemDestroyEvent : public AWTEvent {
+
+ private:
+ QAction *widget;
+
+ public:
+ MenuItemDestroyEvent(QAction *w)
+ {
+ widget = w;
+ }
+
+ void runEvent()
+ {
+ delete widget;
+ }
+};
+
+class MenuItemLabelEvent : public AWTEvent {
+
+ private:
+ QAction *widget;
+ QString *string;
+
+ public:
+ MenuItemLabelEvent(QAction *w, QString *s) : AWTEvent()
+ {
+ widget = w;
+ string = s;
+ }
+
+ void runEvent()
+ {
+ widget->setText( *string );
+ delete string;
+ }
+};
+
+class MenuItemStatusEvent : public AWTEvent {
+
+ private:
+ QAction *widget;
+ bool enabled;
+ bool value;
+
+ public:
+ MenuItemStatusEvent(QAction *w, bool e, bool v) : AWTEvent()
+ {
+ widget = w;
+ enabled = e;
+ value = v;
+ }
+
+ void runEvent()
+ {
+ if( enabled )
+ widget->setEnabled( value );
+ else
+ widget->setChecked( value );
+ }
+};
+
+/*
+ * Creates a QAction object
+ */
+JNIEXPORT void JNICALL Java_gnu_java_awt_peer_qt_QtMenuItemPeer_create
+(JNIEnv *env, jobject obj, jstring label, jboolean isSeperator, jboolean isCheckable)
+{
+ QAction *action;
+ if(label == NULL || isSeperator == JNI_TRUE)
+ {
+ action = new QAction(NULL);
+ action->setSeparator(true);
+ assert( action );
+ }
+ else
+ {
+ QString *qStr = getQString(env, label);
+ action = new QAction(*qStr, NULL);
+ delete qStr;
+ assert( action );
+ action->setCheckable( (isCheckable == JNI_TRUE) );
+ }
+
+ setNativeObject( env, obj, action );
+}
+
+/**
+ * Disposal.
+ */
+JNIEXPORT void JNICALL Java_gnu_java_awt_peer_qt_QtMenuItemPeer_dispose
+(JNIEnv *env, jobject obj)
+{
+ QAction *action = (QAction *)getNativeObject( env, obj );
+ assert( action );
+ mainThread->postEventToMain( new MenuItemDestroyEvent( action ) );
+}
+
+/*
+ * Enables/disables the item
+ */
+JNIEXPORT void JNICALL Java_gnu_java_awt_peer_qt_QtMenuItemPeer_setEnabled
+(JNIEnv *env, jobject obj, jboolean enabled)
+{
+ QAction *action = (QAction *)getNativeObject( env, obj );
+ assert( action );
+ mainThread->postEventToMain(new MenuItemStatusEvent(action, true,
+ (enabled == JNI_TRUE)));
+}
+
+/*
+ * Sets the item label.
+ */
+JNIEXPORT void JNICALL Java_gnu_java_awt_peer_qt_QtMenuItemPeer_setLabel
+(JNIEnv *env, jobject obj, jstring label)
+{
+ QAction *action = (QAction *)getNativeObject( env, obj );
+ assert( action );
+
+ QString *qStr = getQString(env, label);
+ mainThread->postEventToMain( new MenuItemLabelEvent( action, qStr ) );
+}
+
+/*
+ * Sets the checkbox state.
+ */
+JNIEXPORT void JNICALL Java_gnu_java_awt_peer_qt_QtMenuItemPeer_setState
+(JNIEnv *env, jobject obj, jboolean state)
+{
+ QAction *action = (QAction *)getNativeObject( env, obj );
+ assert( action );
+ mainThread->postEventToMain(new MenuItemStatusEvent(action, false,
+ (state == JNI_TRUE)));
+}
+
+
+
--- /dev/null
+/* qtmenupeer.cpp --
+ 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., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 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 <assert.h>
+#include <QMenu>
+#include <gnu_java_awt_peer_qt_QtMenuPeer.h>
+#include "nativewrapper.h"
+#include "qtstrings.h"
+#include "mainthreadinterface.h"
+#include "slotcallbacks.h"
+#include "componentevent.h"
+
+#define ADDMENU 0
+#define ADDITEM 1
+#define ADDSEPA 2
+
+// Sets the title, but also tear-off.
+class MenuTitleEvent : public AWTEvent {
+
+ private:
+ QMenu *widget;
+ QString *string;
+ bool tearOff;
+
+ public:
+ MenuTitleEvent(QMenu *w, QString *s, bool tear) : AWTEvent()
+ {
+ widget = w;
+ string = s;
+ tearOff = tear;
+ }
+
+ void runEvent()
+ {
+ if (tearOff)
+ widget->setTearOffEnabled( true );
+ else
+ {
+ widget->setTitle( *string );
+ delete string;
+ }
+ }
+};
+
+class MenuAction : public AWTEvent {
+
+ private:
+ QMenu *menu;
+ QAction *action;
+ int isMenu; // 0 to add a menu, 1 to add an item, 2 to add a seperator
+ JavaVM *vm;
+ jobject menuPeer;
+ jobject itemPeer;
+
+public:
+ MenuAction(JNIEnv *env, jobject mp, jobject ip, QMenu *m, QAction *a,
+ bool ismenu) : AWTEvent()
+ {
+ menu = m;
+ action = a;
+ isMenu = ismenu;
+ env->GetJavaVM( &vm );
+ menuPeer = env->NewGlobalRef( mp );
+ if( ip != NULL )
+ itemPeer = env->NewGlobalRef( ip );
+ else
+ itemPeer = NULL;
+ }
+
+ void runEvent()
+ {
+ JNIEnv *env;
+ QAction *newAction; // adding an action creates a new duplicate.
+ vm->GetEnv((void **)&env, JNI_VERSION_1_1);
+
+ switch(isMenu)
+ {
+ case ADDMENU:
+ newAction = menu->addMenu( (QMenu *)action );
+ break;
+ case ADDITEM:
+ newAction = menu->addAction(action->text());
+ newAction->setSeparator(action->isSeparator());
+ newAction->setCheckable(action->isCheckable());
+ // delete action;
+ break;
+ case ADDSEPA:
+ newAction = menu->addSeparator();
+ break;
+ }
+
+ jclass menuCls = env->GetObjectClass( menuPeer );
+ jmethodID mid = env->GetMethodID(menuCls, "add", "(J)V");
+ env->CallVoidMethod( menuPeer, mid, (jlong)newAction );
+
+ env->DeleteGlobalRef( menuPeer );
+ if( itemPeer != NULL )
+ {
+ setNativeObject( env, itemPeer, newAction );
+ connectAction(newAction, env, itemPeer);
+ env->DeleteGlobalRef( itemPeer );
+ }
+ }
+};
+
+class MenuRemoveAction : public AWTEvent {
+
+ private:
+ QMenu *menu;
+ QAction *action;
+
+public:
+ MenuRemoveAction(QMenu *m, QAction *a) : AWTEvent()
+ {
+ menu = m;
+ action = a;
+ }
+
+ void runEvent()
+ {
+ if (action)
+ menu->removeAction(action);
+ }
+};
+
+/*
+ * Constructs a QMenu item
+ */
+JNIEXPORT void JNICALL Java_gnu_java_awt_peer_qt_QtMenuPeer_init
+(JNIEnv *env, jobject obj)
+{
+ QMenu *menu = new QMenu();
+ assert( menu );
+
+ setNativeObject( env, obj, menu );
+}
+
+/**
+ * Allows tear-off: Only called once, if ever.
+ */
+JNIEXPORT void JNICALL Java_gnu_java_awt_peer_qt_QtMenuPeer_allowTearOff
+(JNIEnv *env, jobject obj)
+{
+ QMenu *menu = (QMenu *)getNativeObject( env, obj );
+ assert( menu );
+ mainThread->postEventToMain( new MenuTitleEvent( menu, NULL, true ) );
+}
+
+/*
+ * Inserts a seperator.
+ */
+JNIEXPORT void JNICALL Java_gnu_java_awt_peer_qt_QtMenuPeer_insertSeperator
+(JNIEnv *env, jobject obj)
+{
+ QMenu *menu = (QMenu *)getNativeObject( env, obj );
+ assert( menu );
+ mainThread->postEventToMain( new MenuAction( env, obj, NULL,
+ menu, NULL, ADDSEPA ) );
+}
+
+/*
+ * Inserts an item.
+ */
+JNIEXPORT void JNICALL Java_gnu_java_awt_peer_qt_QtMenuPeer_insertItem
+(JNIEnv *env, jobject obj, jobject item)
+{
+ QMenu *menu = (QMenu *)getNativeObject( env, obj );
+ assert( menu );
+
+ QAction *action = (QAction *)getNativeObject( env, item );
+ assert( action );
+
+ mainThread->postEventToMain( new MenuAction( env, obj, item, menu, action, ADDITEM ));
+}
+
+/*
+ * Inserts a sub-menu
+ */
+JNIEXPORT void JNICALL Java_gnu_java_awt_peer_qt_QtMenuPeer_insertMenu
+(JNIEnv *env, jobject obj, jobject menu)
+{
+ assert( menu );
+ QMenu *thisMenu = (QMenu *)getNativeObject( env, obj );
+ assert( thisMenu );
+ QMenu *insMenu = (QMenu *)getNativeObject(env, menu);
+ assert( insMenu );
+
+ mainThread->postEventToMain( new MenuAction( env, obj, menu, thisMenu, (QAction *)insMenu, ADDMENU ) );
+}
+
+/*
+ * Removes an item at index.
+ */
+JNIEXPORT void JNICALL Java_gnu_java_awt_peer_qt_QtMenuPeer_delItem
+(JNIEnv *env, jobject obj, jlong ptr)
+{
+ QMenu *menu = (QMenu *)getNativeObject( env, obj );
+ assert( menu );
+ QAction *action = (QAction *)ptr;
+
+ mainThread->postEventToMain( new MenuRemoveAction( menu, action ) );
+}
+
+/*
+ * Enables/Disables the menu.
+ */
+JNIEXPORT void JNICALL Java_gnu_java_awt_peer_qt_QtMenuPeer_setEnabled
+(JNIEnv *env, jobject obj, jboolean enabled)
+{
+ QMenu *menu = (QMenu *)getNativeObject( env, obj );
+ assert( menu );
+
+ mainThread->postEventToMain(new AWTEnableEvent(menu, (enabled == JNI_TRUE)));
+}
+
+/*
+ * Sets the menu title.
+ */
+JNIEXPORT void JNICALL Java_gnu_java_awt_peer_qt_QtMenuPeer_setLabel
+(JNIEnv *env, jobject obj, jstring label)
+{
+ if(label == NULL)
+ return;
+
+ QMenu *menu = (QMenu *)getNativeObject( env, obj );
+ assert( menu );
+ QString *qStr = getQString(env, label);
+ mainThread->postEventToMain( new MenuTitleEvent( menu, qStr, false ) );
+}
+
--- /dev/null
+/* qtpanelpeer.cpp --
+ 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., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 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 <assert.h>
+#include <qwidget.h>
+#include <gnu_java_awt_peer_qt_QtPanelPeer.h>
+#include "qtcomponent.h"
+#include "keybindings.h"
+
+class MyPanel : public QWidget
+{
+public:
+ MyPanel(JNIEnv *env, jobject obj, QWidget *parent) : QWidget( parent )
+ {
+ setup(env, obj);
+ }
+
+ ~MyPanel()
+ {
+ destroy();
+ }
+
+#define I_KNOW_WHAT_IM_DOING
+#define PARENT QWidget
+#include "eventmethods.h"
+#undef I_KNOW_WHAT_IM_DOING
+#undef PARENT
+};
+
+/**
+ * Init
+ */
+JNIEXPORT void JNICALL Java_gnu_java_awt_peer_qt_QtPanelPeer_init
+(JNIEnv *env, jobject obj)
+{
+ QWidget *parentWidget = (QWidget *) getParentWidget( env, obj );
+ QWidget *canvas = new MyPanel( env, obj, parentWidget );
+ assert( canvas );
+
+ setNativeObject( env, obj, canvas );
+}
+
+
--- /dev/null
+/* qtpopupmenupeer.cpp --
+ 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., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 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 <assert.h>
+#include <QMenu>
+#include <QPoint>
+#include <QWidget>
+#include <gnu_java_awt_peer_qt_QtPopupMenuPeer.h>
+#include "nativewrapper.h"
+#include "qtstrings.h"
+#include "mainthreadinterface.h"
+
+class PopupMenuShowEvent : public AWTEvent {
+
+ private:
+ QMenu *menu;
+ int x, y;
+
+ public:
+ PopupMenuShowEvent(QMenu *m, int x0, int y0) : AWTEvent()
+ {
+ menu = m;
+ x = x0;
+ y = y0;
+ }
+
+ void runEvent()
+ {
+ menu->exec( QPoint( x, y ) );
+ }
+};
+
+/*
+ * Shows the menu.
+ */
+JNIEXPORT void JNICALL Java_gnu_java_awt_peer_qt_QtPopupMenuPeer_showNative
+(JNIEnv *env, jobject obj, jint x, jint y)
+{
+ QMenu *menu = (QMenu *)getNativeObject( env, obj );
+ assert( menu );
+ mainThread->postEventToMain( new PopupMenuShowEvent(menu, x, y ) );
+}
--- /dev/null
+/* qtscreendevice.cpp --
+ 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., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 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 <assert.h>
+#include <QApplication>
+#include <QDesktopWidget>
+#include <gnu_java_awt_peer_qt_QtScreenDevice.h>
+#include "nativewrapper.h"
+
+extern QApplication *qApplication;
+
+/*
+ */
+JNIEXPORT void JNICALL Java_gnu_java_awt_peer_qt_QtScreenDevice_init
+(JNIEnv *env, jobject obj, jint id)
+{
+ QWidget *widget = qApplication->desktop()->screen( id );
+ assert( widget );
+ setNativeObject(env, obj, widget);
+}
+
+/*
+ */
+JNIEXPORT void JNICALL Java_gnu_java_awt_peer_qt_QtScreenDevice_dispose
+(JNIEnv *env, jobject obj)
+{
+ QWidget *widget = (QWidget *)getNativeObject(env, obj);
+ setNativeObject(env, obj, NULL);
+ if( widget )
+ delete widget;
+}
+
+/*
+ * Returns the bounds
+ */
+JNIEXPORT jobject JNICALL Java_gnu_java_awt_peer_qt_QtScreenDevice_getBounds
+(JNIEnv *env, jobject obj)
+{
+ QWidget *widget = (QWidget *)getNativeObject(env, obj);
+ assert( widget );
+
+ jclass cls = env->FindClass("java/awt/Rectangle");
+ jmethodID mid = env->GetMethodID(cls, "<init>", "(IIII)V");
+ jvalue values[4];
+
+ int x,y,w,h;
+ widget->geometry().getRect( &x, &y, &w, &h );
+
+ values[0].i = (jint) x;
+ values[1].i = (jint) y;
+ values[2].i = (jint) w;
+ values[3].i = (jint) h;
+
+ return env->NewObjectA(cls, mid, values);
+}
+
+/*
+ * Returns the X DPI
+ */
+JNIEXPORT jint JNICALL Java_gnu_java_awt_peer_qt_QtScreenDevice_getDpiX
+(JNIEnv *env, jobject obj)
+{
+ QWidget *widget = (QWidget *)getNativeObject(env, obj);
+ assert( widget );
+ return widget->logicalDpiX();
+}
+
+/*
+ * Returns the Y DPI
+ */
+JNIEXPORT jint JNICALL Java_gnu_java_awt_peer_qt_QtScreenDevice_getDpiY
+(JNIEnv *env, jobject obj)
+{
+ QWidget *widget = (QWidget *)getNativeObject(env, obj);
+ assert( widget );
+ return widget->logicalDpiY();
+}
+
+/*
+ * Returns the bitplane depth
+ */
+JNIEXPORT jint JNICALL Java_gnu_java_awt_peer_qt_QtScreenDevice_depth
+(JNIEnv *env, jobject obj)
+{
+ QWidget *widget = (QWidget *)getNativeObject(env, obj);
+ assert( widget );
+ return widget->depth();
+}
+
--- /dev/null
+/* qtscrollbarpeer.cpp --
+ 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., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 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 <assert.h>
+#include <QScrollBar>
+#include <gnu_java_awt_peer_qt_QtScrollbarPeer.h>
+#include "keybindings.h"
+#include "slotcallbacks.h"
+#include "qtcomponent.h"
+
+// Constant fields from java.awt.Scrollbar
+#define HORIZONTAL 0
+#define VERTICAL 1
+
+class MyScrollBar : public QScrollBar
+{
+public:
+ MyScrollBar(JNIEnv *env, jobject obj, QWidget *parent) : QScrollBar( parent )
+ {
+ setup(env, obj);
+ }
+
+ ~MyScrollBar()
+ {
+ destroy();
+ }
+
+#define I_KNOW_WHAT_IM_DOING
+#define PARENT QScrollBar
+#include "eventmethods.h"
+};
+
+/*
+ * Construct a QScrollbar object
+ */
+JNIEXPORT void JNICALL Java_gnu_java_awt_peer_qt_QtScrollbarPeer_init
+(JNIEnv *env, jobject obj)
+{
+ QWidget *parentWidget = (QWidget *)getParentWidget( env, obj );
+ assert( parentWidget );
+ // QScrollBar *scrollbar = new QScrollBar( parentWidget );
+ MyScrollBar *scrollbar = new MyScrollBar( env, obj, parentWidget );
+ assert( scrollbar );
+
+ setNativeObject( env, obj, scrollbar );
+ connectScrollBar(scrollbar, env, obj);
+}
+
+/*
+ * Set the line increment.
+ */
+JNIEXPORT void JNICALL Java_gnu_java_awt_peer_qt_QtScrollbarPeer_setLineIncrement
+(JNIEnv *env, jobject obj, jint inc)
+{
+ QScrollBar *bar = (QScrollBar *) getNativeObject( env, obj );
+ assert( bar );
+
+ bar->setSingleStep(inc);
+}
+
+/**
+ * Sets the orientation of the scrollbar
+ */
+JNIEXPORT void JNICALL Java_gnu_java_awt_peer_qt_QtScrollbarPeer_setOrientation
+(JNIEnv *env, jobject obj, jint orientation)
+{
+ QScrollBar *bar = (QScrollBar *) getNativeObject( env, obj );
+ assert( bar );
+
+ switch(orientation)
+ {
+ case HORIZONTAL:
+ bar->setOrientation ( Qt::Horizontal );
+ break;
+
+ default:
+ case VERTICAL:
+ bar->setOrientation ( Qt::Vertical );
+ break;
+ }
+}
+
+/**
+ * Sets the page increment (equivalent to slider size)
+ */
+JNIEXPORT void JNICALL Java_gnu_java_awt_peer_qt_QtScrollbarPeer_setPageIncrement
+(JNIEnv *env, jobject obj, jint inc)
+{
+ QScrollBar *bar = (QScrollBar *) getNativeObject( env, obj );
+ assert( bar );
+
+ bar->setPageStep( inc );
+}
+
+/*
+ * Setvalues.
+ */
+JNIEXPORT void JNICALL Java_gnu_java_awt_peer_qt_QtScrollbarPeer_setValues
+(JNIEnv *env, jobject obj, jint value, jint visible, jint min, jint max)
+{
+ QScrollBar *bar = (QScrollBar *) getNativeObject( env, obj );
+ assert( bar );
+
+ bar->setValue(value);
+ bar->setPageStep( visible ); // page step and slider size are the same in Qt
+ bar->setRange( min , max );
+}
+
--- /dev/null
+/* qtscrollpanepeer.cpp --
+ 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., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 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 <assert.h>
+#include <QScrollArea>
+#include <QScrollBar>
+#include <gnu_java_awt_peer_qt_QtScrollPanePeer.h>
+#include "qtcomponent.h"
+#include "containers.h"
+#include "mainthreadinterface.h"
+#include "componentevent.h"
+#include "keybindings.h"
+
+// Constants in java.awt.ScrollPane
+#define SCROLLBARS_AS_NEEDED 0
+#define SCROLLBARS_ALWAYS 1
+#define SCROLLBARS_NEVER 2
+
+
+class MyScrollArea : public QScrollArea
+{
+public:
+ MyScrollArea(JNIEnv *env, jobject obj, QWidget *parent) : QScrollArea( parent )
+ {
+ setup(env, obj);
+ }
+
+ ~MyScrollArea()
+ {
+ destroy();
+ }
+
+#define I_KNOW_WHAT_IM_DOING
+#define PARENT QScrollArea
+#include "eventmethods.h"
+};
+
+
+class ScrollPanePolicy : public AWTEvent {
+
+ private:
+ QScrollArea *widget;
+ Qt::ScrollBarPolicy policy;
+
+ public:
+ ScrollPanePolicy(QScrollArea *w, Qt::ScrollBarPolicy p) : AWTEvent()
+ {
+ widget = w;
+ policy = p;
+ }
+
+ void runEvent()
+ {
+ widget->setHorizontalScrollBarPolicy(policy);
+ widget->setVerticalScrollBarPolicy(policy);
+ }
+};
+
+/**
+ * Returns the child widget, given the owner Component.
+ */
+QWidget *scrollPaneChildWidget( JNIEnv *env, jobject component )
+{
+ jclass scrollpaneCls = env->FindClass( "java/awt/ScrollPane" );
+ jmethodID getPeerMID = env->GetMethodID( scrollpaneCls,
+ "getPeer",
+ "()Ljava/awt/peer/ComponentPeer;");
+ assert(getPeerMID != 0);
+ jobject scrollpanepeerobj = env->CallObjectMethod( component, getPeerMID, NULL );
+ QScrollArea *view = (QScrollArea *) getNativeObject( env, scrollpanepeerobj );
+ assert(view != 0);
+ return view->viewport();
+}
+
+/*
+ * Creates a QScrollArea object.
+ */
+JNIEXPORT void JNICALL Java_gnu_java_awt_peer_qt_QtScrollPanePeer_init
+(JNIEnv *env, jobject obj)
+{
+ QWidget *parentWidget = (QWidget *) getParentWidget( env, obj );
+ assert( parentWidget );
+ // QScrollArea *pane = new MyScrollArea( env, obj, parentWidget );
+ QScrollArea *pane = new QScrollArea( parentWidget );
+ assert( pane );
+ setNativeObject( env, obj, pane );
+}
+
+/*
+ * Resize the child.
+ */
+JNIEXPORT void JNICALL Java_gnu_java_awt_peer_qt_QtScrollPanePeer_childResized
+(JNIEnv *env, jobject obj, jint w, jint h)
+{
+ QScrollArea *view = (QScrollArea *) getNativeObject( env, obj );
+ assert( view );
+
+ QWidget *child = view->viewport();
+ assert( child );
+ // child->setGeometry( 0, 0, w, h );
+// child->update();
+ mainThread->postEventToMain( new AWTResizeEvent(child, 0, 0, w, h) );
+}
+
+/*
+ * Returns the horizontal scrollbar height.
+ */
+JNIEXPORT jint JNICALL Java_gnu_java_awt_peer_qt_QtScrollPanePeer_getHScrollbarHeight
+(JNIEnv *env, jobject obj)
+{
+ QScrollArea *pane = (QScrollArea *) getNativeObject( env, obj );
+ assert( pane );
+ QScrollBar *hbar = pane->horizontalScrollBar();
+ if(hbar == NULL)
+ return 0;
+ if(!hbar->isVisible())
+ return 0;
+ int height = hbar->height();
+
+ return height;
+}
+
+/*
+ * Returns the vertical scrollbar width.
+ */
+JNIEXPORT jint JNICALL Java_gnu_java_awt_peer_qt_QtScrollPanePeer_getVScrollbarWidth
+(JNIEnv *env, jobject obj)
+{
+ QScrollArea *pane = (QScrollArea *) getNativeObject( env, obj );
+ assert( pane );
+ QScrollBar *vbar = pane->verticalScrollBar();
+ if(vbar == NULL)
+ return 0;
+ if(!vbar->isVisible())
+ return 0;
+ int width = vbar->width();
+
+ return width;
+}
+
+/*
+ * Sets the current upper-left corner to x, y.
+ */
+JNIEXPORT void JNICALL Java_gnu_java_awt_peer_qt_QtScrollPanePeer_setScrollPosition
+(JNIEnv *env, jobject obj, jint x, jint y)
+{
+ QScrollArea *pane = (QScrollArea *) getNativeObject( env, obj );
+ assert( pane );
+ // pane->scrollContentsBy( x, y );
+}
+
+/*
+ * Sets the scrollbar policy
+ */
+JNIEXPORT void JNICALL Java_gnu_java_awt_peer_qt_QtScrollPanePeer_setPolicy
+(JNIEnv *env, jobject obj, jint policy)
+{
+ QScrollArea *pane = (QScrollArea *) getNativeObject( env, obj );
+ assert( pane );
+
+ Qt::ScrollBarPolicy qtpolicy;
+ switch( policy )
+ {
+ case SCROLLBARS_ALWAYS:
+ qtpolicy = Qt::ScrollBarAlwaysOn;
+ break;
+
+ case SCROLLBARS_NEVER:
+ qtpolicy = Qt::ScrollBarAlwaysOff;
+ break;
+
+ default:
+ case SCROLLBARS_AS_NEEDED:
+ qtpolicy = Qt::ScrollBarAsNeeded;
+ break;
+ }
+
+ mainThread->postEventToMain( new ScrollPanePolicy( pane, qtpolicy ) );
+}
+
--- /dev/null
+/* qtstrings.cpp --
+ 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., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 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 "qtstrings.h"
+
+QString *getQString(JNIEnv *env, jstring str)
+{
+ QString qStr;
+ {
+ const char *chars = env->GetStringUTFChars( str, NULL );
+ qStr = QString::fromUtf8( chars, env->GetStringLength( str ) );
+ env->ReleaseStringUTFChars( str, chars );
+ }
+ return new QString(qStr);
+}
+
+jstring getJavaString(JNIEnv *env, QString *qstring)
+{
+ return env->NewStringUTF(qstring->toUtf8());
+}
--- /dev/null
+#ifndef QTSTRINGS_H
+#define QTSTRINGS_H
+
+#include <jni.h>
+#include <QString>
+
+QString *getQString(JNIEnv *env, jstring str);
+jstring getJavaString(JNIEnv *env, QString *qstring);
+
+#endif
--- /dev/null
+/* qttextareapeer.cpp --
+ 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., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 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 <assert.h>
+#include <time.h>
+#include <QTextEdit>
+#include <QTextCursor>
+#include <gnu_java_awt_peer_qt_QtTextAreaPeer.h>
+#include "mainthreadinterface.h"
+#include "componentevent.h"
+#include "slotcallbacks.h"
+#include "qtcomponent.h"
+#include "qtstrings.h"
+
+class TASetText : public AWTEvent {
+ private:
+ QTextEdit *area;
+ QString *text;
+
+ public:
+ TASetText(QTextEdit *w, QString *t) : AWTEvent()
+ {
+ area = w;
+ text = t;
+ }
+
+ void runEvent()
+ {
+ area->setPlainText( *text );
+ delete text;
+ }
+};
+
+/*
+ * Construct a QTextEdit object
+ */
+JNIEXPORT void JNICALL Java_gnu_java_awt_peer_qt_QtTextAreaPeer_init
+(JNIEnv *env, jobject obj)
+{
+ QWidget *parentWidget = (QWidget *)getParentWidget( env, obj );
+ assert( parentWidget );
+ QTextEdit *editor = new QTextEdit( parentWidget );
+ editor->setGeometry( 0, 0, 400, 400 );
+ assert( editor );
+
+ // setLineWrapColumnOrWidth ( int w );
+ setNativeObject( env, obj, editor );
+
+ // Connect TextChanged events.
+ connectTextEdit(editor, env, obj);
+}
+
+/*
+ * Returns the cursor position.
+ */
+JNIEXPORT jint JNICALL Java_gnu_java_awt_peer_qt_QtTextAreaPeer_getCaretPosition
+(JNIEnv *env, jobject obj)
+{
+ int index;
+
+ QTextEdit *editor = (QTextEdit *) getNativeObject( env, obj );
+ assert( editor );
+
+ index = editor->textCursor().position();;
+
+ return (jint)index;
+}
+
+/*
+ * Returns the char index at a given screen point
+ */
+JNIEXPORT jint JNICALL Java_gnu_java_awt_peer_qt_QtTextAreaPeer_getIndexAtPoint
+(JNIEnv *env, jobject obj, jint x, jint y)
+{
+ QPoint *p = new QPoint(x,y);
+
+ QTextEdit *editor = (QTextEdit *) getNativeObject( env, obj );
+ assert( editor );
+ QTextCursor curs = editor->cursorForPosition( *p );
+ delete p;
+
+ return curs.position();
+}
+
+/*
+ * Returns the start (start = true) or end (start = false) of the selection.
+ */
+JNIEXPORT jint JNICALL Java_gnu_java_awt_peer_qt_QtTextAreaPeer_getSelection
+(JNIEnv *env, jobject obj, jboolean isStart)
+{
+ int start, end;
+
+ QTextEdit *editor = (QTextEdit *) getNativeObject( env, obj );
+ assert( editor );
+ start = editor->textCursor().selectionStart();
+ end = editor->textCursor().selectionEnd();
+
+ return ((isStart == JNI_TRUE) ? start : end);
+}
+
+/*
+ * Returns the text.
+ */
+JNIEXPORT jstring JNICALL Java_gnu_java_awt_peer_qt_QtTextAreaPeer_getText
+(JNIEnv *env, jobject obj)
+{
+ QTextEdit *editor = (QTextEdit *) getNativeObject( env, obj );
+ assert( editor );
+ QString text = editor->toPlainText();
+
+ return getJavaString(env, &text);
+}
+
+/*
+ * Sets the editor text.
+ */
+JNIEXPORT void JNICALL Java_gnu_java_awt_peer_qt_QtTextAreaPeer_setText
+(JNIEnv *env, jobject obj, jstring str)
+{
+ QTextEdit *editor = (QTextEdit *) getNativeObject( env, obj );
+ assert( editor );
+
+ QString *qStr = getQString(env, str);
+ mainThread->postEventToMain( new TASetText( editor, qStr ) );
+}
+
+/*
+ * Sets the selection.
+ */
+JNIEXPORT void JNICALL Java_gnu_java_awt_peer_qt_QtTextAreaPeer_select
+(JNIEnv *env, jobject obj, jint startpos, jint endpos)
+{
+ QTextEdit *editor = (QTextEdit *) getNativeObject( env, obj );
+ assert( editor );
+
+ QTextCursor curs(editor->document());
+ curs.setPosition(startpos);
+ curs.setPosition(endpos, QTextCursor::KeepAnchor);
+ editor->setTextCursor( curs );
+}
+
+/*
+ * Allow or disallow editing.
+ */
+JNIEXPORT void JNICALL Java_gnu_java_awt_peer_qt_QtTextAreaPeer_setEditable
+(JNIEnv *env, jobject obj, jboolean editable)
+{
+ QTextEdit *editor = (QTextEdit *) getNativeObject( env, obj );
+ assert( editor );
+ editor->setReadOnly( (editable != JNI_TRUE) );
+}
+
+/*
+ * Sets the cursor position
+ */
+JNIEXPORT void JNICALL Java_gnu_java_awt_peer_qt_QtTextAreaPeer_setCaretPosition
+(JNIEnv *env, jobject obj, jint index)
+{
+ QTextEdit *editor = (QTextEdit *) getNativeObject( env, obj );
+ assert( editor );
+
+ editor->textCursor().setPosition( index );
+}
--- /dev/null
+/* qttextfieldpeer.cpp --
+ 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., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 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 <assert.h>
+#include <QLineEdit>
+#include <QWidget>
+#include <gnu_java_awt_peer_qt_QtTextFieldPeer.h>
+#include "qtcomponent.h"
+#include "qtstrings.h"
+#include "slotcallbacks.h"
+#include "mainthreadinterface.h"
+
+class TFEchoChar : public AWTEvent {
+ private:
+ QLineEdit *line;
+ jchar c;
+
+ public:
+ TFEchoChar(QLineEdit *w, jchar ch) : AWTEvent()
+ {
+ line = w;
+ c = ch;
+ }
+
+ void runEvent()
+ {
+ line->setEchoMode( (c) ? QLineEdit::Password : QLineEdit::Normal );
+ }
+};
+
+class TFEditable : public AWTEvent {
+ private:
+ QLineEdit *line;
+ bool editable;
+
+ public:
+ TFEditable(QLineEdit *w, bool e) : AWTEvent()
+ {
+ line = w;
+ editable = e;
+ }
+
+ void runEvent()
+ {
+ line->setReadOnly( editable );
+ }
+};
+
+class TFSetText : public AWTEvent {
+ private:
+ QLineEdit *line;
+ QString *text;
+
+ public:
+ TFSetText(QLineEdit *w, QString *t) : AWTEvent()
+ {
+ line = w;
+ text = t;
+ }
+
+ void runEvent()
+ {
+ line->setText( *text );
+ delete text;
+ }
+};
+
+class TFSetCursorPos : public AWTEvent {
+ private:
+ QLineEdit *line;
+ int pos;
+
+ public:
+ TFSetCursorPos(QLineEdit *w, int p) : AWTEvent()
+ {
+ line = w;
+ pos = p;
+ }
+
+ void runEvent()
+ {
+ line->setCursorPosition(pos);
+ }
+};
+
+class TFSelect : public AWTEvent {
+ private:
+ QLineEdit *line;
+ int start,end;
+
+ public:
+ TFSelect(QLineEdit *w, int s, int e) : AWTEvent()
+ {
+ line = w;
+ start = s;
+ end = e;
+ }
+
+ void runEvent()
+ {
+ line->setSelection(start, end - start);
+ }
+};
+
+
+/*
+ */
+JNIEXPORT void JNICALL Java_gnu_java_awt_peer_qt_QtTextFieldPeer_init
+(JNIEnv *env, jobject obj)
+{
+ QWidget *parentWidget = (QWidget *)getParentWidget(env, obj);
+ assert( parentWidget );
+ QLineEdit *line = new QLineEdit( parentWidget );
+ assert( line );
+
+ setNativeObject( env, obj, line );
+ connectLineEdit(line, env, obj);
+}
+
+
+/*
+ * Sets the echo char.
+ */
+JNIEXPORT void JNICALL Java_gnu_java_awt_peer_qt_QtTextFieldPeer_setEchoChar
+(JNIEnv *env, jobject obj, jchar echo)
+{
+ QLineEdit *line = (QLineEdit *) getNativeObject( env, obj );
+ assert( line );
+ mainThread->postEventToMain( new TFEchoChar( line, echo ) );
+}
+
+/*
+ */
+JNIEXPORT jobject JNICALL Java_gnu_java_awt_peer_qt_QtTextFieldPeer_getMinimumSizeNative
+(JNIEnv *env, jobject obj, jint columns)
+{
+ QLineEdit *line = (QLineEdit *) getNativeObject( env, obj );
+ assert( line );
+
+ // FIXME does this work?
+ int old = line->maxLength();
+ line->setMaxLength(columns);
+ QSize size = line->minimumSizeHint();
+ line->setMaxLength(old);
+
+ return makeDimension(env, &size);
+}
+
+/*
+ */
+JNIEXPORT jobject JNICALL Java_gnu_java_awt_peer_qt_QtTextFieldPeer_getPreferredSizeNative
+(JNIEnv *env, jobject obj, jint columns)
+{
+ QLineEdit *line = (QLineEdit *) getNativeObject( env, obj );
+ assert( line );
+
+ int old = line->maxLength();
+ line->setMaxLength(columns);
+ QSize size = line->sizeHint();
+ line->setMaxLength(old);
+
+ return makeDimension(env, &size);
+}
+
+/*
+ */
+JNIEXPORT void JNICALL Java_gnu_java_awt_peer_qt_QtTextFieldPeer_setEditable
+(JNIEnv *env, jobject obj, jboolean edit)
+{
+ QLineEdit *line = (QLineEdit *) getNativeObject( env, obj );
+ assert( line );
+
+ mainThread->postEventToMain( new TFEditable( line, (edit != JNI_TRUE) ) );
+}
+
+/*
+ * Gets the text.
+ */
+JNIEXPORT jstring JNICALL Java_gnu_java_awt_peer_qt_QtTextFieldPeer_getText
+(JNIEnv *env, jobject obj)
+{
+ QLineEdit *line = (QLineEdit *) getNativeObject( env, obj );
+ assert( line );
+ QString text = line->text();
+
+ return getJavaString(env, &text);
+}
+
+/*
+ * Sets the text
+ */
+JNIEXPORT void JNICALL Java_gnu_java_awt_peer_qt_QtTextFieldPeer_setText
+(JNIEnv *env, jobject obj, jstring text)
+{
+ QLineEdit *line = (QLineEdit *) getNativeObject( env, obj );
+ assert( line );
+
+ QString *qStr = getQString(env, text);
+ mainThread->postEventToMain( new TFSetText( line, qStr ) );
+}
+
+/*
+ * Returns the start (start = true) or end (start = false) of the selection.
+ */
+JNIEXPORT jint JNICALL Java_gnu_java_awt_peer_qt_QtTextFieldPeer_getSelection
+(JNIEnv *env, jobject obj, jboolean start)
+{
+ int index, length;
+
+ QLineEdit *line = (QLineEdit *) getNativeObject( env, obj );
+ assert( line );
+ index = line->selectionStart();
+
+ if(start == JNI_TRUE)
+ return index;
+
+ length = (line->selectedText()).length();
+
+ return index + length;
+}
+
+/*
+ * Sets the selection.
+ */
+JNIEXPORT void JNICALL Java_gnu_java_awt_peer_qt_QtTextFieldPeer_select
+(JNIEnv *env, jobject obj, jint start, jint end)
+{
+ QLineEdit *line = (QLineEdit *) getNativeObject( env, obj );
+ assert( line );
+
+ mainThread->postEventToMain( new TFSelect( line, start, end ) );
+}
+
+/*
+ * Sets the cursor position.
+ */
+JNIEXPORT void JNICALL Java_gnu_java_awt_peer_qt_QtTextFieldPeer_setCaretPosition
+(JNIEnv *env, jobject obj, jint pos)
+{
+ QLineEdit *line = (QLineEdit *) getNativeObject( env, obj );
+ assert( line );
+ mainThread->postEventToMain( new TFSetCursorPos( line, (int)pos ) );
+}
+
+/*
+ * Returns the caret position.
+ */
+JNIEXPORT jint JNICALL Java_gnu_java_awt_peer_qt_QtTextFieldPeer_getCaretPosition
+(JNIEnv *env, jobject obj)
+{
+ QLineEdit *line = (QLineEdit *) getNativeObject( env, obj );
+ assert( line );
+
+ return line->cursorPosition();
+}
+
--- /dev/null
+/* qttoolkit.cpp --
+ 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., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 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 <QApplication>
+#include <QDesktopWidget>
+#include <QString>
+#include <QStringList>
+#include <QFontDatabase>
+#include <gnu_java_awt_peer_qt_QtToolkit.h>
+#include "qtcomponent.h"
+#include "mainthreadinterface.h"
+#include "qtstrings.h"
+
+extern QApplication *qApplication;
+
+/**
+ * Calls syncX();
+ */
+class AWTSyncEvent : public AWTEvent {
+
+ private:
+ QApplication *application;
+
+ public:
+ AWTSyncEvent(QApplication *app) : AWTEvent()
+ {
+ application = app;
+ }
+
+ void runEvent()
+ {
+ application->syncX();
+ }
+};
+
+/*
+ * Causes your machine to beep. Wow.
+ */
+JNIEXPORT void JNICALL Java_gnu_java_awt_peer_qt_QtToolkit_beep
+(JNIEnv *env, jobject obj)
+{
+ qApplication->beep();
+}
+
+/**
+ * Returns the # of the default screen.
+ */
+JNIEXPORT jint JNICALL Java_gnu_java_awt_peer_qt_QtToolkit_defaultScreen
+(JNIEnv *env, jobject obj)
+{
+ return (jint) qApplication->desktop()->primaryScreen();
+}
+
+/**
+ * Returns the # of screens.
+ */
+JNIEXPORT jint JNICALL Java_gnu_java_awt_peer_qt_QtToolkit_numScreens
+(JNIEnv *env, jobject obj)
+{
+ return (jint) qApplication->desktop()->numScreens();
+}
+
+/*
+ * Returns the screen size.
+ */
+JNIEXPORT jobject JNICALL Java_gnu_java_awt_peer_qt_QtToolkit_getScreenSize
+(JNIEnv *env, jobject obj)
+{
+ QDesktopWidget *d = QApplication::desktop();
+ QSize s = d->size();
+ return makeDimension( env, &s );
+}
+
+/*
+ * Returns the available fonts
+ */
+JNIEXPORT jobjectArray JNICALL Java_gnu_java_awt_peer_qt_QtToolkit_nativeFontFamilies
+(JNIEnv *env, jobject obj)
+{
+ jobjectArray result_array;
+ jobject *result_array_ptr;
+ QFontDatabase db;
+ QStringList fonts = db.families();
+
+ result_array = env->NewObjectArray(fonts.size(),
+ env->FindClass("java/lang/String"),
+ env->NewStringUTF(""));
+ for (int i = 0; i < fonts.size(); i++)
+ {
+ QString qstr = fonts.at(i);
+ jstring jstr = getJavaString(env, &qstr);
+ env->SetObjectArrayElement( result_array, i, jstr );
+ }
+ return result_array;
+}
+
+
+/*
+ * Returns the screen resolution
+ */
+JNIEXPORT jint JNICALL Java_gnu_java_awt_peer_qt_QtToolkit_getScreenResolution
+(JNIEnv *env, jobject obj)
+{
+ QDesktopWidget *d = qApplication->desktop();
+
+ // Java assumes square pixels. Qt, more intelligently, does not.
+ // What to do? Well.. Average them?
+ // FIXME: Weird values?
+ int dpi = (d->logicalDpiX() + d->logicalDpiY()) >> 1;
+
+ return (jint)dpi;
+}
+
+/*
+ */
+JNIEXPORT void JNICALL Java_gnu_java_awt_peer_qt_QtToolkit_sync
+(JNIEnv *env, jobject obj)
+{
+ // SyncX needs to be called from the main thread.
+ mainThread->postEventToMain( new AWTSyncEvent( qApplication ) );
+}
+
--- /dev/null
+/* qtvolatileimage.cpp --
+ 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., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 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 <assert.h>
+#include <QPixmap>
+#include <QImage>
+#include <QColor>
+#include <QMatrix>
+#include <QPainter>
+#include <gnu_java_awt_peer_qt_QtVolatileImage.h>
+#include "qtimage.h"
+#include "qtstrings.h"
+#include "qtgraphics.h"
+#include "nativewrapper.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
+
+QPixmap *getQtVolatileImage( JNIEnv *env, jobject obj )
+{
+ jclass cls = env->GetObjectClass( obj );
+ jfieldID field = env->GetFieldID( cls, "nativeObject", "J" );
+ return (QPixmap *)env->GetLongField( obj, field );
+}
+
+static void setNativePtr( JNIEnv *env, jobject obj, void *value )
+{
+ jlong longValue = (jlong) value;
+ jclass cls = env->GetObjectClass( obj );
+ jfieldID field = env->GetFieldID( cls, "nativeObject", "J" );
+ env->SetLongField( obj, field, longValue );
+}
+
+/*
+ * Clears the image to zero.
+ */
+JNIEXPORT void JNICALL Java_gnu_java_awt_peer_qt_QtVolatileImage_clear
+(JNIEnv *env, jobject obj)
+{
+ QPixmap *image = getQtVolatileImage(env, obj);
+ assert( image );
+ image->fill();
+}
+
+/*
+ * Returns the pixel data in an int array.
+ */
+JNIEXPORT jintArray JNICALL Java_gnu_java_awt_peer_qt_QtVolatileImage_getPixels
+(JNIEnv *env, jobject obj)
+{
+ QPixmap *image = getQtVolatileImage(env, obj);
+ jintArray result_array;
+ jint *result_array_ptr, *dst;
+ int x, y;
+ jint pixel;
+ QRgb current;
+
+ assert( image );
+ QImage im = image->toImage();
+
+ result_array = env->NewIntArray (image->width() * image->height());
+ dst = result_array_ptr =
+ env->GetIntArrayElements(result_array, NULL);
+
+ // A bit inefficient.
+ for ( y = 0; y < image->height(); y++)
+ for ( x = 0; x < image->width(); x++)
+ {
+ current = im.pixel(x, y);
+ pixel = 0;
+ pixel = (qAlpha(current) & 0xFF) << 24 |
+ (qRed(current) & 0xFF) << 16 |
+ (qGreen(current) & 0xFF) << 8 |
+ (qBlue(current) & 0xFF);
+ *dst = pixel;
+ dst++;
+ }
+
+ env->ReleaseIntArrayElements (result_array, result_array_ptr, 0);
+ return result_array;
+}
+
+/*
+ * Creates a QImage.
+ */
+JNIEXPORT void JNICALL Java_gnu_java_awt_peer_qt_QtVolatileImage_createImage
+(JNIEnv *env, jobject obj)
+{
+ int width, height;
+ jclass cls;
+ jfieldID field;
+
+ cls = env->GetObjectClass( obj );
+ field = env->GetFieldID (cls, "width", "I");
+ assert (field != 0);
+ width = env->GetIntField(obj, field);
+
+ field = env->GetFieldID(cls, "height", "I");
+ assert (field != 0);
+ height = env->GetIntField(obj, field);
+
+ QPixmap *image = new QPixmap ( width, height );
+ setNativePtr(env, obj, image);
+}
+
+/*
+ * Frees the image data.
+ */
+JNIEXPORT void JNICALL Java_gnu_java_awt_peer_qt_QtVolatileImage_freeImage
+(JNIEnv *env, jobject obj)
+{
+ QPixmap *image = getQtVolatileImage(env, obj);
+ if ( image )
+ delete image;
+ setNativePtr(env, obj, NULL);
+}
+
+/*
+ * Blits a QImage
+ */
+JNIEXPORT void JNICALL Java_gnu_java_awt_peer_qt_QtVolatileImage_blit__Lgnu_java_awt_peer_qt_QtImage_2
+(JNIEnv *env, jobject obj, jobject i2)
+{
+ QPixmap *image = getQtVolatileImage(env, obj);
+ assert( image );
+
+ QImage *blit = getQtImage(env, i2);
+ assert( blit );
+
+ QPainter *p = new QPainter( image );
+ assert( p );
+ p->drawImage( 0, 0, *blit );
+
+ delete p;
+}
+
+/*
+ * Blits a QImage
+ */
+JNIEXPORT void JNICALL Java_gnu_java_awt_peer_qt_QtVolatileImage_blit__Lgnu_java_awt_peer_qt_QtImage_2IIII
+(JNIEnv *env, jobject obj, jobject i2, jint x, jint y, jint w, jint h)
+{
+ QPixmap *image = getQtVolatileImage(env, obj);
+ assert( image );
+
+ QImage *blit = getQtImage(env, i2);
+ assert( blit );
+
+ QPainter *p = new QPainter( image );
+ assert( p );
+ p->drawImage( x, y, *blit, x, y, w, h);
+
+ delete p;
+}
+
+/*
+ * Creates a scaled version.
+ */
+JNIEXPORT void JNICALL Java_gnu_java_awt_peer_qt_QtVolatileImage_createScaledImage
+(JNIEnv *env, jobject obj, jobject src, jint hints)
+{
+ int w,h;
+ jclass cls;
+ jfieldID field;
+
+ cls = env->GetObjectClass( obj );
+ field = env->GetFieldID(cls, "width", "I");
+ assert (field != 0);
+ w = env->GetIntField(obj, field);
+
+ field = env->GetFieldID(cls, "height", "I");
+ assert (field != 0);
+ h = env->GetIntField(obj, field);
+
+ QPixmap *ip = getQtVolatileImage(env, src);
+ assert( ip );
+ QImage image = ip->toImage();
+ QImage imageScaled;
+
+ if (hints == SCALE_SMOOTH || hints == SCALE_AREA_AVERAGING)
+ imageScaled = image.scaled(w, h,
+ Qt::IgnoreAspectRatio,
+ Qt::SmoothTransformation);
+ else
+ imageScaled = image.scaled(w, h,
+ Qt::IgnoreAspectRatio,
+ Qt::FastTransformation);
+ QImage *scaledPtr = new QImage( imageScaled );
+
+ // create new QtImage object
+ setNativePtr( env, obj, scaledPtr );
+}
+
+/*
+ * DrawPixels.
+ */
+JNIEXPORT void JNICALL Java_gnu_java_awt_peer_qt_QtVolatileImage_drawPixels
+(JNIEnv *env, jobject obj, jobject graphics, jint bg_red, jint bg_green,
+ jint bg_blue, jint x, jint y, jboolean composite)
+{
+ QPixmap *image = getQtVolatileImage(env, obj);
+ assert( image );
+ QPainter *painter = getPainter( env, graphics );
+ assert( painter );
+
+ if(composite == JNI_TRUE)
+ painter->fillRect ( x, y, image->width(), image->height(),
+ QColor(bg_red, bg_green, bg_blue ) );
+ painter->drawPixmap ( QPoint(x, y), *image );
+}
+
+/*
+ * DrawPixels scaled.
+ */
+JNIEXPORT void JNICALL Java_gnu_java_awt_peer_qt_QtVolatileImage_drawPixelsScaled
+(JNIEnv *env, jobject obj, jobject graphics,
+ jint bg_red, jint bg_green, jint bg_blue,
+ jint x, jint y, jint w, jint h, jboolean composite)
+{
+ QPixmap *image = getQtVolatileImage(env, obj);
+ assert( image );
+ QPainter *painter = getPainter( env, graphics );
+ assert( painter );
+
+ if(composite == JNI_TRUE)
+ painter->fillRect ( x, y, w, h, QColor(bg_red, bg_green, bg_blue ) );
+
+ QRectF *srcRect = new QRectF((qreal)0, (qreal)0,
+ (qreal)image->width(), (qreal)image->height());
+ QRectF *dstRect = new QRectF((qreal)x, (qreal)y,
+ (qreal)w, (qreal)h);
+
+ if(composite == JNI_TRUE)
+ painter->fillRect( *dstRect, QColor(bg_red, bg_green, bg_blue ) );
+
+ painter->drawPixmap( *dstRect, *image, *srcRect);
+
+ delete srcRect;
+ delete dstRect;
+}
+
+/*
+ * Draw pixels transformed.
+ */
+JNIEXPORT void JNICALL Java_gnu_java_awt_peer_qt_QtVolatileImage_drawPixelsTransformed
+(JNIEnv *env, jobject obj, jobject graphics, jobject transform)
+{
+ QPixmap *originalImage = getQtVolatileImage(env, obj);
+ assert( originalImage );
+ QPainter *painter = getPainter( env, graphics );
+ assert( painter );
+ QMatrix *matrix = (QMatrix *)getNativeObject(env, transform);
+ assert( matrix );
+
+ // FIXME : Add rendering hint support here.
+ QPoint p = matrix->map( QPoint(0,0) );
+ QImage image = originalImage->toImage().transformed ( *matrix, Qt::FastTransformation );
+ painter->drawImage(p, image);
+}
+
+
+/**
+ * Draw pixels scaled and flipped
+ */
+JNIEXPORT void JNICALL Java_gnu_java_awt_peer_qt_QtVolatileImage_drawPixelsScaledFlipped
+(JNIEnv *env, jobject obj, jobject graphics,
+ 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)
+{
+ QPixmap *originalImage = getQtVolatileImage(env, obj);
+ assert( originalImage );
+ QPainter *painter = getPainter( env, graphics );
+ assert( painter );
+
+ QRectF *srcRect = new QRectF((qreal)srcx, (qreal)srcy,
+ (qreal)srcwidth, (qreal)srcheight);
+ QRectF *dstRect = new QRectF((qreal)dstx, (qreal)dsty,
+ (qreal)dstwidth, (qreal)dstheight);
+
+ if(composite == JNI_TRUE)
+ painter->fillRect( *dstRect, QColor(bg_red, bg_green, bg_blue ) );
+
+ if( flipx == JNI_TRUE || flipy == JNI_TRUE )
+ {
+ QImage im = originalImage->toImage().mirrored ( (flipx == JNI_TRUE),
+ (flipy == JNI_TRUE) );
+ painter->drawImage ( *dstRect, im, *srcRect);
+ }
+ else
+ painter->drawPixmap ( *dstRect, *originalImage, *srcRect);
+
+ delete srcRect;
+ delete dstRect;
+}
+
+/**
+ * Copies an area of the image (used by Graphics)
+ */
+JNIEXPORT void JNICALL Java_gnu_java_awt_peer_qt_QtVolatileImage_copyArea
+(JNIEnv *env, jobject obj , jint x, jint y, jint w, jint h, jint dx, jint dy)
+{
+ QPixmap *image = getQtVolatileImage(env, obj);
+ assert( image );
+
+ // FIXME
+}
--- /dev/null
+/* qtwindowpeer.cpp --
+ 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., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 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 <assert.h>
+#include <QWidget>
+#include <qstyle.h>
+#include <gnu_java_awt_peer_qt_QtWindowPeer.h>
+#include "qtcomponent.h"
+#include "keybindings.h"
+#include "qtstrings.h"
+#include "containers.h"
+#include "mainthreadinterface.h"
+
+/*
+ * Our QMainWindow subclass
+ */
+class MyWindow : public QWidget
+{
+public:
+ MyWindow(JNIEnv *env, jobject obj) : QWidget(0, (Qt::Window | Qt::FramelessWindowHint))
+ {
+ setup(env, obj);
+ }
+
+ ~MyWindow()
+ {
+ destroy();
+ }
+
+#define I_KNOW_WHAT_IM_DOING
+#define PARENT QWidget
+#include "eventmethods.h"
+};
+
+
+class RaiseLower : public AWTEvent {
+
+ private:
+ QWidget *widget;
+ bool raise;
+
+ public:
+ RaiseLower(QWidget *w, bool r) : AWTEvent()
+ {
+ widget = w;
+ raise = r;
+ }
+
+ void runEvent()
+ {
+ if (raise)
+ widget->raise();
+ else
+ widget->lower();
+ }
+};
+
+class FrameTitleEvent : public AWTEvent {
+
+ private:
+ QWidget *widget;
+ QString *string;
+
+ public:
+ FrameTitleEvent(QWidget *w, QString *s) : AWTEvent()
+ {
+ widget = w;
+ string = s;
+ }
+
+ void runEvent()
+ {
+ widget->setWindowTitle( *string );
+ delete string;
+ }
+};
+
+/*
+ * Constructs a top-level QWidget native object.
+ */
+JNIEXPORT void JNICALL Java_gnu_java_awt_peer_qt_QtWindowPeer_init
+(JNIEnv *env, jobject obj)
+{
+ QWidget *window = new MyWindow(env, obj);
+ assert( window );
+ // Qt::WStyle_StaysOnTop
+ setNativeObject( env, obj, window );
+}
+
+/*
+ * Lower the window.
+ */
+JNIEXPORT void JNICALL Java_gnu_java_awt_peer_qt_QtWindowPeer_toBack
+(JNIEnv *env, jobject obj)
+{
+ QWidget *window = (QWidget *) getNativeObject( env, obj );
+ assert( window );
+ mainThread->postEventToMain( new RaiseLower( window, false ) );
+}
+
+/*
+ * Raise the window.
+ */
+JNIEXPORT void JNICALL Java_gnu_java_awt_peer_qt_QtWindowPeer_toFront
+(JNIEnv *env, jobject obj)
+{
+ QWidget *window = (QWidget *) getNativeObject( env, obj );
+ assert( window );
+ mainThread->postEventToMain( new RaiseLower( window, true ) );
+}
+
+/*
+ * Title.
+ */
+JNIEXPORT void JNICALL Java_gnu_java_awt_peer_qt_QtWindowPeer_setTitle
+(JNIEnv *env, jobject obj, jstring string)
+{
+ QWidget *frame = (QWidget *) getNativeObject( env, obj );
+ assert( frame );
+ QString *qStr = getQString(env, string);
+ mainThread->postEventToMain( new FrameTitleEvent( frame, qStr ) );
+}
+
--- /dev/null
+/* slotcallbacks.cpp --
+ 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., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 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 <QObject>
+#include <QAbstractButton>
+#include <QAbstractSlider>
+#include <QAction>
+#include <QComboBox>
+#include <QListWidget>
+#include <QLineEdit>
+#include <QPushButton>
+#include <QTextEdit>
+#include <gnu_java_awt_peer_qt_QtButtonPeer.h>
+#include "qtcomponent.h"
+#include "qtstrings.h"
+#include "keybindings.h"
+#include "buttonevent.h"
+#include "slotcallbacks.h"
+
+// AdjustmentEvent constants
+#define UNIT_INCREMENT 1
+#define UNIT_DECREMENT 2
+#define BLOCK_DECREMENT 3
+#define BLOCK_INCREMENT 4
+#define TRACK 5
+
+
+class SlotCallback : public QObject {
+ Q_OBJECT;
+
+private:
+ JavaVM* vm;
+ jobject target;
+ jclass componentCls;
+ jmethodID fireEventID;
+
+public:
+ QScrollBar *sb; // used only by the scrollbar method.
+ QListWidget *lw; // used only by the listitemclicked method
+
+ SlotCallback(JNIEnv *env, jobject t)
+ {
+ env->GetJavaVM(&vm);
+ target = t;
+ target = env->NewGlobalRef(t);
+ }
+
+ ~SlotCallback()
+ {
+ JNIEnv *env;
+ vm->GetEnv((void **)&env, JNI_VERSION_1_1);
+ env->DeleteGlobalRef(target);
+ }
+
+ public slots:
+
+ void buttonClicked()
+ {
+ JNIEnv *env;
+ vm->GetEnv((void **)&env, JNI_VERSION_1_1);
+ componentCls = env->GetObjectClass( target );
+ fireEventID = env->GetMethodID( componentCls,
+ "fireClick",
+ "(I)V" );
+ int modifiers = getAEKeyModifiers( QApplication::keyboardModifiers() );
+ env->CallVoidMethod( target, fireEventID, modifiers );
+ env->DeleteLocalRef( componentCls );
+ }
+
+ void buttonToggled(bool checked)
+ {
+ JNIEnv *env;
+ vm->GetEnv((void **)&env, JNI_VERSION_1_1);
+ componentCls = env->GetObjectClass( target );
+ fireEventID = env->GetMethodID( componentCls,
+ "fireToggle",
+ "(Z)V" );
+ if(checked)
+ env->CallVoidMethod( target, fireEventID, JNI_TRUE );
+ else
+ env->CallVoidMethod( target, fireEventID, JNI_FALSE );
+ env->DeleteLocalRef( componentCls );
+ }
+
+ // Used for List and Choice
+ void choiceActivated( int index )
+ {
+ JNIEnv *env;
+ vm->GetEnv((void **)&env, JNI_VERSION_1_1);
+ componentCls = env->GetObjectClass( target );
+ fireEventID = env->GetMethodID( componentCls,
+ "fireChoice",
+ "(I)V" );
+ env->CallVoidMethod( target, fireEventID, (jint)index );
+ env->DeleteLocalRef( componentCls );
+ }
+
+ void textChanged()
+ {
+ JNIEnv *env;
+ vm->GetEnv((void **)&env, JNI_VERSION_1_1);
+ componentCls = env->GetObjectClass( target );
+ fireEventID = env->GetMethodID( componentCls,
+ "textChanged",
+ "()V" );
+ env->CallVoidMethod( target, fireEventID );
+ env->DeleteLocalRef( componentCls );
+ }
+
+ void scrollBarAction( int action )
+ {
+ JNIEnv *env;
+ int type;
+ int index;
+ switch(action)
+ {
+ case QAbstractSlider::SliderNoAction:
+ return;
+ case QAbstractSlider::SliderSingleStepAdd:
+ type = UNIT_INCREMENT;
+ break;
+ case QAbstractSlider::SliderSingleStepSub:
+ type = UNIT_DECREMENT;
+ break;
+ case QAbstractSlider::SliderPageStepAdd:
+ type = BLOCK_INCREMENT;
+ break;
+ case QAbstractSlider::SliderPageStepSub:
+ type = BLOCK_DECREMENT;
+ break;
+ case QAbstractSlider::SliderToMinimum:
+ type = TRACK;
+ break;
+ case QAbstractSlider::SliderToMaximum:
+ type = TRACK;
+ break;
+ case QAbstractSlider::SliderMove:
+ type = TRACK;
+ break;
+ }
+ index = sb->value();
+ vm->GetEnv((void **)&env, JNI_VERSION_1_1);
+ componentCls = env->GetObjectClass( target );
+ fireEventID = env->GetMethodID( componentCls,
+ "fireMoved",
+ "(II)V" );
+ env->CallVoidMethod( target, fireEventID, (jint)type, (jint)index );
+ env->DeleteLocalRef( componentCls );
+ }
+
+ void listItemClicked( QListWidgetItem * item )
+ {
+ int index = lw->row( item );
+ JNIEnv *env;
+ vm->GetEnv((void **)&env, JNI_VERSION_1_1);
+ componentCls = env->GetObjectClass( target );
+ fireEventID = env->GetMethodID( componentCls,
+ "itemDoubleClicked",
+ "(II)V" );
+ int modifiers = getAEKeyModifiers( QApplication::keyboardModifiers() );
+ env->CallVoidMethod( target, fireEventID, index, modifiers );
+ env->DeleteLocalRef( componentCls );
+ }
+};
+
+#include "slotcallbacks.moc.h"
+
+void connectButton(QPushButton *button, JNIEnv *env, jobject buttonobj)
+{
+ SlotCallback *scb = new SlotCallback(env, buttonobj);
+ QObject::connect( button, SIGNAL( clicked() ), scb, SLOT( buttonClicked() ) );
+}
+
+void connectChoice(QComboBox *choice, JNIEnv *env, jobject choiceobj)
+{
+ SlotCallback *scb = new SlotCallback(env, choiceobj);
+ QObject::connect( choice, SIGNAL( activated(int) ), scb, SLOT( choiceActivated(int) ) );
+}
+
+void connectList(QListWidget *list, JNIEnv *env, jobject listobj)
+{
+ SlotCallback *scb = new SlotCallback(env, listobj);
+ scb->lw = list;
+ QObject::connect( list, SIGNAL( currentRowChanged(int) ),
+ scb, SLOT( choiceActivated(int) ) );
+ QObject::connect( list, SIGNAL( itemDoubleClicked( QListWidgetItem * )),
+ scb, SLOT( listItemClicked( QListWidgetItem * )));
+}
+
+void connectAction(QAction *action, JNIEnv *env, jobject obj)
+{
+ SlotCallback *scb = new SlotCallback(env, obj);
+ QObject::connect( action, SIGNAL( triggered() ), scb, SLOT( buttonClicked() ) );
+}
+
+void connectToggle(QAbstractButton *action, JNIEnv *env, jobject obj)
+{
+ SlotCallback *scb = new SlotCallback(env, obj);
+ QObject::connect( action, SIGNAL( toggled(bool) ), scb, SLOT( buttonToggled(bool) ) );
+}
+
+void connectScrollBar(QScrollBar *scroll, JNIEnv *env, jobject obj)
+{
+ SlotCallback *scb = new SlotCallback(env, obj);
+ scb->sb = scroll;
+ QObject::connect( scroll, SIGNAL( actionTriggered(int) ), scb, SLOT( scrollBarAction(int) ) );
+}
+
+void connectTextEdit(QTextEdit *edit, JNIEnv *env, jobject obj)
+{
+ SlotCallback *scb = new SlotCallback(env, obj);
+ QObject::connect( edit, SIGNAL( textChanged() ),
+ scb, SLOT( textChanged() ) );
+}
+
+void connectLineEdit(QLineEdit *edit, JNIEnv *env, jobject obj)
+{
+ SlotCallback *scb = new SlotCallback(env, obj);
+ QObject::connect( edit, SIGNAL(textChanged( QString ) ),
+ scb, SLOT( textChanged() ) );
+}
+
--- /dev/null
+#ifndef SLOTCALLBACKS_H
+#define SLOTCALLBACKS_H
+
+#include <QAbstractButton>
+#include <QAbstractSlider>
+#include <QAction>
+#include <QComboBox>
+#include <QListWidget>
+#include <QLineEdit>
+#include <QPushButton>
+#include <QScrollBar>
+#include <QTextEdit>
+#include <jni.h>
+
+void connectButton(QPushButton *button, JNIEnv *env, jobject buttonobj);
+void connectChoice(QComboBox *choice, JNIEnv *env, jobject choiceobj);
+void connectAction(QAction *action, JNIEnv *env, jobject obj);
+void connectToggle(QAbstractButton *action, JNIEnv *env, jobject obj);
+void connectScrollBar(QScrollBar *scroll, JNIEnv *env, jobject obj);
+void connectList(QListWidget *list, JNIEnv *env, jobject choiceobj);
+void connectTextEdit(QTextEdit *edit, JNIEnv *env, jobject obj);
+void connectLineEdit(QLineEdit *edit, JNIEnv *env, jobject obj);
+
+#endif
--- /dev/null
+/* BindingIteratorPOA.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., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 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 org.omg.CORBA.BAD_OPERATION;
+import org.omg.CORBA.CompletionStatus;
+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.PortableServer.POA;
+import org.omg.PortableServer.Servant;
+
+/**
+ * The binding iterator servant, used in POA-based naming service
+ * implementations.
+ *
+ * @since 1.4
+ *
+ * @author Audrius Meskauskas, Lithuania (AudriusA@Bioinformatics.org)
+ */
+public abstract class BindingIteratorPOA
+ extends Servant
+ implements BindingIteratorOperations, InvokeHandler
+{
+ /** @inheritDoc */
+ public String[] _all_interfaces(POA poa, byte[] object_ID)
+ {
+ return new String[] { BindingIteratorHelper.id() };
+ }
+
+ /**
+ * Call the required method.
+ */
+ public OutputStream _invoke(String method, InputStream in, ResponseHandler rh)
+ {
+ OutputStream out = null;
+
+ // We suppose that the next_n should be the most popular.
+ if (method.equals("next_n"))
+ {
+ // The next_n has been invoked.
+ int amount = in.read_ulong();
+ BindingListHolder a_list = new BindingListHolder();
+
+ boolean result = next_n(amount, a_list);
+
+ out = rh.createReply();
+ out.write_boolean(result);
+ BindingListHelper.write(out, a_list.value);
+ }
+ else if (method.equals("next_one"))
+ {
+ // The next_one has been invoked.
+ BindingHolder a_binding = new BindingHolder();
+
+ boolean result = next_one(a_binding);
+
+ out = rh.createReply();
+ out.write_boolean(result);
+ BindingHelper.write(out, a_binding.value);
+ }
+ else if (method.equals("destroy"))
+ {
+ // The destroy has been invoked.
+ destroy();
+ out = rh.createReply();
+ }
+ else
+ throw new BAD_OPERATION(method, 0, CompletionStatus.COMPLETED_MAYBE);
+
+ return out;
+ }
+
+ /**
+ * Get the CORBA object that delegates calls to this servant. The servant must
+ * be already connected to an ORB.
+ */
+ public BindingIterator _this()
+ {
+ return BindingIteratorHelper.narrow(super._this_object());
+ }
+
+ /**
+ * Get the CORBA object that delegates calls to this servant. Connect to the
+ * given ORB, if needed.
+ */
+ public BindingIterator _this(org.omg.CORBA.ORB orb)
+ {
+ return BindingIteratorHelper.narrow(super._this_object(orb));
+ }
+}
--- /dev/null
+/* NamingContextExtPOA.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., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 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 org.omg.CORBA.BAD_OPERATION;
+import org.omg.CORBA.CompletionStatus;
+import org.omg.CORBA.ObjectHelper;
+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.InvalidAddress;
+import org.omg.CosNaming.NamingContextExtPackage.InvalidAddressHelper;
+import org.omg.CosNaming.NamingContextPackage.AlreadyBound;
+import org.omg.CosNaming.NamingContextPackage.AlreadyBoundHelper;
+import org.omg.CosNaming.NamingContextPackage.CannotProceed;
+import org.omg.CosNaming.NamingContextPackage.CannotProceedHelper;
+import org.omg.CosNaming.NamingContextPackage.InvalidName;
+import org.omg.CosNaming.NamingContextPackage.InvalidNameHelper;
+import org.omg.CosNaming.NamingContextPackage.NotEmpty;
+import org.omg.CosNaming.NamingContextPackage.NotEmptyHelper;
+import org.omg.CosNaming.NamingContextPackage.NotFound;
+import org.omg.CosNaming.NamingContextPackage.NotFoundHelper;
+import org.omg.PortableServer.POA;
+import org.omg.PortableServer.Servant;
+
+/**
+ * The extended naming service servant. After implementing the abstract methods the
+ * instance of this class can be connected to an ORB using POA.
+ *
+ * @since 1.4
+ *
+ * @author Audrius Meskauskas, Lithuania (AudriusA@Bioinformatics.org)
+ */
+public abstract class NamingContextExtPOA
+ extends Servant
+ implements NamingContextExtOperations, InvokeHandler
+
+{
+ /** @inheritDoc */
+ public String[] _all_interfaces(POA poa, byte[] object_ID)
+ {
+ return new String[] { NamingContextExtHelper.id(), NamingContextHelper.id() };
+ }
+
+ /** @inheritDoc */
+ public OutputStream _invoke(String method, InputStream in, ResponseHandler rh)
+ {
+ Integer call_method = (Integer) _NamingContextExtImplBase._methods.get(method);
+
+ if (call_method == null)
+ // The older methods are handled separately.
+ return super_invoke(method, in, rh);
+
+ OutputStream out = null;
+
+ switch (call_method.intValue())
+ {
+ case 0: // to_string
+ {
+ try
+ {
+ NameComponent[] a_name = NameHelper.read(in);
+ String result = null;
+ result = this.to_string(a_name);
+ out = rh.createReply();
+ out.write_string(result);
+ }
+ catch (InvalidName ex)
+ {
+ out = rh.createExceptionReply();
+ InvalidNameHelper.write(out, ex);
+ }
+ break;
+ }
+
+ case 1: // to_name
+ {
+ try
+ {
+ String a_name_string = in.read_string();
+ NameComponent[] result = to_name(a_name_string);
+ out = rh.createReply();
+ NameHelper.write(out, result);
+ }
+ catch (InvalidName ex)
+ {
+ out = rh.createExceptionReply();
+ InvalidNameHelper.write(out, ex);
+ }
+ break;
+ }
+
+ case 2: // to_url
+ {
+ try
+ {
+ String an_address = in.read_string();
+ String a_name_string = in.read_string();
+ String result = to_url(an_address, a_name_string);
+ out = rh.createReply();
+ out.write_string(result);
+ }
+ catch (InvalidAddress ex)
+ {
+ out = rh.createExceptionReply();
+ InvalidAddressHelper.write(out, ex);
+ }
+ catch (InvalidName ex)
+ {
+ out = rh.createExceptionReply();
+ InvalidNameHelper.write(out, ex);
+ }
+ break;
+ }
+
+ case 3: // resolve_str
+ {
+ try
+ {
+ String a_name_string = in.read_string();
+ org.omg.CORBA.Object result = resolve_str(a_name_string);
+ out = rh.createReply();
+ org.omg.CORBA.ObjectHelper.write(out, result);
+ }
+ catch (NotFound ex)
+ {
+ out = rh.createExceptionReply();
+ NotFoundHelper.write(out, ex);
+ }
+ catch (CannotProceed ex)
+ {
+ out = rh.createExceptionReply();
+ CannotProceedHelper.write(out, ex);
+ }
+ catch (InvalidName ex)
+ {
+ out = rh.createExceptionReply();
+ InvalidNameHelper.write(out, ex);
+ }
+ break;
+ }
+ }
+ return out;
+ }
+
+ /**
+ * Handles calls to the methods from the NamingContext. The classes cannot be
+ * directly derived from each other; new public methods would appear.
+ */
+ OutputStream super_invoke(String method, InputStream in, ResponseHandler rh)
+ {
+ OutputStream out = null;
+ Integer call_method = (Integer) _NamingContextImplBase.methods.get(method);
+ if (call_method == null)
+ throw new BAD_OPERATION(0, CompletionStatus.COMPLETED_MAYBE);
+
+ switch (call_method.intValue())
+ {
+ case 0: // bind
+ {
+ try
+ {
+ NameComponent[] a_name = NameHelper.read(in);
+ org.omg.CORBA.Object an_object = ObjectHelper.read(in);
+ bind(a_name, an_object);
+ out = rh.createReply();
+ }
+ catch (NotFound ex)
+ {
+ out = rh.createExceptionReply();
+ NotFoundHelper.write(out, ex);
+ }
+ catch (CannotProceed ex)
+ {
+ out = rh.createExceptionReply();
+ CannotProceedHelper.write(out, ex);
+ }
+ catch (InvalidName ex)
+ {
+ out = rh.createExceptionReply();
+ InvalidNameHelper.write(out, ex);
+ }
+ catch (AlreadyBound ex)
+ {
+ out = rh.createExceptionReply();
+ AlreadyBoundHelper.write(out, ex);
+ }
+ break;
+ }
+
+ case 1: // rebind
+ {
+ try
+ {
+ NameComponent[] a_name = NameHelper.read(in);
+ org.omg.CORBA.Object an_object = ObjectHelper.read(in);
+ rebind(a_name, an_object);
+ out = rh.createReply();
+ }
+ catch (NotFound ex)
+ {
+ out = rh.createExceptionReply();
+ NotFoundHelper.write(out, ex);
+ }
+ catch (CannotProceed ex)
+ {
+ out = rh.createExceptionReply();
+ CannotProceedHelper.write(out, ex);
+ }
+ catch (InvalidName ex)
+ {
+ out = rh.createExceptionReply();
+ InvalidNameHelper.write(out, ex);
+ }
+ break;
+ }
+
+ case 2: // bind_context
+ {
+ try
+ {
+ NameComponent[] a_name = NameHelper.read(in);
+ NamingContext a_context = NamingContextHelper.read(in);
+ bind_context(a_name, a_context);
+ out = rh.createReply();
+ }
+ catch (NotFound ex)
+ {
+ out = rh.createExceptionReply();
+ NotFoundHelper.write(out, ex);
+ }
+ catch (CannotProceed ex)
+ {
+ out = rh.createExceptionReply();
+ CannotProceedHelper.write(out, ex);
+ }
+ catch (InvalidName ex)
+ {
+ out = rh.createExceptionReply();
+ InvalidNameHelper.write(out, ex);
+ }
+ catch (AlreadyBound ex)
+ {
+ out = rh.createExceptionReply();
+ AlreadyBoundHelper.write(out, ex);
+ }
+ break;
+ }
+
+ case 3: // rebind_context
+ {
+ try
+ {
+ NameComponent[] a_name = NameHelper.read(in);
+ NamingContext a_context = NamingContextHelper.read(in);
+ rebind_context(a_name, a_context);
+ out = rh.createReply();
+ }
+ catch (NotFound ex)
+ {
+ out = rh.createExceptionReply();
+ NotFoundHelper.write(out, ex);
+ }
+ catch (CannotProceed ex)
+ {
+ out = rh.createExceptionReply();
+ CannotProceedHelper.write(out, ex);
+ }
+ catch (InvalidName ex)
+ {
+ out = rh.createExceptionReply();
+ InvalidNameHelper.write(out, ex);
+ }
+ break;
+ }
+
+ case 4: // resolve
+ {
+ try
+ {
+ NameComponent[] a_name = NameHelper.read(in);
+ org.omg.CORBA.Object __result = null;
+ __result = resolve(a_name);
+ out = rh.createReply();
+ ObjectHelper.write(out, __result);
+ }
+ catch (NotFound ex)
+ {
+ out = rh.createExceptionReply();
+ NotFoundHelper.write(out, ex);
+ }
+ catch (CannotProceed ex)
+ {
+ out = rh.createExceptionReply();
+ CannotProceedHelper.write(out, ex);
+ }
+ catch (InvalidName ex)
+ {
+ out = rh.createExceptionReply();
+ InvalidNameHelper.write(out, ex);
+ }
+ break;
+ }
+
+ case 5: // unbind
+ {
+ try
+ {
+ NameComponent[] a_name = NameHelper.read(in);
+ unbind(a_name);
+ out = rh.createReply();
+ }
+ catch (NotFound ex)
+ {
+ out = rh.createExceptionReply();
+ NotFoundHelper.write(out, ex);
+ }
+ catch (CannotProceed ex)
+ {
+ out = rh.createExceptionReply();
+ CannotProceedHelper.write(out, ex);
+ }
+ catch (InvalidName ex)
+ {
+ out = rh.createExceptionReply();
+ InvalidNameHelper.write(out, ex);
+ }
+ break;
+ }
+
+ case 6: // new_context
+ {
+ NamingContext __result = null;
+ __result = new_context();
+ out = rh.createReply();
+ NamingContextHelper.write(out, __result);
+ break;
+ }
+
+ case 7: // bind_new_context
+ {
+ try
+ {
+ NameComponent[] a_name = NameHelper.read(in);
+ NamingContext __result = null;
+ __result = bind_new_context(a_name);
+ out = rh.createReply();
+ NamingContextHelper.write(out, __result);
+ }
+ catch (NotFound ex)
+ {
+ out = rh.createExceptionReply();
+ NotFoundHelper.write(out, ex);
+ }
+ catch (AlreadyBound ex)
+ {
+ out = rh.createExceptionReply();
+ AlreadyBoundHelper.write(out, ex);
+ }
+ catch (CannotProceed ex)
+ {
+ out = rh.createExceptionReply();
+ CannotProceedHelper.write(out, ex);
+ }
+ catch (InvalidName ex)
+ {
+ out = rh.createExceptionReply();
+ InvalidNameHelper.write(out, ex);
+ }
+ break;
+ }
+
+ case 8: // destroy
+ {
+ try
+ {
+ destroy();
+ out = rh.createReply();
+ }
+ catch (NotEmpty ex)
+ {
+ out = rh.createExceptionReply();
+ NotEmptyHelper.write(out, ex);
+ }
+ break;
+ }
+
+ case 9: // list
+ {
+ int amount = in.read_ulong();
+ BindingListHolder a_list = new BindingListHolder();
+ BindingIteratorHolder an_iter = new BindingIteratorHolder();
+ list(amount, a_list, an_iter);
+ out = rh.createReply();
+ BindingListHelper.write(out, a_list.value);
+ BindingIteratorHelper.write(out, an_iter.value);
+ break;
+ }
+
+ default:
+ throw new BAD_OPERATION(0, CompletionStatus.COMPLETED_MAYBE);
+ }
+
+ return out;
+ }
+
+ /**
+ * Get the CORBA object that delegates calls to this servant. The servant must
+ * be already connected to an ORB.
+ */
+ public NamingContextExt _this()
+ {
+ return NamingContextExtHelper.narrow(super._this_object());
+ }
+
+ /**
+ * Get the CORBA object that delegates calls to this servant. Connect to the
+ * given ORB, if needed.
+ */
+ public NamingContextExt _this(org.omg.CORBA.ORB orb)
+ {
+ return NamingContextExtHelper.narrow(super._this_object(orb));
+ }
+}
--- /dev/null
+/* NamingContextPOA.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., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 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 org.omg.CORBA.BAD_OPERATION;
+import org.omg.CORBA.CompletionStatus;
+import org.omg.CORBA.ObjectHelper;
+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.NamingContextPackage.AlreadyBound;
+import org.omg.CosNaming.NamingContextPackage.AlreadyBoundHelper;
+import org.omg.CosNaming.NamingContextPackage.CannotProceed;
+import org.omg.CosNaming.NamingContextPackage.CannotProceedHelper;
+import org.omg.CosNaming.NamingContextPackage.InvalidName;
+import org.omg.CosNaming.NamingContextPackage.InvalidNameHelper;
+import org.omg.CosNaming.NamingContextPackage.NotEmpty;
+import org.omg.CosNaming.NamingContextPackage.NotEmptyHelper;
+import org.omg.CosNaming.NamingContextPackage.NotFound;
+import org.omg.CosNaming.NamingContextPackage.NotFoundHelper;
+import org.omg.PortableServer.POA;
+import org.omg.PortableServer.Servant;
+
+/**
+ * The naming service servant. After implementing the abstract methods the
+ * instance of this class can be connected to an ORB using POA.
+ *
+ * @since 1.4
+ *
+ * @author Audrius Meskauskas, Lithuania (AudriusA@Bioinformatics.org)
+ */
+public abstract class NamingContextPOA
+ extends Servant
+ implements NamingContextOperations, InvokeHandler
+{
+ /** @inheritDoc */
+ public String[] _all_interfaces(POA poa, byte[] object_ID)
+ {
+ return new String[] { NamingContextHelper.id() };
+ }
+
+ /**
+ * The server calls this method after receiving the request message from
+ * client. The implementation base calls one of its abstract methods to
+ * perform the requested operation.
+ *
+ * @param method the method being invoked.
+ * @param in the stream to read parameters from.
+ * @param rh the handler to get a stream for writing a response.
+ *
+ * @return the stream, returned by the handler.
+ */
+ public OutputStream _invoke(String method, InputStream in, ResponseHandler rh)
+ {
+ OutputStream out = null;
+ Integer call_method = (Integer) _NamingContextImplBase.methods.get(method);
+ if (call_method == null)
+ throw new BAD_OPERATION(0, CompletionStatus.COMPLETED_MAYBE);
+
+ switch (call_method.intValue())
+ {
+ case 0: // bind
+ {
+ try
+ {
+ NameComponent[] a_name = NameHelper.read(in);
+ org.omg.CORBA.Object an_object = ObjectHelper.read(in);
+ bind(a_name, an_object);
+ out = rh.createReply();
+ }
+ catch (NotFound ex)
+ {
+ out = rh.createExceptionReply();
+ NotFoundHelper.write(out, ex);
+ }
+ catch (CannotProceed ex)
+ {
+ out = rh.createExceptionReply();
+ CannotProceedHelper.write(out, ex);
+ }
+ catch (InvalidName ex)
+ {
+ out = rh.createExceptionReply();
+ InvalidNameHelper.write(out, ex);
+ }
+ catch (AlreadyBound ex)
+ {
+ out = rh.createExceptionReply();
+ AlreadyBoundHelper.write(out, ex);
+ }
+ break;
+ }
+
+ case 1: // rebind
+ {
+ try
+ {
+ NameComponent[] a_name = NameHelper.read(in);
+ org.omg.CORBA.Object an_object = ObjectHelper.read(in);
+ rebind(a_name, an_object);
+ out = rh.createReply();
+ }
+ catch (NotFound ex)
+ {
+ out = rh.createExceptionReply();
+ NotFoundHelper.write(out, ex);
+ }
+ catch (CannotProceed ex)
+ {
+ out = rh.createExceptionReply();
+ CannotProceedHelper.write(out, ex);
+ }
+ catch (InvalidName ex)
+ {
+ out = rh.createExceptionReply();
+ InvalidNameHelper.write(out, ex);
+ }
+ break;
+ }
+
+ case 2: // bind_context
+ {
+ try
+ {
+ NameComponent[] a_name = NameHelper.read(in);
+ NamingContext a_context = NamingContextHelper.read(in);
+ bind_context(a_name, a_context);
+ out = rh.createReply();
+ }
+ catch (NotFound ex)
+ {
+ out = rh.createExceptionReply();
+ NotFoundHelper.write(out, ex);
+ }
+ catch (CannotProceed ex)
+ {
+ out = rh.createExceptionReply();
+ CannotProceedHelper.write(out, ex);
+ }
+ catch (InvalidName ex)
+ {
+ out = rh.createExceptionReply();
+ InvalidNameHelper.write(out, ex);
+ }
+ catch (AlreadyBound ex)
+ {
+ out = rh.createExceptionReply();
+ AlreadyBoundHelper.write(out, ex);
+ }
+ break;
+ }
+
+ case 3: // rebind_context
+ {
+ try
+ {
+ NameComponent[] a_name = NameHelper.read(in);
+ NamingContext a_context = NamingContextHelper.read(in);
+ rebind_context(a_name, a_context);
+ out = rh.createReply();
+ }
+ catch (NotFound ex)
+ {
+ out = rh.createExceptionReply();
+ NotFoundHelper.write(out, ex);
+ }
+ catch (CannotProceed ex)
+ {
+ out = rh.createExceptionReply();
+ CannotProceedHelper.write(out, ex);
+ }
+ catch (InvalidName ex)
+ {
+ out = rh.createExceptionReply();
+ InvalidNameHelper.write(out, ex);
+ }
+ break;
+ }
+
+ case 4: // resolve
+ {
+ try
+ {
+ NameComponent[] a_name = NameHelper.read(in);
+ org.omg.CORBA.Object __result = null;
+ __result = resolve(a_name);
+ out = rh.createReply();
+ ObjectHelper.write(out, __result);
+ }
+ catch (NotFound ex)
+ {
+ out = rh.createExceptionReply();
+ NotFoundHelper.write(out, ex);
+ }
+ catch (CannotProceed ex)
+ {
+ out = rh.createExceptionReply();
+ CannotProceedHelper.write(out, ex);
+ }
+ catch (InvalidName ex)
+ {
+ out = rh.createExceptionReply();
+ InvalidNameHelper.write(out, ex);
+ }
+ break;
+ }
+
+ case 5: // unbind
+ {
+ try
+ {
+ NameComponent[] a_name = NameHelper.read(in);
+ unbind(a_name);
+ out = rh.createReply();
+ }
+ catch (NotFound ex)
+ {
+ out = rh.createExceptionReply();
+ NotFoundHelper.write(out, ex);
+ }
+ catch (CannotProceed ex)
+ {
+ out = rh.createExceptionReply();
+ CannotProceedHelper.write(out, ex);
+ }
+ catch (InvalidName ex)
+ {
+ out = rh.createExceptionReply();
+ InvalidNameHelper.write(out, ex);
+ }
+ break;
+ }
+
+ case 6: // new_context
+ {
+ NamingContext __result = null;
+ __result = new_context();
+ out = rh.createReply();
+ NamingContextHelper.write(out, __result);
+ break;
+ }
+
+ case 7: // bind_new_context
+ {
+ try
+ {
+ NameComponent[] a_name = NameHelper.read(in);
+ NamingContext __result = null;
+ __result = bind_new_context(a_name);
+ out = rh.createReply();
+ NamingContextHelper.write(out, __result);
+ }
+ catch (NotFound ex)
+ {
+ out = rh.createExceptionReply();
+ NotFoundHelper.write(out, ex);
+ }
+ catch (AlreadyBound ex)
+ {
+ out = rh.createExceptionReply();
+ AlreadyBoundHelper.write(out, ex);
+ }
+ catch (CannotProceed ex)
+ {
+ out = rh.createExceptionReply();
+ CannotProceedHelper.write(out, ex);
+ }
+ catch (InvalidName ex)
+ {
+ out = rh.createExceptionReply();
+ InvalidNameHelper.write(out, ex);
+ }
+ break;
+ }
+
+ case 8: // destroy
+ {
+ try
+ {
+ destroy();
+ out = rh.createReply();
+ }
+ catch (NotEmpty ex)
+ {
+ out = rh.createExceptionReply();
+ NotEmptyHelper.write(out, ex);
+ }
+ break;
+ }
+
+ case 9: // list
+ {
+ int amount = in.read_ulong();
+ BindingListHolder a_list = new BindingListHolder();
+ BindingIteratorHolder an_iter = new BindingIteratorHolder();
+ list(amount, a_list, an_iter);
+ out = rh.createReply();
+ BindingListHelper.write(out, a_list.value);
+ BindingIteratorHelper.write(out, an_iter.value);
+ break;
+ }
+
+ default:
+ throw new BAD_OPERATION(0, CompletionStatus.COMPLETED_MAYBE);
+ }
+
+ return out;
+ }
+
+ /**
+ * Get the CORBA object that delegates calls to this servant. The servant must
+ * be already connected to an ORB.
+ */
+ public NamingContext _this()
+ {
+ return NamingContextHelper.narrow(super._this_object());
+ }
+
+ /**
+ * Get the CORBA object that delegates calls to this servant. Connect to the
+ * given ORB, if needed.
+ */
+ public NamingContext _this(org.omg.CORBA.ORB orb)
+ {
+ return NamingContextHelper.narrow(super._this_object(orb));
+ }
+
+}
--- /dev/null
+/* AnySeqHelper.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., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 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.DynamicAny;
+
+import org.omg.CORBA.Any;
+import org.omg.CORBA.ORB;
+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 the array of {@link Any}. This class shares
+ * the same {@link AnySeqHolder} as the {@link org.omg.CORBA.AnySeqHelper}.
+ *
+ * @author Audrius Meskauskas, Lithuania (AudriusA@Bioinformatics.org)
+ */
+public abstract class AnySeqHelper
+{
+ /**
+ * The cached typecode value, computed only once.
+ */
+ private static TypeCode typeCode;
+
+ /**
+ * Delegates call to {@link org.omg.CORBA.AnySeqHelper#extract}.
+ */
+ public static Any[] extract(Any any)
+ {
+ return org.omg.CORBA.AnySeqHelper.extract(any);
+ }
+
+ /**
+ * Get the AnySeq repository id.
+ *
+ * @return "IDL:omg.org/DynamicAny/AnySeq:1.0", always.
+ */
+ public static String id()
+ {
+ return "IDL:omg.org/DynamicAny/AnySeq:1.0";
+ }
+
+ /**
+ * Delegates call to {@link org.omg.CORBA.AnySeqHelper#insert}.
+ */
+ public static void insert(Any any, Any[] those)
+ {
+ org.omg.CORBA.AnySeqHelper.insert(any, those);
+ }
+
+ /**
+ * Delegates call to {@link org.omg.CORBA.AnySeqHelper#read}.
+ *
+ * @param input a org.omg.CORBA.portable stream to read from.
+ */
+ public static Any[] read(InputStream input)
+ {
+ return org.omg.CORBA.AnySeqHelper.read(input);
+ }
+
+ /**
+ * Get the typecode as officially defined for this helper.
+ *
+ * @return alias of unbounded sequence of Any's, named AnySeq,
+ * with the id, returned by {@link #id()}.
+ */
+ public static TypeCode type()
+ {
+ if (typeCode == null)
+ {
+ ORB orb = ORB.init();
+ TypeCode t =
+ orb.create_sequence_tc(0, orb.get_primitive_tc(TCKind.tk_any));
+ typeCode = orb.create_alias_tc(id(), "AnySeq", t);
+ }
+ return typeCode;
+ }
+
+ /**
+ * Delegates call to {@link org.omg.CORBA.AnySeqHelper#write}.
+ */
+ public static void write(OutputStream output, Any[] value)
+ {
+ org.omg.CORBA.AnySeqHelper.write(output, value);
+ }
+}
\ No newline at end of file
--- /dev/null
+/* DynAny.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., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 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.DynamicAny;
+
+import java.io.Serializable;
+
+import org.omg.CORBA.Any;
+import org.omg.CORBA.portable.IDLEntity;
+
+/**
+ * <p>
+ * The DynAny interface provides possibility to access the components of the
+ * CORBA object, stored inside the {@link Any}. The DynAny and derived classes
+ * additionally allows to access the members of the sequence, structure, union
+ * and get the data about enumeration, value type and CORBA <code>fixed</code>
+ * without knowing the exact type at the run time. The returned members are also
+ * wrapped into DynAny objects, allowing them to be the nested structures.
+ * </p>
+ * <p>
+ * The DynAny's are usually produced by {@link DynAnyFactory}. This factory is
+ * obtained from the ORB: <br>
+ * <code>
+ * DynAnyFactory f = DynAnyFactoryHelper.narrow
+ * (orb.resolve_initial_references("DynAnyFactory"));
+ * </code>
+ * </p>
+ * <p>
+ * DynAny can also be returned by a method, invoked on another DynAny.
+ * </p>
+ *
+ * @author Audrius Meskauskas, Lithuania (AudriusA@Bioinformatics.org)
+ */
+public interface DynAny
+ extends DynAnyOperations, IDLEntity, org.omg.CORBA.Object, Serializable
+{
+}
\ No newline at end of file
--- /dev/null
+/* DynAnyFactory.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., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 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.DynamicAny;
+
+import java.io.Serializable;
+
+import org.omg.CORBA.portable.IDLEntity;
+
+/**
+ * Produces DynAnys from Anys or typecodes. The produced DynAnys are initialized
+ * to they agreed default values.
+ *
+ * @author Audrius Meskauskas, Lithuania (AudriusA@Bioinformatics.org)
+ */
+public interface DynAnyFactory
+ extends DynAnyFactoryOperations, IDLEntity, org.omg.CORBA.Object,
+ Serializable
+{
+}
--- /dev/null
+/* DynAnyFactoryHelper.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., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 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.DynamicAny;
+
+import org.omg.CORBA.BAD_PARAM;
+import org.omg.CORBA.TypeCode;
+import org.omg.CORBA.ORB;
+import org.omg.CORBA.Any;
+import org.omg.CORBA.portable.InputStream;
+import org.omg.CORBA.MARSHAL;
+import org.omg.CORBA.portable.OutputStream;
+
+/**
+ * The helper operations for {@link DynAnyFactory}. Following the 1.5 JDK
+ * specifications, DynAnyFactory is always a local object, so the two methods of
+ * this helper ({@link #read} and {@link #write} are not in use, always
+ * throwing {@link MARSHAL}.
+ *
+ * @specnote always throwing MARSHAL in read and write ensures compatibility
+ * with other popular implementations like Sun's.
+ *
+ * @author Audrius Meskauskas, Lithuania (AudriusA@Bioinformatics.org)
+ */
+public abstract class DynAnyFactoryHelper
+{
+ /**
+ * Cast the passed object into the DynAnyFactory. As DynAnyFactory is a local
+ * object, the method just uses java final_type cast.
+ *
+ * @param obj the object to narrow.
+ * @return narrowed instance.
+ * @throws BAD_PARAM if the passed object is not a DynAnyFactory.
+ */
+ public static DynAnyFactory narrow(org.omg.CORBA.Object obj)
+ {
+ try
+ {
+ return (DynAnyFactory) obj;
+ }
+ catch (ClassCastException cex)
+ {
+ throw new BAD_PARAM(obj.getClass().getName()
+ + " is not a DynAnyFactory");
+ }
+ }
+
+ /**
+ * Get the final_type code of the {@link DynAnyFactory}.
+ */
+ public static TypeCode type()
+ {
+ return ORB.init().create_interface_tc(id(), "DynAnyFactory");
+ }
+
+ /**
+ * Insert the DynAnyFactory into the given Any.
+ *
+ * @param any the Any to insert into.
+ *
+ * @param that the DynAnyFactory to insert.
+ */
+ public static void insert(Any any, DynAnyFactory that)
+ {
+ any.insert_Object(that);
+ }
+
+ /**
+ * Extract the DynAnyFactory from given Any.
+ *
+ * @throws BAD_OPERATION if the passed Any does not contain DynAnyFactory.
+ */
+ public static DynAnyFactory extract(Any any)
+ {
+ return narrow(any.extract_Object());
+ }
+
+ /**
+ * Get the DynAnyFactory repository id.
+ *
+ * @return "IDL:omg.org/DynamicAny/DynAnyFactory:1.0", always.
+ */
+ public static String id()
+ {
+ return "IDL:omg.org/DynamicAny/DynAnyFactory:1.0";
+ }
+
+ /**
+ * This should read DynAnyFactory from the CDR input stream, but (following
+ * the JDK 1.5 API) it does not. The factory can only be obtained from the
+ * ORB.
+ *
+ * @param input a org.omg.CORBA.portable stream to read from.
+ *
+ * @specenote Sun throws the same exception.
+ *
+ * @throws MARSHAL always.
+ */
+ public static DynAnyFactory read(InputStream input)
+ {
+ throw new MARSHAL(not_applicable(id()));
+ }
+
+ /**
+ * This should read DynAnyFactory from the CDR input stream, but (following
+ * the JDK 1.5 API) it does not.
+ *
+ * @param input a org.omg.CORBA.portable stream to read from.
+ *
+ * @specenote Sun throws the same exception.
+ *
+ * @throws MARSHAL always.
+ */
+ public static void write(OutputStream output, DynAnyFactory value)
+ {
+ throw new MARSHAL(not_applicable(id()));
+ }
+
+ /**
+ * The package level method for throwing exception, explaining that the
+ * operation is not applicable.
+ *
+ * @param Id the Id for the typecode for that the operations was attempted to
+ * perform.
+ */
+ static String not_applicable(String Id)
+ {
+ try
+ {
+ throw new MARSHAL("The read/write are not applicable for " + Id);
+ }
+ catch (Exception e)
+ {
+ throw new MARSHAL();
+ }
+ }
+}
\ No newline at end of file
--- /dev/null
+/* DynAnyFactoryOperations.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., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 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.DynamicAny;
+
+import org.omg.CORBA.Any;
+import org.omg.CORBA.TypeCode;
+import org.omg.DynamicAny.DynAnyFactoryPackage.InconsistentTypeCode;
+
+/**
+ * Defines the operations, applicable for DynAnyFactory. These operations
+ * produce new DynAny's either from Any, serving as a template and value
+ * provider, or from the given typecode.
+ *
+ * @author Audrius Meskauskas, Lithuania (AudriusA@Bioinformatics.org)
+ */
+public interface DynAnyFactoryOperations
+{
+ /**
+ * Create DynAny for holding the data of the given type. The returned DynAny
+ * is initialised to its agreed default value. The agreed default values are:
+ * <table border='1'>
+ * <tr>
+ * <th>Type</th>
+ * <th>Value</th>
+ * <th>Creates</th>
+ * </tr>
+ *
+ * <tr>
+ * <td>boolean</td>
+ * <td>false</td>
+ * <td>{@link DynAny}</td>
+ * </tr>
+ * <tr>
+ * <td>numeric types, octet, fixed</td>
+ * <td>0</td>
+ * <td>{@link DynAny}</td>
+ * </tr>
+ * <tr>
+ * <td>char, wchar</td>
+ * <td>(char) 0</td>
+ * <td>{@link DynAny}</td>
+ * </tr>
+ * <tr>
+ * <td>string, wstring</td>
+ * <td>empty string ("", not <code>null<code>)</td>
+ * <td>{@link DynAny}</td>
+ * </tr>
+ * <tr>
+ * <td>{@link Any}</td>
+ * <td>{@link Any} with no value and typecode of kind {@link TCKind.tk_null}</td>
+ * <td>{@link DynAny}</td>
+ * </tr>
+ * <tr>
+ * <td>Sequence</td>
+ * <td>Empty (zero size) sequence</td>
+ * <td>{@link DynSequence}</td>
+ * </tr>
+ * <tr>
+ * <td>Array</td>
+ * <td>All members of array are recursively initialised to default values.</td>
+ * <td>{@link DynArray}</td>
+ * </tr>
+ * <tr>
+ * <td>Structure, exception</td>
+ * <td>All fields of the structure (if any) are recursively initialised to
+ * default values.</td>
+ * <td>{@link DynStruct}</td>
+ * </tr>
+ * <tr>
+ * <td>Enumeration</td>
+ * <td>Default value, indicated by typecode.</td>
+ * <td>{@link DynEnum}</td>
+ * </tr>
+ * <tr>
+ * <td>Union</td>
+ * <td>Default variant (indicated by typecode), recursively initialised to
+ * its default value.</td>
+ * <td>{@link DynUnion}</td>
+ * </tr>
+ * <tr>
+ * <td>Value, ValueBox</td>
+ * <td>null</td>
+ * <td>{@link DynValue}, {@link DynValueBox}</td>
+ * </tr>
+ * <tr>
+ * <td>TypeCode</td>
+ * <td>Typecode of kind <code>TCKind.tk_null</code></td>
+ * <td>{@link DynValue}, {@link DynValueBox}</td>
+ * </tr>
+ *
+ * </table>
+ *
+ * @param type the type of the data being stored.
+ *
+ * @return the created DynAny, having the passed type.
+ *
+ * @throws InconsistentTypeCode if type.kind() is tk_Principal, tk_native or
+ * tk_abstract_interface. These types cannot be stored in DynAny.
+ */
+ DynAny create_dyn_any_from_type_code(TypeCode type)
+ throws InconsistentTypeCode;
+
+ /**
+ * Create DynAny using the given Any as template.
+ *
+ * @param value the Any, providing type and value for the DynAny being
+ * created.
+ *
+ * @return the created DynAny, having the same type and storing the same value
+ * as the passed Any.
+ *
+ * @throws InconsistentTypeCode if value.type().kind() is tk_Principal,
+ * tk_native or tk_abstract_interface. These types cannot be stored in DynAny.
+ */
+ DynAny create_dyn_any(Any value)
+ throws InconsistentTypeCode;
+}
--- /dev/null
+/* DynAnyHelper.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., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 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.DynamicAny;
+
+import org.omg.CORBA.BAD_PARAM;
+import org.omg.CORBA.TypeCode;
+import org.omg.CORBA.ORB;
+import org.omg.CORBA.Any;
+import org.omg.CORBA.portable.InputStream;
+import org.omg.CORBA.MARSHAL;
+import org.omg.CORBA.portable.OutputStream;
+
+/**
+ * The helper operations for {@link DynAny}. Following the 1.5 JDK
+ * specifications, DynAny is always a local object, so the two methods of this
+ * helper ({@link #read} and {@link #write} are not in use, always throwing
+ * {@link MARSHAL}.
+ *
+ * @specnote always throwing MARSHAL in read and write ensures compatibility
+ * with other popular implementations like Sun's.
+ *
+ * @author Audrius Meskauskas, Lithuania (AudriusA@Bioinformatics.org)
+ */
+public abstract class DynAnyHelper
+{
+ /**
+ * Cast the passed object into the DynAny. As DynAny is a local object, the
+ * method just uses java type cast.
+ *
+ * @param obj the object to narrow.
+ * @return narrowed instance.
+ * @throws BAD_PARAM if the passed object is not a DynAny.
+ */
+ public static DynAny narrow(org.omg.CORBA.Object obj)
+ {
+ try
+ {
+ return (DynAny) obj;
+ }
+ catch (ClassCastException cex)
+ {
+ throw new BAD_PARAM(obj.getClass().getName() + " is not a DynAny");
+ }
+ }
+
+ /**
+ * Get the type code of the {@link DynAny}.
+ */
+ public static TypeCode type()
+ {
+ return ORB.init().create_interface_tc(id(), "DynAny");
+ }
+
+ /**
+ * Insert the DynAny into the given Any.
+ *
+ * @param any the Any to insert into.
+ *
+ * @param that the DynAny to insert.
+ */
+ public static void insert(Any any, DynAny that)
+ {
+ any.insert_Object(that);
+ }
+
+ /**
+ * Extract the DynAny from given Any.
+ *
+ * @throws BAD_OPERATION if the passed Any does not contain DynAny.
+ */
+ public static DynAny extract(Any any)
+ {
+ return narrow(any.extract_Object());
+ }
+
+ /**
+ * Get the DynAny repository id.
+ *
+ * @return "IDL:omg.org/DynamicAny/DynAny:1.0", always.
+ */
+ public static String id()
+ {
+ return "IDL:omg.org/DynamicAny/DynAny:1.0";
+ }
+
+ /**
+ * This should read DynAny from the CDR input stream, but (following the JDK
+ * 1.5 API) it does not.
+ *
+ * @param input a org.omg.CORBA.portable stream to read from.
+ *
+ * @specenote Sun throws the same exception.
+ *
+ * @throws MARSHAL always.
+ */
+ public static DynAny read(InputStream input)
+ {
+ throw new MARSHAL(DynAnyFactoryHelper.not_applicable(id()));
+ }
+
+ /**
+ * This should read DynAny from the CDR input stream, but (following the JDK
+ * 1.5 API) it does not.
+ *
+ * @param input a org.omg.CORBA.portable stream to read from.
+ *
+ * @specenote Sun throws the same exception.
+ *
+ * @throws MARSHAL always.
+ */
+ public static void write(OutputStream output, DynAny value)
+ {
+ throw new MARSHAL(DynAnyFactoryHelper.not_applicable(id()));
+ }
+}
\ No newline at end of file
--- /dev/null
+/* DynAnyOperations.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., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 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.DynamicAny;
+
+import org.omg.CORBA.Any;
+import org.omg.CORBA.TypeCode;
+import org.omg.DynamicAny.DynAnyPackage.InvalidValue;
+import org.omg.DynamicAny.DynAnyPackage.TypeMismatch;
+
+import java.io.Serializable;
+
+/**
+ * Defines the operations, applicable to {@link DynAny}.
+ *
+ * @author Audrius Meskauskas, Lithuania (AudriusA@Bioinformatics.org)
+ */
+public interface DynAnyOperations
+{
+ /**
+ * Initialises the value of this DynAny with the value, stored inside the
+ * passed DynAny, making a shallow copy.
+ *
+ * @param from the DynAny to copy from.
+ * @throws TypeMismatch if the source DynAny is invalid.
+ */
+ void assign(DynAny from)
+ throws TypeMismatch;
+
+ /**
+ * Fully clones the content of this Any, returning a deep copy.
+ */
+ DynAny copy();
+
+ /**
+ * Returns the focused component of this DynAny. The DynAny has the internal
+ * pointer (reference) that can point to one of its components. The returned
+ * DynAny can be used to get or set the value of the focused component. If the
+ * DynAny holds a primitive type with no components, this implementation
+ * returns <code>null</code>.
+ *
+ * @throws TypeMismatch if called on DynAny that cannot have active
+ * components, like {@link DynEnum}.
+ */
+ DynAny current_component()
+ throws TypeMismatch;
+
+ /**
+ * Destroys this DynAny, freeing the used resources. In java, resources are
+ * freed by the garbage collectors, so this method typically returns without
+ * action.
+ */
+ void destroy();
+
+ /**
+ * Makes a DynAny from the {@link Any}. The passed {@link Any} becomes the
+ * enclosed instance of this DynAny, allowing to change/traverse the
+ * {@link Any} fields by the {@link DynAny} methods.
+ *
+ * @throws TypeMismatch if the type of this DynAny differs from the type of
+ * the passed Any. The DynAny cannot be reused with the enclosed type
+ * different from that it was initially created.
+ * @throws InvalidValue if the value, stored in the passed parameter, is
+ * otherwise invalid.
+ */
+ void from_any(Any an_any)
+ throws TypeMismatch, InvalidValue;
+
+ /**
+ * This method is used when the wrapped Any contains an instance of another
+ * Any itself. The method returns this second enclosed Any.
+ *
+ * @throws TypeMismatch if the typecode of the accessed Any is not the same as
+ * the typecode of this DynAny.
+ */
+ Any get_any()
+ throws TypeMismatch, InvalidValue;
+
+ /**
+ * Extract the boolean value that is expected to be stored in this DynAny.
+ *
+ * @throws TypeMismatch if this DynAny holds the value of the different type.
+ */
+ boolean get_boolean()
+ throws TypeMismatch, InvalidValue;
+
+ /**
+ * Extract the char value that is expected to be stored in this DynAny.
+ *
+ * @throws TypeMismatch if this DynAny holds the value of the different type.
+ */
+ char get_char()
+ throws TypeMismatch, InvalidValue;
+
+ /**
+ * Extract the <code>double</code> value that is expected to be stored in
+ * this DynAny.
+ *
+ * @throws TypeMismatch if this DynAny holds the value of the different type.
+ */
+ double get_double()
+ throws TypeMismatch, InvalidValue;
+
+ /**
+ * Extract the <code>float</code> value that is expected to be stored in
+ * this DynAny.
+ *
+ * @throws TypeMismatch if this DynAny holds the value of the different type.
+ */
+ float get_float()
+ throws TypeMismatch, InvalidValue;
+
+ /**
+ * Extract the int (CORBA long) value that is expected to be stored in this
+ * DynAny.
+ *
+ * @throws TypeMismatch if this DynAny holds the value of the different type.
+ */
+ int get_long()
+ throws TypeMismatch, InvalidValue;
+
+ /**
+ * Extract the long (CORBA long long) value that is expected to be stored in
+ * this DynAny.
+ *
+ * @throws TypeMismatch if this DynAny holds the value of the different type.
+ */
+ long get_longlong()
+ throws TypeMismatch, InvalidValue;
+
+ /**
+ * Extract the byte (CORBA octet) value that is expected to be stored in this
+ * DynAny.
+ *
+ * @throws TypeMismatch if this DynAny holds the value of the different type.
+ */
+ byte get_octet()
+ throws TypeMismatch, InvalidValue;
+
+ /**
+ * Extract the CORBA object reference that is expected to be stored in this
+ * DynAny.
+ *
+ * @throws TypeMismatch if this DynAny holds the value of the different type.
+ */
+ org.omg.CORBA.Object get_reference()
+ throws TypeMismatch, InvalidValue;
+
+ /**
+ * Extract the <code>short</code> value that is expected to be stored in
+ * this DynAny.
+ *
+ * @throws TypeMismatch if this DynAny holds the value of the different type.
+ */
+ short get_short()
+ throws TypeMismatch, InvalidValue;
+
+ /**
+ * Extract the string value that is expected to be stored in this DynAny.
+ *
+ * @throws TypeMismatch if this DynAny holds the value of the different type.
+ */
+ String get_string()
+ throws TypeMismatch, InvalidValue;
+
+ /**
+ * Extract the {@link TypeCode} value that is expected to be stored in this
+ * DynAny.
+ *
+ * @throws TypeMismatch if this DynAny holds the value of the different type.
+ */
+ TypeCode get_typecode()
+ throws TypeMismatch, InvalidValue;
+
+ /**
+ * Extract the unsigned int (CORBA ulong) value that is expected to be stored
+ * in this DynAny.
+ *
+ * @throws TypeMismatch if this DynAny holds the value of the different type.
+ */
+ int get_ulong()
+ throws TypeMismatch, InvalidValue;
+
+ /**
+ * Extract the unsingel long (CORBA unsigned long long )value that is expected
+ * to be stored in this DynAny.
+ *
+ * @throws TypeMismatch if this DynAny holds the value of the different type.
+ */
+ long get_ulonglong()
+ throws TypeMismatch, InvalidValue;
+
+ /**
+ * Extract the unsigned short value that is expected to be stored in this
+ * DynAny.
+ *
+ * @throws TypeMismatch if this DynAny holds the value of the different type.
+ */
+ short get_ushort()
+ throws TypeMismatch, InvalidValue;
+
+ /**
+ * Extract the value that is expected to be stored in this DynAny.
+ *
+ * @throws TypeMismatch if this DynAny holds the value of the different type.
+ */
+ Serializable get_val()
+ throws TypeMismatch, InvalidValue;
+
+ /**
+ * Extract the wide (usually UTF-16) character value that is expected to be
+ * stored in this DynAny.
+ *
+ * @throws TypeMismatch if this DynAny holds the value of the different type.
+ */
+ char get_wchar()
+ throws TypeMismatch, InvalidValue;
+
+ /**
+ * Extract the wide (usually UFT-16) string that is expected to be stored in
+ * this DynAny.
+ *
+ * @throws TypeMismatch if this DynAny holds the value of the different type.
+ */
+ String get_wstring()
+ throws TypeMismatch, InvalidValue;
+
+ /**
+ * Insert the {@link Any} value into the enclosed {@link Any} inside this
+ * DynAny.
+ *
+ * @param a_x the value being inserted.
+ * @throws InvalidValue if the value type does not match the typecode of the
+ * enclosed {@link Any}.
+ */
+ void insert_any(Any an_any)
+ throws TypeMismatch, InvalidValue;
+
+ /**
+ * Insert the boolean value into the enclosed {@link Any} inside this DynAny
+ *
+ * @param a_x the value being inserted.
+ * @throws InvalidValue if the value type does not match the typecode of the
+ * enclosed {@link Any}.
+ */
+ void insert_boolean(boolean a_x)
+ throws InvalidValue, TypeMismatch;
+
+ /**
+ * Insert the char value into the enclosed {@link Any} inside this DynAny
+ *
+ * @param a_x the value being inserted.
+ * @throws InvalidValue if the value type does not match the typecode of the
+ * enclosed {@link Any}.
+ */
+ void insert_char(char a_x)
+ throws InvalidValue, TypeMismatch;
+
+ /**
+ * Insert the double value into the enclosed {@link Any} inside this DynAny
+ *
+ * @param a_x the value being inserted.
+ * @throws InvalidValue if the value type does not match the typecode of the
+ * enclosed {@link Any}.
+ */
+ void insert_double(double a_x)
+ throws InvalidValue, TypeMismatch;
+
+ /**
+ * Insert the float value into the enclosed {@link Any} inside this DynAny
+ *
+ * @param a_x the value being inserted.
+ * @throws InvalidValue if the value type does not match the typecode of the
+ * enclosed {@link Any}.
+ */
+ void insert_float(float a_x)
+ throws InvalidValue, TypeMismatch;
+
+ /**
+ * Insert the int (CORBA long) value into the enclosed {@link Any} inside this
+ * DynAny
+ *
+ * @param a_x the value being inserted.
+ * @throws InvalidValue if the value type does not match the typecode of the
+ * enclosed {@link Any}.
+ */
+ void insert_long(int a_x)
+ throws InvalidValue, TypeMismatch;
+
+ /**
+ * Insert the long (CORBA long long) value into the enclosed {@link Any}
+ * inside this DynAny
+ *
+ * @param a_x the value being inserted.
+ * @throws InvalidValue if the value type does not match the typecode of the
+ * enclosed {@link Any}.
+ */
+ void insert_longlong(long a_x)
+ throws InvalidValue, TypeMismatch;
+
+ /**
+ * Insert the byte (CORBA octet) value into the enclosed {@link Any} inside
+ * this DynAny
+ *
+ * @param a_x the value being inserted.
+ * @throws InvalidValue if the value type does not match the typecode of the
+ * enclosed {@link Any}.
+ */
+ void insert_octet(byte a_x)
+ throws InvalidValue, TypeMismatch;
+
+ /**
+ * Insert the object reference into the enclosed {@link Any} inside this
+ * DynAny
+ *
+ * @param a_x the value being inserted.
+ * @throws InvalidValue if the value type does not match the typecode of the
+ * enclosed {@link Any}.
+ */
+ void insert_reference(org.omg.CORBA.Object a_x)
+ throws InvalidValue, TypeMismatch;
+
+ /**
+ * Insert the <code>short</code> value into the enclosed {@link Any} inside
+ * this DynAny
+ *
+ * @param a_x the value being inserted.
+ * @throws InvalidValue if the value type does not match the typecode of the
+ * enclosed {@link Any}.
+ */
+ void insert_short(short a_x)
+ throws InvalidValue, TypeMismatch;
+
+ /**
+ * Insert the string value into the enclosed {@link Any} inside this DynAny
+ *
+ * @param a_x the value being inserted.
+ * @throws InvalidValue if the value type does not match the typecode of the
+ * enclosed {@link Any}.
+ */
+ void insert_string(String a_x)
+ throws InvalidValue, TypeMismatch;
+
+ /**
+ * Insert the {@link TypeCode} value into the enclosed {@link Any} inside this
+ * DynAny
+ *
+ * @param a_x the value being inserted.
+ * @throws InvalidValue if the value type does not match the typecode of the
+ * enclosed {@link Any}.
+ */
+ void insert_typecode(TypeCode a_x)
+ throws InvalidValue, TypeMismatch;
+
+ /**
+ * Insert the int (CORBA unsinged long) value into the enclosed {@link Any}
+ * inside this DynAny
+ *
+ * @param a_x the value being inserted.
+ * @throws InvalidValue if the value type does not match the typecode of the
+ * enclosed {@link Any}.
+ */
+ void insert_ulong(int a_x)
+ throws InvalidValue, TypeMismatch;
+
+ /**
+ * Insert the long (CORBA unsigned long long) value into the enclosed
+ * {@link Any} inside this DynAny
+ *
+ * @param a_x the value being inserted.
+ * @throws InvalidValue if the value type does not match the typecode of the
+ * enclosed {@link Any}.
+ */
+ void insert_ulonglong(long a_x)
+ throws InvalidValue, TypeMismatch;
+
+ /**
+ * Insert the short (CORBA unsigned short) value into the enclosed {@link Any}
+ * inside this DynAny
+ *
+ * @param a_x the value being inserted.
+ * @throws InvalidValue if the value type does not match the typecode of the
+ * enclosed {@link Any}.
+ */
+ void insert_ushort(short a_x)
+ throws InvalidValue, TypeMismatch;
+
+ /**
+ * Insert the value into the enclosed {@link Any} inside this DynAny
+ *
+ * @param a_x the value being inserted.
+ * @throws InvalidValue if the value type does not match the typecode of the
+ * enclosed {@link Any}.
+ */
+ void insert_val(Serializable a_x)
+ throws InvalidValue, TypeMismatch;
+
+ /**
+ * Insert the wide char (usually UTF-16) value into the enclosed {@link Any}
+ * inside this DynAny
+ *
+ * @param a_x the value being inserted.
+ * @throws InvalidValue if the value type does not match the typecode of the
+ * enclosed {@link Any}.
+ */
+ void insert_wchar(char a_x)
+ throws InvalidValue, TypeMismatch;
+
+ /**
+ * Insert the wide string (usually UTF-16) into the enclosed {@link Any}
+ * inside this DynAny
+ *
+ * @param a_x the value being inserted.
+ * @throws InvalidValue if the value type does not match the typecode of the
+ * enclosed {@link Any}.
+ */
+ void insert_wstring(String a_x)
+ throws InvalidValue, TypeMismatch;
+
+ /**
+ * Advances the internal pointer, described in the {@link current_component},
+ * one position forward.
+ *
+ * @return true if the pointer now points to the new component, false if there
+ * are no more components of this DynAny holds a basic type that is not
+ * divided into components.
+ */
+ boolean next();
+
+ /**
+ * Moves the internal pointer, described in the {@link current_component}, to
+ * the first component.
+ */
+ void rewind();
+
+ /**
+ * Moves the internal pointer, described in the {@link current_component}, to
+ * the given position.
+ *
+ * @param p the number of the internal component on that the internal pointer
+ * must be focused.
+ * @return true on success or false if there is no component with the given
+ * number. If the DynAny holds the basic type, this method returs false p
+ * values other than 0.
+ */
+ boolean seek(int p);
+
+ /**
+ * Returns a shallow copy of the enclosed {@link Any},
+ *
+ * @return shallow copy of the enclosed {@link Any}.
+ */
+ Any to_any();
+
+ /**
+ * Returns the typecode of the object, inserted into this DynAny.
+ *
+ * @return the typecode of the inserted {@link Any} or null typecode if no
+ * {@link Any has been yet inserted}.
+ */
+ TypeCode type();
+
+ /**
+ * Insert a value at the current position.
+ *
+ * @param insert_it a value to insert.
+ * @throws TypeMismatch if the component at the current position has a
+ * different type.
+ * @throws InvalidValue if the current position points nowhere.
+ */
+ void insert_dyn_any(DynAny insert_it)
+ throws TypeMismatch, InvalidValue;
+
+ /**
+ * Checks for equality with another Dynamic Any.
+ *
+ *
+ * @specnote This method is currently only implemented only for case when
+ * another DynAny was created by the factory of this implementation and is not
+ * an independent class, just implementing interface. Otherwise, a
+ * NO_IMPLEMENT minor 8148 will be thrown. General implementation is highly
+ * ineffective, but we will do if somebody would ever need it.
+ */
+ boolean equal(DynAny other);
+
+ /**
+ * Get the number number of fields in the enclosed structure or number of
+ * memebers in the enclosed array, sequence, enumeration, etc. This method
+ * only counts elements at the top level. For instance, if invoked on a
+ * DynStruct with a single member, it returns 1, irrespective of the type of
+ * the member.
+ *
+ * @return number of components or 0 if the enclosed Any is not divideable.
+ */
+ int component_count();
+
+ /**
+ * Return DynAny, wrapping the second (enclosed any) that is stored in the
+ * wrapped Any.
+ *
+ * @throws TypeMismatch if the wrapped Any does not store another Any.
+ * @throws InvalidValue if the current position points nowhere.
+ */
+ DynAny get_dyn_any()
+ throws TypeMismatch, InvalidValue;
+}
\ No newline at end of file
--- /dev/null
+/* DynAnySeq.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., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 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.DynamicAny;
+
+import gnu.CORBA.DynAnySeqHolder;
+
+import org.omg.CORBA.Any;
+import org.omg.CORBA.BAD_OPERATION;
+import org.omg.CORBA.MARSHAL;
+import org.omg.CORBA.ORB;
+import org.omg.CORBA.TypeCode;
+import org.omg.CORBA.portable.InputStream;
+import org.omg.CORBA.portable.OutputStream;
+
+/**
+ * A helper operations for the array of {@link DynAny} ({@link DynAnySeq}).
+ * Following the 1.5 JDK specifications, DynAny (and hence an sequence of
+ * DynAny's) is always a local object, so the two methods of this helper
+ * ({@link #read} and {@link #write} are not in use, always throwing
+ * {@link MARSHAL}.
+ *
+ * @specnote always throwing MARSHAL in read and write ensures compatibility
+ * with other popular implementations like Sun's.
+ *
+ * @author Audrius Meskauskas, Lithuania (AudriusA@Bioinformatics.org)
+ */
+public abstract class DynAnySeqHelper
+{
+ /**
+ * The cached typecode value, computed only once.
+ */
+ private static TypeCode typeCode;
+
+ public static TypeCode type()
+ {
+ if (typeCode == null)
+ {
+ ORB orb = ORB.init();
+ TypeCode t = orb.create_sequence_tc(0, DynAnyHelper.type());
+ typeCode = orb.create_alias_tc(id(), "DynAnySeq", t);
+ }
+ return typeCode;
+ }
+
+ /**
+ * Insert the DynAnySeq into the given Any.
+ * This method uses the DynAnySeqHolder.
+ *
+ * @param any the Any to insert into.
+ * @param those the DynAny[] to insert.
+ */
+ public static void insert(Any any, DynAny[] those)
+ {
+ any.insert_Streamable(new DynAnySeqHolder(those));
+ }
+
+ /**
+ * Extract the DynAnySeq from given Any.
+ * This method uses the DynAnySeqHolder.
+ *
+ * @throws BAD_OPERATION if the passed Any does not contain DynAnySeq.
+ */
+ public static DynAny[] extract(Any any)
+ {
+ try
+ {
+ return ((DynAnySeqHolder) any.extract_Streamable()).value;
+ }
+ catch (ClassCastException cex)
+ {
+ BAD_OPERATION bad = new BAD_OPERATION("DynAnySeq expected");
+ bad.initCause(cex);
+ throw bad;
+ }
+ }
+
+ /**
+ * Get the DynAnySeq repository id.
+ *
+ * @return "IDL:omg.org/DynamicAny/DynAnySeq:1.0", always.
+ */
+ public static String id()
+ {
+ return "IDL:omg.org/DynamicAny/DynAnySeq:1.0";
+ }
+
+ /**
+ * The method should read this object from the CDR input stream, but
+ * (following the JDK 1.5 API) it does not.
+ *
+ * @param input a org.omg.CORBA.portable stream to read from.
+ *
+ * @specenote Sun throws the same exception.
+ *
+ * @throws MARSHAL always.
+ */
+ public static DynAny[] read(InputStream input)
+ {
+ throw new MARSHAL(DynAnyFactoryHelper.not_applicable(id()));
+ }
+
+ /**
+ * The method should write this object to the CDR input stream, but
+ * (following the JDK 1.5 API) it does not.
+ *
+ * @param input a org.omg.CORBA.portable stream to read from.
+ *
+ * @specenote Sun throws the same exception.
+ *
+ * @throws MARSHAL always.
+ */
+ public static void write(OutputStream output, DynAny[] value)
+ {
+ throw new MARSHAL(DynAnyFactoryHelper.not_applicable(id()));
+ }
+}
\ No newline at end of file
--- /dev/null
+/* DynArray.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., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 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.DynamicAny;
+
+import java.io.Serializable;
+
+import org.omg.CORBA.portable.IDLEntity;
+
+/**
+ * Represents a fixed size array. All components in the array have the same
+ * type.
+ *
+ * @author Audrius Meskauskas, Lithuania (AudriusA@Bioinformatics.org)
+ */
+public interface DynArray
+ extends DynArrayOperations, DynAny, IDLEntity, org.omg.CORBA.Object,
+ Serializable
+{
+}
--- /dev/null
+/* DynArrayHelper.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., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 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.DynamicAny;
+
+import org.omg.CORBA.BAD_PARAM;
+import org.omg.CORBA.TypeCode;
+import org.omg.CORBA.ORB;
+import org.omg.CORBA.Any;
+import org.omg.CORBA.portable.InputStream;
+import org.omg.CORBA.MARSHAL;
+import org.omg.CORBA.portable.OutputStream;
+
+/**
+ * The helper operations for {@link DynArray}. Following the 1.5 JDK
+ * specifications, DynArray is always a local object, so the two methods of this
+ * helper ({@link #read} and {@link #write} are not in use, always throwing
+ * {@link MARSHAL}.
+ *
+ * @specnote always throwing MARSHAL in read and write ensures compatibility
+ * with other popular implementations like Sun's.
+ *
+ * @author Audrius Meskauskas, Lithuania (AudriusA@Bioinformatics.org)
+ */
+public abstract class DynArrayHelper
+{
+ /**
+ * Cast the passed object into the DynArray. As DynArray is a local object,
+ * the method just uses java type cast.
+ *
+ * @param obj the object to narrow.
+ * @return narrowed instance.
+ * @throws BAD_PARAM if the passed object is not a DynArray.
+ */
+ public static DynArray narrow(org.omg.CORBA.Object obj)
+ {
+ try
+ {
+ return (DynArray) obj;
+ }
+ catch (ClassCastException cex)
+ {
+ throw new BAD_PARAM(obj.getClass().getName() + " is not a DynArray");
+ }
+ }
+
+ /**
+ * Get the type code of the {@link DynArray}.
+ */
+ public static TypeCode type()
+ {
+ return ORB.init().create_interface_tc(id(), "DynArray");
+ }
+
+ /**
+ * Insert the DynArray into the given Any.
+ *
+ * @param any the Any to insert into.
+ *
+ * @param that the DynArray to insert.
+ */
+ public static void insert(Any any, DynArray that)
+ {
+ any.insert_Object(that);
+ }
+
+ /**
+ * Extract the DynArray from given Any.
+ *
+ * @throws BAD_OPERATION if the passed Any does not contain DynArray.
+ */
+ public static DynArray extract(Any any)
+ {
+ return narrow(any.extract_Object());
+ }
+
+ /**
+ * Get the DynArray repository id.
+ *
+ * @return "IDL:omg.org/DynamicAny/DynArray:1.0", always.
+ */
+ public static String id()
+ {
+ return "IDL:omg.org/DynamicAny/DynArray:1.0";
+ }
+
+ /**
+ * This should read DynArray from the CDR input stream, but (following the JDK
+ * 1.5 API) it does not.
+ *
+ * @param input a org.omg.CORBA.portable stream to read from.
+ *
+ * @specenote Sun throws the same exception.
+ *
+ * @throws MARSHAL always.
+ */
+ public static DynArray read(InputStream input)
+ {
+ throw new MARSHAL(DynAnyFactoryHelper.not_applicable(id()));
+ }
+
+ /**
+ * This should read DynArray from the CDR input stream, but (following the JDK
+ * 1.5 API) it does not.
+ *
+ * @param input a org.omg.CORBA.portable stream to read from.
+ *
+ * @specenote Sun throws the same exception.
+ *
+ * @throws MARSHAL always.
+ */
+ public static void write(OutputStream output, DynArray value)
+ {
+ throw new MARSHAL(DynAnyFactoryHelper.not_applicable(id()));
+ }
+}
\ No newline at end of file
--- /dev/null
+/* DynArrayOperations.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., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 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.DynamicAny;
+
+import org.omg.CORBA.Any;
+import org.omg.DynamicAny.DynAnyPackage.InvalidValue;
+import org.omg.DynamicAny.DynAnyPackage.TypeMismatch;
+
+/**
+ * Defines operations, applicable for {@link DynArray}.
+ *
+ * @author Audrius Meskauskas, Lithuania (AudriusA@Bioinformatics.org)
+ */
+public interface DynArrayOperations
+ extends DynAnyOperations
+{
+ /**
+ * Returns the array.
+ *
+ * @return the array of elements as an array of DynAny's.
+ */
+ DynAny[] get_elements_as_dyn_any();
+
+ /**
+ * Returns the array.
+ *
+ * @return the array of elements as an array of Any's.
+ */
+ Any[] get_elements();
+
+ /**
+ * Sets the array.
+ *
+ * @param value the array of elements an DynAny's.
+ *
+ * @throws TypeMismatch if the members of the passed array does not match
+ * array component type.
+ *
+ * @throws InvalidValue if the number of elements in the passed array is not
+ * the same as the size of this DynArray.
+ */
+ void set_elements_as_dyn_any(DynAny[] value)
+ throws TypeMismatch, InvalidValue;
+
+ /**
+ * Sets the array.
+ *
+ * @param value the array of elements as Any's.
+ *
+ * @throws TypeMismatch if the members of the passed array does not match
+ * array component type.
+ *
+ * @throws InvalidValue if the number of elements in the passed array is not
+ * the same as the size of this DynArray.
+ */
+ void set_elements(Any[] value)
+ throws TypeMismatch, InvalidValue;
+}
--- /dev/null
+/* DynEnum.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., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 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.DynamicAny;
+
+import java.io.Serializable;
+
+import org.omg.CORBA.portable.IDLEntity;
+
+/**
+ * Defines the dynamic enumeration. The value of the dynamic enumeration can be
+ * set by name or by integer code. The valid string values and integer codes are
+ * taken from the typecode, from which the enumeration was constructed. The
+ * enumeration is an undividable type without traversable components.
+ *
+ * @author Audrius Meskauskas, Lithuania (AudriusA@Bioinformatics.org)
+ */
+public interface DynEnum
+ extends DynEnumOperations, DynAny, IDLEntity, org.omg.CORBA.Object,
+ Serializable
+{
+}
--- /dev/null
+/* DynEnumHelper.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., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 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.DynamicAny;
+
+import org.omg.CORBA.BAD_PARAM;
+import org.omg.CORBA.TypeCode;
+import org.omg.CORBA.ORB;
+import org.omg.CORBA.Any;
+import org.omg.CORBA.portable.InputStream;
+import org.omg.CORBA.MARSHAL;
+import org.omg.CORBA.portable.OutputStream;
+
+/**
+ * The helper operations for {@link DynEnum}. Following the 1.5 JDK
+ * specifications, DynEnum is always a local object, so the two methods of this
+ * helper ({@link #read} and {@link #write} are not in use, always throwing
+ * {@link MARSHAL}.
+ *
+ * @specnote always throwing MARSHAL in read and write ensures compatibility
+ * with other popular implementations like Sun's.
+ *
+ * @author Audrius Meskauskas, Lithuania (AudriusA@Bioinformatics.org)
+ */
+public abstract class DynEnumHelper
+{
+ /**
+ * Cast the passed object into the DynEnum. As DynEnum is a local object, the
+ * method just uses java type cast.
+ *
+ * @param obj the object to narrow.
+ * @return narrowed instance.
+ * @throws BAD_PARAM if the passed object is not a DynEnum.
+ */
+ public static DynEnum narrow(org.omg.CORBA.Object obj)
+ {
+ try
+ {
+ return (DynEnum) obj;
+ }
+ catch (ClassCastException cex)
+ {
+ throw new BAD_PARAM(obj.getClass().getName() + " is not a DynEnum");
+ }
+ }
+
+ /**
+ * Get the type code of the {@link DynEnum}.
+ */
+ public static TypeCode type()
+ {
+ return ORB.init().create_interface_tc(id(), "DynEnum");
+ }
+
+ /**
+ * Insert the DynEnum into the given Any.
+ *
+ * @param any the Any to insert into.
+ *
+ * @param that the DynEnum to insert.
+ */
+ public static void insert(Any any, DynEnum that)
+ {
+ any.insert_Object(that);
+ }
+
+ /**
+ * Extract the DynEnum from given Any.
+ *
+ * @throws BAD_OPERATION if the passed Any does not contain DynEnum.
+ */
+ public static DynEnum extract(Any any)
+ {
+ return narrow(any.extract_Object());
+ }
+
+ /**
+ * Get the DynEnum repository id.
+ *
+ * @return "IDL:omg.org/DynamicAny/DynEnum:1.0", always.
+ */
+ public static String id()
+ {
+ return "IDL:omg.org/DynamicAny/DynEnum:1.0";
+ }
+
+ /**
+ * This should read DynEnum from the CDR input stream, but (following the JDK
+ * 1.5 API) it does not.
+ *
+ * @param input a org.omg.CORBA.portable stream to read from.
+ *
+ * @specenote Sun throws the same exception.
+ *
+ * @throws MARSHAL always.
+ */
+ public static DynEnum read(InputStream input)
+ {
+ throw new MARSHAL(DynAnyFactoryHelper.not_applicable(id()));
+ }
+
+ /**
+ * This should read DynEnum from the CDR input stream, but (following the JDK
+ * 1.5 API) it does not.
+ *
+ * @param input a org.omg.CORBA.portable stream to read from.
+ *
+ * @specenote Sun throws the same exception.
+ *
+ * @throws MARSHAL always.
+ */
+ public static void write(OutputStream output, DynEnum value)
+ {
+ throw new MARSHAL(DynAnyFactoryHelper.not_applicable(id()));
+ }
+}
\ No newline at end of file
--- /dev/null
+/* DynEnumOperations.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., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 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.DynamicAny;
+
+import org.omg.DynamicAny.DynAnyPackage.InvalidValue;
+
+/**
+ * Defines operations, applicable to the dynamic enumeration. The value of the
+ * dynamic enumeration can be set by name or by integer code. The valid string
+ * values and integer codes are taken from the typecode, from which the
+ * enumeration was constructed. The enumeration is an undividable type without
+ * traversable components.
+ *
+ * @author Audrius Meskauskas, Lithuania (AudriusA@Bioinformatics.org)
+ */
+public interface DynEnumOperations
+ extends DynAnyOperations
+{
+ /**
+ * Get the current enumeration value, as string.
+ */
+ String get_as_string();
+
+ /**
+ * Get the current enumeration value, as int.
+ */
+ int get_as_ulong();
+
+ /**
+ * Set the current enumeration value, as string.
+ *
+ * @throws InvalidValue if the passed string is not one of the allowed values
+ * for this enumeration.
+ */
+ void set_as_string(String value)
+ throws InvalidValue;
+
+ /**
+ * Set the current enumeration value, as int.
+ *
+ * @throws InvalidValue if the passed string is not one of the allowed values
+ * for this enumeration.
+ */
+ void set_as_ulong(int value)
+ throws InvalidValue;
+
+}
--- /dev/null
+/* DynFixed.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., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 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.DynamicAny;
+
+import java.io.Serializable;
+
+import org.omg.CORBA.portable.IDLEntity;
+
+/**
+ * Defines dynamic any, holding CORBA <code>fixed</code>. The operations on
+ * <code>fixed</code> (defined in {@link DynFixedOperations}) take and return
+ * this data type in its string representation.
+ *
+ * @author Audrius Meskauskas, Lithuania (AudriusA@Bioinformatics.org)
+ */
+public interface DynFixed
+ extends DynFixedOperations, DynAny, IDLEntity, org.omg.CORBA.Object,
+ Serializable
+{
+}
--- /dev/null
+/* DynFixedHelper.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., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 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.DynamicAny;
+
+import org.omg.CORBA.BAD_PARAM;
+import org.omg.CORBA.TypeCode;
+import org.omg.CORBA.ORB;
+import org.omg.CORBA.Any;
+import org.omg.CORBA.portable.InputStream;
+import org.omg.CORBA.MARSHAL;
+import org.omg.CORBA.portable.OutputStream;
+
+/**
+ * The helper operations for {@link DynFixed}. Following the 1.5 JDK
+ * specifications, DynFixed is always a local object, so the two methods of this
+ * helper ({@link #read} and {@link #write} are not in use, always throwing
+ * {@link MARSHAL}.
+ *
+ * @specnote always throwing MARSHAL in read and write ensures compatibility
+ * with other popular implementations like Sun's.
+ *
+ * @author Audrius Meskauskas, Lithuania (AudriusA@Bioinformatics.org)
+ */
+public abstract class DynFixedHelper
+{
+ /**
+ * Cast the passed object into the DynFixed. As DynFixed is a local object,
+ * the method just uses java type cast.
+ *
+ * @param obj the object to narrow.
+ * @return narrowed instance.
+ * @throws BAD_PARAM if the passed object is not a DynFixed.
+ */
+ public static DynFixed narrow(org.omg.CORBA.Object obj)
+ {
+ try
+ {
+ return (DynFixed) obj;
+ }
+ catch (ClassCastException cex)
+ {
+ throw new BAD_PARAM(obj.getClass().getName() + " is not a DynFixed");
+ }
+ }
+
+ /**
+ * Get the type code of the {@link DynFixed}.
+ */
+ public static TypeCode type()
+ {
+ return ORB.init().create_interface_tc(id(), "DynFixed");
+ }
+
+ /**
+ * Insert the DynFixed into the given Any.
+ *
+ * @param any the Any to insert into.
+ *
+ * @param that the DynFixed to insert.
+ */
+ public static void insert(Any any, DynFixed that)
+ {
+ any.insert_Object(that);
+ }
+
+ /**
+ * Extract the DynFixed from given Any.
+ *
+ * @throws BAD_OPERATION if the passed Any does not contain DynFixed.
+ */
+ public static DynFixed extract(Any any)
+ {
+ return narrow(any.extract_Object());
+ }
+
+ /**
+ * Get the DynFixed repository id.
+ *
+ * @return "IDL:omg.org/DynamicAny/DynFixed:1.0", always.
+ */
+ public static String id()
+ {
+ return "IDL:omg.org/DynamicAny/DynFixed:1.0";
+ }
+
+ /**
+ * This should read DynFixed from the CDR input stream, but (following the JDK
+ * 1.5 API) it does not.
+ *
+ * @param input a org.omg.CORBA.portable stream to read from.
+ *
+ * @specenote Sun throws the same exception.
+ *
+ * @throws MARSHAL always.
+ */
+ public static DynFixed read(InputStream input)
+ {
+ throw new MARSHAL(DynAnyFactoryHelper.not_applicable(id()));
+ }
+
+ /**
+ * This should read DynFixed from the CDR input stream, but (following the JDK
+ * 1.5 API) it does not.
+ *
+ * @param input a org.omg.CORBA.portable stream to read from.
+ *
+ * @specenote Sun throws the same exception.
+ *
+ * @throws MARSHAL always.
+ */
+ public static void write(OutputStream output, DynFixed value)
+ {
+ throw new MARSHAL(DynAnyFactoryHelper.not_applicable(id()));
+ }
+}
\ No newline at end of file
--- /dev/null
+/* DynFixedOperations.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., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 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.DynamicAny;
+
+import org.omg.DynamicAny.DynAnyPackage.InvalidValue;
+import org.omg.DynamicAny.DynAnyPackage.TypeMismatch;
+
+/**
+ * Defines operations, applicable for DynAny, holding CORBA <code>fixed</code>.
+ * These operations take and return this data type in its string representation.
+ *
+ * @author Audrius Meskauskas, Lithuania (AudriusA@Bioinformatics.org)
+ */
+public interface DynFixedOperations
+ extends DynAnyOperations
+{
+ /**
+ * Get the value of the enclosed DynFixed, as string.
+ */
+ String get_value();
+
+ /**
+ * Set the value of the enclosed DynFixed, from string.
+ *
+ * @param fixed_value the value to set.
+ *
+ * @throws TypeMismatch if the passed string cannot be parsed into CORBA
+ * <code>fixed</code>. The valid string can only contain digits, decimal
+ * point and optional leading and trailing whitespace.
+ *
+ * @return true if the passed value can be represented without the loss of
+ * precision, false if some fractional digits were truncated.
+ */
+ boolean set_value(String fixed_value)
+ throws TypeMismatch, InvalidValue;
+}
--- /dev/null
+/* DynSequence.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., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 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.DynamicAny;
+
+import java.io.Serializable;
+
+import org.omg.CORBA.portable.IDLEntity;
+
+/**
+ * Defines a dynamic resizeable array with the optional upper size bound. All
+ * elements in this structure have the same type.
+ *
+ * @author Audrius Meskauskas, Lithuania (AudriusA@Bioinformatics.org)
+ */
+public interface DynSequence
+ extends DynSequenceOperations, DynAny, IDLEntity, org.omg.CORBA.Object,
+ Serializable
+{
+}
--- /dev/null
+/* DynSequenceHelper.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., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 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.DynamicAny;
+
+import org.omg.CORBA.BAD_PARAM;
+import org.omg.CORBA.TypeCode;
+import org.omg.CORBA.ORB;
+import org.omg.CORBA.Any;
+import org.omg.CORBA.portable.InputStream;
+import org.omg.CORBA.MARSHAL;
+import org.omg.CORBA.portable.OutputStream;
+
+/**
+ * The helper operations for {@link DynSequence}. Following the 1.5 JDK
+ * specifications, DynSequence is always a local object, so the two methods of
+ * this helper ({@link #read} and {@link #write} are not in use, always
+ * throwing {@link MARSHAL}.
+ *
+ * @specnote always throwing MARSHAL in read and write ensures compatibility
+ * with other popular implementations like Sun's.
+ *
+ * @author Audrius Meskauskas, Lithuania (AudriusA@Bioinformatics.org)
+ */
+public abstract class DynSequenceHelper
+{
+ /**
+ * Cast the passed object into the DynSequence. As DynSequence is a local
+ * object, the method just uses java type cast.
+ *
+ * @param obj the object to narrow.
+ * @return narrowed instance.
+ * @throws BAD_PARAM if the passed object is not a DynSequence.
+ */
+ public static DynSequence narrow(org.omg.CORBA.Object obj)
+ {
+ try
+ {
+ return (DynSequence) obj;
+ }
+ catch (ClassCastException cex)
+ {
+ throw new BAD_PARAM(obj.getClass().getName() + " is not a DynSequence");
+ }
+ }
+
+ /**
+ * Get the type code of the {@link DynSequence}.
+ */
+ public static TypeCode type()
+ {
+ return ORB.init().create_interface_tc(id(), "DynSequence");
+ }
+
+ /**
+ * Insert the DynSequence into the given Any.
+ *
+ * @param any the Any to insert into.
+ *
+ * @param that the DynSequence to insert.
+ */
+ public static void insert(Any any, DynSequence that)
+ {
+ any.insert_Object(that);
+ }
+
+ /**
+ * Extract the DynSequence from given Any.
+ *
+ * @throws BAD_OPERATION if the passed Any does not contain DynSequence.
+ */
+ public static DynSequence extract(Any any)
+ {
+ return narrow(any.extract_Object());
+ }
+
+ /**
+ * Get the DynSequence repository id.
+ *
+ * @return "IDL:omg.org/DynamicAny/DynSequence:1.0", always.
+ */
+ public static String id()
+ {
+ return "IDL:omg.org/DynamicAny/DynSequence:1.0";
+ }
+
+ /**
+ * This should read DynSequence from the CDR input stream, but (following the
+ * JDK 1.5 API) it does not.
+ *
+ * @param input a org.omg.CORBA.portable stream to read from.
+ *
+ * @specenote Sun throws the same exception.
+ *
+ * @throws MARSHAL always.
+ */
+ public static DynSequence read(InputStream input)
+ {
+ throw new MARSHAL(DynAnyFactoryHelper.not_applicable(id()));
+ }
+
+ /**
+ * This should read DynSequence from the CDR input stream, but (following the
+ * JDK 1.5 API) it does not.
+ *
+ * @param input a org.omg.CORBA.portable stream to read from.
+ *
+ * @specenote Sun throws the same exception.
+ *
+ * @throws MARSHAL always.
+ */
+ public static void write(OutputStream output, DynSequence value)
+ {
+ throw new MARSHAL(DynAnyFactoryHelper.not_applicable(id()));
+ }
+}
\ No newline at end of file
--- /dev/null
+/* DynSequenceOperations.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., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 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.DynamicAny;
+
+import org.omg.CORBA.Any;
+import org.omg.DynamicAny.DynAnyPackage.InvalidValue;
+import org.omg.DynamicAny.DynAnyPackage.TypeMismatch;
+
+/**
+ * Defines operations, applicable to DynSequence. These are basically the same
+ * operations as for {@link DynArrayOperations} with additional possibility to
+ * change the length of the sequence. If the
+ * {@link org.omg.CORBA.TypeCode#length()} method of the sequence typecode
+ * returns positive value, it is treated as a sequence bound. An attempt to
+ * extend the sequence above its bound raises {@link InvalidValue}.
+ *
+ * @author Audrius Meskauskas, Lithuania (AudriusA@Bioinformatics.org)
+ */
+public interface DynSequenceOperations
+ extends DynAnyOperations
+{
+ /**
+ * Get the length of the sequence.
+ *
+ * @return the current sequence length that was taken from typecode or changed
+ * with set_length.
+ */
+ int get_length();
+
+ /**
+ * Set the length of the sequence. If the sequence is shortened, the tailing
+ * members are discarded, but the remaining content is not affected. If the
+ * new length is larger than the previous one, the new members are added to
+ * the end of the sequence. These new members are initialised to they default
+ * values.
+ *
+ * @param length the new length of the sequence.
+ *
+ * @throws InvalidValue if this is a bounded sequence, and the size being set
+ * exceeds the sequence bound.
+ */
+ public void set_length(int length)
+ throws InvalidValue;
+
+ /**
+ * Returns the array, containing the sequence elements.
+ *
+ * @return the array of elements as an array of DynAny's.
+ */
+ DynAny[] get_elements_as_dyn_any();
+
+ /**
+ * Returns the array, containing the sequence elements.
+ *
+ * @return the array of elements as an array of Any's.
+ */
+ Any[] get_elements();
+
+ /**
+ * Sets the sequence elements from the array. The length of the sequence is
+ * set to the length of the passed array.
+ *
+ * @param value the array of elements an DynAny's.
+ *
+ * @throws TypeMismatch if the members of the passed array does not match
+ * sequence component type.
+ *
+ * @throws InvalidValue if this is a bounded sequence and the number of
+ * elements in the passed array exceeds the sequence bound.
+ */
+ void set_elements_as_dyn_any(DynAny[] value)
+ throws TypeMismatch, InvalidValue;
+
+ /**
+ * Sets the sequence elements from the array. The length of the sequence is
+ * set to the length of the passed array.
+ *
+ * @param value the array of elements as Any's.
+ *
+ *
+ * @throws TypeMismatch if the members of the passed array does not match
+ * sequence component type.
+ *
+ * @throws InvalidValue if this is a bounded sequence and the number of
+ * elements in the passed array exceeds the sequence bound.
+ */
+ void set_elements(Any[] value)
+ throws TypeMismatch, InvalidValue;
+}
--- /dev/null
+/* DynStruct.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., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 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.DynamicAny;
+
+import java.io.Serializable;
+
+import org.omg.CORBA.portable.IDLEntity;
+
+/**
+ * Defines a fixed size structure with the named fields that may have different
+ * types.
+ *
+ * @author Audrius Meskauskas, Lithuania (AudriusA@Bioinformatics.org)
+ */
+public interface DynStruct
+ extends DynStructOperations, DynAny, IDLEntity, org.omg.CORBA.Object,
+ Serializable
+{
+}
--- /dev/null
+/* DynStructHelper.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., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 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.DynamicAny;
+
+import org.omg.CORBA.BAD_PARAM;
+import org.omg.CORBA.TypeCode;
+import org.omg.CORBA.ORB;
+import org.omg.CORBA.Any;
+import org.omg.CORBA.portable.InputStream;
+import org.omg.CORBA.MARSHAL;
+import org.omg.CORBA.portable.OutputStream;
+
+/**
+ * The helper operations for {@link DynStruct}. Following the 1.5 JDK
+ * specifications, DynStruct is always a local object, so the two methods of
+ * this helper ({@link #read} and {@link #write} are not in use, always
+ * throwing {@link MARSHAL}.
+ *
+ * @specnote always throwing MARSHAL in read and write ensures compatibility
+ * with other popular implementations like Sun's.
+ *
+ * @author Audrius Meskauskas, Lithuania (AudriusA@Bioinformatics.org)
+ */
+public abstract class DynStructHelper
+{
+ /**
+ * Cast the passed object into the DynStruct. As DynStruct is a local object,
+ * the method just uses java type cast.
+ *
+ * @param obj the object to narrow.
+ * @return narrowed instance.
+ * @throws BAD_PARAM if the passed object is not a DynStruct.
+ */
+ public static DynStruct narrow(org.omg.CORBA.Object obj)
+ {
+ try
+ {
+ return (DynStruct) obj;
+ }
+ catch (ClassCastException cex)
+ {
+ throw new BAD_PARAM(obj.getClass().getName() + " is not a DynStruct");
+ }
+ }
+
+ /**
+ * Get the type code of the {@link DynStruct}.
+ */
+ public static TypeCode type()
+ {
+ return ORB.init().create_interface_tc(id(), "DynStruct");
+ }
+
+ /**
+ * Insert the DynStruct into the given Any.
+ *
+ * @param any the Any to insert into.
+ *
+ * @param that the DynStruct to insert.
+ */
+ public static void insert(Any any, DynStruct that)
+ {
+ any.insert_Object(that);
+ }
+
+ /**
+ * Extract the DynStruct from given Any.
+ *
+ * @throws BAD_OPERATION if the passed Any does not contain DynStruct.
+ */
+ public static DynStruct extract(Any any)
+ {
+ return narrow(any.extract_Object());
+ }
+
+ /**
+ * Get the DynStruct repository id.
+ *
+ * @return "IDL:omg.org/DynamicAny/DynStruct:1.0", always.
+ */
+ public static String id()
+ {
+ return "IDL:omg.org/DynamicAny/DynStruct:1.0";
+ }
+
+ /**
+ * This should read DynStruct from the CDR input stream, but (following the
+ * JDK 1.5 API) it does not.
+ *
+ * @param input a org.omg.CORBA.portable stream to read from.
+ *
+ * @specenote Sun throws the same exception.
+ *
+ * @throws MARSHAL always.
+ */
+ public static DynStruct read(InputStream input)
+ {
+ throw new MARSHAL(DynAnyFactoryHelper.not_applicable(id()));
+ }
+
+ /**
+ * This should read DynStruct from the CDR input stream, but (following the
+ * JDK 1.5 API) it does not.
+ *
+ * @param input a org.omg.CORBA.portable stream to read from.
+ *
+ * @specenote Sun throws the same exception.
+ *
+ * @throws MARSHAL always.
+ */
+ public static void write(OutputStream output, DynStruct value)
+ {
+ throw new MARSHAL(DynAnyFactoryHelper.not_applicable(id()));
+ }
+}
\ No newline at end of file
--- /dev/null
+/* DynStructOperations.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., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 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.DynamicAny;
+
+import org.omg.CORBA.TCKind;
+import org.omg.DynamicAny.DynAnyPackage.InvalidValue;
+import org.omg.DynamicAny.DynAnyPackage.TypeMismatch;
+
+/**
+ * Defines the operations, applicable to the DynStructure.
+ *
+ * @author Audrius Meskauskas, Lithuania (AudriusA@Bioinformatics.org)
+ */
+public interface DynStructOperations
+ extends DynAnyOperations
+{
+ /**
+ * Get the kind of the structure field at the current position.
+ *
+ * @return the kind of field.
+ *
+ * @throws TypeMismatch for an empty structure (normally exception).
+ * @throws InvalidValue if the current position does not indicate a memeber.
+ */
+ TCKind current_member_kind()
+ throws TypeMismatch, InvalidValue;
+
+ /**
+ * Get the name of the structure field at the current position.
+ *
+ * @return the name of the field.
+ *
+ * @throws TypeMismatch for an empty structure (normally exception).
+ * @throws InvalidValue if the current position does not indicate a memeber.
+ */
+ String current_member_name()
+ throws TypeMismatch, InvalidValue;
+
+ /**
+ * Return array, describing describing the name and the value of each member
+ * in the structure.
+ *
+ * @return an array of NameDynAnyPair's, each defining a single field in this
+ * structure.
+ */
+ NameDynAnyPair[] get_members_as_dyn_any();
+
+ /**
+ * Return array, describing describing the name and the value of each member
+ * in the structure.
+ *
+ * @return an array of NameValuePair's, each defining a single field in this
+ * structure.
+ */
+ NameValuePair[] get_members();
+
+ /**
+ * Set the structure contend from the array, where each member defines the
+ * name and value of the structure field. If the passed array is not empty,
+ * the current position is set to the first member.
+ *
+ * The members of array must follow in the same order as the structure fields,
+ * how they are defined in the typecode. The name-based value assignment is
+ * not supported.
+ *
+ * @specnote The name-based value assignment is not supported by Sun's jdk
+ * 1.4.
+ *
+ * @param an array of NameDynValuePair's, each defining a single field in the
+ * structure.
+ *
+ * @throws TypeMismatch if the member of the passed array has a different type
+ * than the corresponding structure field.
+ *
+ * @throws InvalidValue if the size of the passed array is not the same as the
+ * number of fields in this structure.
+ */
+ void set_members_as_dyn_any(NameDynAnyPair[] value)
+ throws TypeMismatch, InvalidValue;
+
+ /**
+ * Set the structure contend from the array, where each member defines the
+ * name and value of the structure field. If the passed array is not empty,
+ * the current position is set to the first member.
+ *
+ * The members of array must follow in the same order as the structure fields,
+ * how they are defined in the typecode. The name-based value assignment is
+ * not supported.
+ *
+ * @specnote The name-based value assignment is not supported by Sun's jdk
+ * 1.4.
+ *
+ * @param an array of NameValuePair's, each defining a single field in the
+ * structure.
+ *
+ * @throws TypeMismatch if the member of the passed array has a different type
+ * than the corresponding structure field.
+ *
+ * @throws InvalidValue if the size of the passed array is not the same as the
+ * number of fields in this structure.
+ */
+ void set_members(NameValuePair[] value)
+ throws TypeMismatch, InvalidValue;
+
+}
--- /dev/null
+/* DynUnion.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., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 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.DynamicAny;
+
+import java.io.Serializable;
+
+import org.omg.CORBA.portable.IDLEntity;
+
+/**
+ * Defines a fixed size structure with the named fields that may have different
+ * types.
+ *
+ * @author Audrius Meskauskas, Lithuania (AudriusA@Bioinformatics.org)
+ */
+public interface DynUnion
+ extends DynUnionOperations, DynAny, IDLEntity, org.omg.CORBA.Object,
+ Serializable
+{
+}
--- /dev/null
+/* DynUnionHelper.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., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 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.DynamicAny;
+
+import org.omg.CORBA.BAD_PARAM;
+import org.omg.CORBA.TypeCode;
+import org.omg.CORBA.ORB;
+import org.omg.CORBA.Any;
+import org.omg.CORBA.portable.InputStream;
+import org.omg.CORBA.MARSHAL;
+import org.omg.CORBA.portable.OutputStream;
+
+/**
+ * The helper operations for {@link DynUnion}. Following the 1.5 JDK
+ * specifications, DynUnion is always a local object, so the two methods of this
+ * helper ({@link #read} and {@link #write} are not in use, always throwing
+ * {@link MARSHAL}.
+ *
+ * @specnote always throwing MARSHAL in read and write ensures compatibility
+ * with other popular implementations like Sun's.
+ *
+ * @author Audrius Meskauskas, Lithuania (AudriusA@Bioinformatics.org)
+ */
+public abstract class DynUnionHelper
+{
+ /**
+ * Cast the passed object into the DynUnion. As DynUnion is a local object,
+ * the method just uses java type cast.
+ *
+ * @param obj the object to narrow.
+ * @return narrowed instance.
+ * @throws BAD_PARAM if the passed object is not a DynUnion.
+ */
+ public static DynUnion narrow(org.omg.CORBA.Object obj)
+ {
+ try
+ {
+ return (DynUnion) obj;
+ }
+ catch (ClassCastException cex)
+ {
+ throw new BAD_PARAM(obj.getClass().getName() + " is not a DynUnion");
+ }
+ }
+
+ /**
+ * Get the type code of the {@link DynUnion}.
+ */
+ public static TypeCode type()
+ {
+ return ORB.init().create_interface_tc(id(), "DynUnion");
+ }
+
+ /**
+ * Insert the DynUnion into the given Any.
+ *
+ * @param any the Any to insert into.
+ *
+ * @param that the DynUnion to insert.
+ */
+ public static void insert(Any any, DynUnion that)
+ {
+ any.insert_Object(that);
+ }
+
+ /**
+ * Extract the DynUnion from given Any.
+ *
+ * @throws BAD_OPERATION if the passed Any does not contain DynUnion.
+ */
+ public static DynUnion extract(Any any)
+ {
+ return narrow(any.extract_Object());
+ }
+
+ /**
+ * Get the DynUnion repository id.
+ *
+ * @return "IDL:omg.org/DynamicAny/DynUnion:1.0", always.
+ */
+ public static String id()
+ {
+ return "IDL:omg.org/DynamicAny/DynUnion:1.0";
+ }
+
+ /**
+ * This should read DynUnion from the CDR input stream, but (following the JDK
+ * 1.5 API) it does not.
+ *
+ * @param input a org.omg.CORBA.portable stream to read from.
+ *
+ * @specenote Sun throws the same exception.
+ *
+ * @throws MARSHAL always.
+ */
+ public static DynUnion read(InputStream input)
+ {
+ throw new MARSHAL(DynAnyFactoryHelper.not_applicable(id()));
+ }
+
+ /**
+ * This should read DynUnion from the CDR input stream, but (following the JDK
+ * 1.5 API) it does not.
+ *
+ * @param input a org.omg.CORBA.portable stream to read from.
+ *
+ * @specenote Sun throws the same exception.
+ *
+ * @throws MARSHAL always.
+ */
+ public static void write(OutputStream output, DynUnion value)
+ {
+ throw new MARSHAL(DynAnyFactoryHelper.not_applicable(id()));
+ }
+}
\ No newline at end of file
--- /dev/null
+/* DynUnionOperations.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., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 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.DynamicAny;
+
+import org.omg.CORBA.TCKind;
+import org.omg.DynamicAny.DynAnyPackage.InvalidValue;
+import org.omg.DynamicAny.DynAnyPackage.TypeMismatch;
+
+/**
+ * Defines the operations, applicable to the DynUnion. The DynUnion has only two
+ * valid positions:
+ * <ul>
+ * <li>0 - contains the discriminator of the union. The discriminator defines,
+ * which of the union variants is currently active.</li>
+ * <li>1 - contains the currently active variant of the union content (a union
+ * member). </li>
+ * </ul>
+ * The size of the union is normally 2. If the discriminator value defines no
+ * valid variant, the union consists of discriminator only, having the size 1.
+ *
+ * @author Audrius Meskauskas, Lithuania (AudriusA@Bioinformatics.org)
+ */
+public interface DynUnionOperations
+ extends DynAnyOperations
+{
+ /**
+ * <p>Get the value of discriminator, defining which content variant
+ * (member) is active.
+ * </p><p>
+ * In the current implementation, the later changes on the returned value
+ * alter the state of the union via implemented internal listener.
+ * </p>
+ */
+ DynAny get_discriminator();
+
+ /**
+ * <p>Set the value of discriminator, activating the member variant that is
+ * consistent with the discriminator value. If the current member variant
+ * matches the discriminator being set, it is unchanged. Otherwise, it is
+ * replaced by the matching member variant with fields, initialised to default
+ * values. The current position is set to 0 if the discriminator value does
+ * not match any member variant. Otherwise, the current position is set to 1,
+ * index of the member variant.
+ * </p>
+ * @throws TypeMismatch if the discriminator has a wrong type of this union.
+ */
+ void set_discriminator(DynAny aDiscriminator)
+ throws TypeMismatch;
+
+ /**
+ * Get the kind of the union descriminator.
+ *
+ * @return the TCKind value of the discriminator typecode.
+ */
+ TCKind discriminator_kind();
+
+ /**
+ * Get the current variant of the union content.
+ *
+ * @return the current member of the union. This reference is only valid as
+ * long as the current member does not change.
+ *
+ * @throws InvalidValue if the union has no active member.
+ */
+ DynAny member()
+ throws InvalidValue;
+
+ /**
+ * Returns the kind of the currently active union member.
+ *
+ * @return the TCKind value of the union member.
+ *
+ * @throws InvalidValue if the union has no active member.
+ */
+ TCKind member_kind()
+ throws InvalidValue;
+
+ /**
+ * Returns the name of the currently active union member.
+ *
+ * @return the TCKind value of the union member.
+ *
+ * @throws InvalidValue if the union has no active member.
+ */
+ String member_name()
+ throws InvalidValue;
+
+ /**
+ * Returns true if the union has no active member. This happens if If the
+ * discriminator value defines no valid variant. Such union consists of
+ * discriminator only, having the size 1.
+ */
+ boolean has_no_active_member();
+
+ /**
+ * Set the discriminator to default value. The current position is set to 0.
+ * This also sets the content variant to the default variant, and the size of
+ * the union becomes 2.
+ *
+ * @throws TypeMismatch if the default case is not defined for this union.
+ */
+ void set_to_default_member()
+ throws TypeMismatch;
+
+ /**
+ * Set the discriminator to value that does not correspond any content variant
+ * (any union <code>case</code> label). The current position is set to 0.
+ * The size of the union becomes 0.
+ *
+ * @throws TypeMismatch if the union has explicit default case.
+ */
+ void set_to_no_active_member()
+ throws TypeMismatch;
+}
\ No newline at end of file
--- /dev/null
+/* 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., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 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.DynamicAny;
+
+import java.io.Serializable;
+
+import org.omg.CORBA.portable.IDLEntity;
+
+/**
+ * Defines a non boxed value type. From the view point of DynAny, the Value is
+ * very much like structure. The access to fields of this structer are supported
+ * via {@link DynValueOperations} interface.Unlike structure, the value can also
+ * be equal to <code>null</code> that is supported via
+ * {@link DynValueCommonOperations} interface.
+ *
+ * @author Audrius Meskauskas, Lithuania (AudriusA@Bioinformatics.org)
+ */
+public interface DynValue
+ extends DynValueOperations, DynValueCommon, DynAny, IDLEntity,
+ org.omg.CORBA.Object, Serializable
+{
+}
--- /dev/null
+/* DynValueBox.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., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 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.DynamicAny;
+
+import org.omg.CORBA.portable.IDLEntity;
+
+import java.io.Serializable;
+
+/**
+ * A "ValueBox" is a Value type container, holding a single instance of the
+ * other CORBA type. This content can be set to <code>null</code>.
+ *
+ * @author Audrius Meskauskas, Lithuania (AudriusA@Bioinformatics.org)
+ */
+public interface DynValueBox
+ extends DynValueBoxOperations, DynValueCommon, DynAny, IDLEntity,
+ org.omg.CORBA.Object, Serializable
+{
+}
\ No newline at end of file
--- /dev/null
+/* DynValueBoxOperation.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., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 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.DynamicAny;
+
+import org.omg.CORBA.Any;
+import org.omg.DynamicAny.DynAnyPackage.InvalidValue;
+import org.omg.DynamicAny.DynAnyPackage.TypeMismatch;
+
+/**
+ * Defines operations, applicable for the boxed value type.
+ *
+ * @author Audrius Meskauskas, Lithuania (AudriusA@Bioinformatics.org)
+ */
+public interface DynValueBoxOperations
+ extends DynValueCommonOperations, DynAnyOperations
+{
+ /**
+ * Get the return the content of the "box" as the DynAny.
+ *
+ * @throws InvalidValue if the object is holding <code>null</code>.
+ */
+ DynAny get_boxed_value_as_dyn_any()
+ throws InvalidValue;
+
+ /**
+ * Get the return the content of the "box" as the Any.
+ *
+ * @throws InvalidValue if the object is holding <code>null</code>.
+ */
+ Any get_boxed_value()
+ throws InvalidValue;
+
+ /**
+ * Set the value of the "box" from DynAny.
+ *
+ * @param boxIt a value to box.
+ *
+ * @throws TypeMismatch if the type is not matching the current boxed value
+ * type.
+ */
+ void set_boxed_value_as_dyn_any(DynAny boxIt)
+ throws TypeMismatch;
+
+ /**
+ * Set the value of the "box" as Any.
+ *
+ * @param boxIt a value to place into the box.
+ *
+ * @throws TypeMismatch if the type is not matching the current boxed value
+ * type.
+ */
+ void set_boxed_value(Any boxIt)
+ throws TypeMismatch;
+
+}
--- /dev/null
+/* DynValueCommon.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., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 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.DynamicAny;
+
+import org.omg.CORBA.portable.IDLEntity;
+
+import java.io.Serializable;
+
+/**
+ * Defines DynAny that may hold CORBA <code>null</code>. The
+ * {@link DynValueCommonOperations} provides methods for setting the value to
+ * <code>null</code> or non-<code>null</code> and checking if the value is
+ * <code>null</code>.
+ *
+ * @author Audrius Meskauskas, Lithuania (AudriusA@Bioinformatics.org)
+ */
+public interface DynValueCommon
+ extends DynValueCommonOperations, DynAny, IDLEntity, org.omg.CORBA.Object,
+ Serializable
+{
+ /**
+ * Check if this {@link DynAny} is holding the <code>null</code>.
+ *
+ * @return true if this {@link DynAny} is holding the <code>null</code>,
+ * false otherwise.
+ */
+ boolean is_null();
+
+ /**
+ * Set the value of this {@link DynAny} to CORBA <code>null</code>.
+ */
+ void set_to_null();
+
+ /**
+ * Set the value of this {@link DynAny} to the default non-null value. The
+ * target {@link DynAny} creates a new data structure, intialised to the
+ * agreed default values, as defined in {@link DynAnyFactoryOperations}.
+ */
+ void set_to_value();
+}
--- /dev/null
+/* DynValueCommonOperations.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., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 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.DynamicAny;
+
+/**
+ * Provides operations, applicable to {@link DynAny}s that may hold CORBA
+ * <code>null</code>.
+ *
+ * @author Audrius Meskauskas, Lithuania (AudriusA@Bioinformatics.org)
+ */
+public interface DynValueCommonOperations
+ extends DynAnyOperations
+{
+ /**
+ * Check if this {@link DynAny} is holding the <code>null</code>.
+ *
+ * @return true if this {@link DynAny} is holding the <code>null</code>,
+ * false otherwise.
+ */
+ boolean is_null();
+
+ /**
+ * Set the value of this {@link DynAny} to CORBA <code>null</code>.
+ */
+ void set_to_null();
+
+ /**
+ * Set the value of this {@link DynAny} to the default non-null value. The
+ * target {@link DynAny} creates a new data structure, intialised to the
+ * agreed default values, as defined in {@link DynAnyFactoryOperations}.
+ */
+ void set_to_value();
+}
--- /dev/null
+/* DynValueHelper.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., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 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.DynamicAny;
+
+import org.omg.CORBA.BAD_PARAM;
+import org.omg.CORBA.TypeCode;
+import org.omg.CORBA.ORB;
+import org.omg.CORBA.Any;
+import org.omg.CORBA.portable.InputStream;
+import org.omg.CORBA.MARSHAL;
+import org.omg.CORBA.portable.OutputStream;
+
+/**
+ * The helper operations for {@link DynValue}. Following the 1.5 JDK
+ * specifications, DynValue is always a local object, so the two methods of this
+ * helper ({@link #read} and {@link #write} are not in use, always throwing
+ * {@link MARSHAL}.
+ *
+ * @specnote always throwing MARSHAL in read and write ensures compatibility
+ * with other popular implementations like Sun's.
+ *
+ * @author Audrius Meskauskas, Lithuania (AudriusA@Bioinformatics.org)
+ */
+public abstract class DynValueHelper
+{
+ /**
+ * Cast the passed object into the DynValue. As DynValue is a local object,
+ * the method just uses java type cast.
+ *
+ * @param obj the object to narrow.
+ * @return narrowed instance.
+ * @throws BAD_PARAM if the passed object is not a DynValue.
+ */
+ public static DynValue narrow(org.omg.CORBA.Object obj)
+ {
+ try
+ {
+ return (DynValue) obj;
+ }
+ catch (ClassCastException cex)
+ {
+ throw new BAD_PARAM(obj.getClass().getName() + " is not a DynValue");
+ }
+ }
+
+ /**
+ * Get the type code of the {@link DynValue}.
+ */
+ public static TypeCode type()
+ {
+ return ORB.init().create_interface_tc(id(), "DynValue");
+ }
+
+ /**
+ * Insert the DynValue into the given Any.
+ *
+ * @param any the Any to insert into.
+ *
+ * @param that the DynValue to insert.
+ */
+ public static void insert(Any any, DynValue that)
+ {
+ any.insert_Object(that);
+ }
+
+ /**
+ * Extract the DynValue from given Any.
+ *
+ * @throws BAD_OPERATION if the passed Any does not contain DynValue.
+ */
+ public static DynValue extract(Any any)
+ {
+ return narrow(any.extract_Object());
+ }
+
+ /**
+ * Get the DynValue repository id.
+ *
+ * @return "IDL:omg.org/DynamicAny/DynValue:1.0", always.
+ */
+ public static String id()
+ {
+ return "IDL:omg.org/DynamicAny/DynValue:1.0";
+ }
+
+ /**
+ * This should read DynValue from the CDR input stream, but (following the JDK
+ * 1.5 API) it does not.
+ *
+ * @param input a org.omg.CORBA.portable stream to read from.
+ *
+ * @specenote Sun throws the same exception.
+ *
+ * @throws MARSHAL always.
+ */
+ public static DynValue read(InputStream input)
+ {
+ throw new MARSHAL(DynAnyFactoryHelper.not_applicable(id()));
+ }
+
+ /**
+ * This should read DynValue from the CDR input stream, but (following the JDK
+ * 1.5 API) it does not.
+ *
+ * @param input a org.omg.CORBA.portable stream to read from.
+ *
+ * @specenote Sun throws the same exception.
+ *
+ * @throws MARSHAL always.
+ */
+ public static void write(OutputStream output, DynValue value)
+ {
+ throw new MARSHAL(DynAnyFactoryHelper.not_applicable(id()));
+ }
+}
\ No newline at end of file
--- /dev/null
+/* DynValueOperations.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., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 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.DynamicAny;
+
+import org.omg.CORBA.TCKind;
+import org.omg.DynamicAny.DynAnyPackage.InvalidValue;
+import org.omg.DynamicAny.DynAnyPackage.TypeMismatch;
+
+/**
+ * Defines operations, applicable to DynValue. From the view point of DynAny,
+ * the Value is very much like structure. However, differently from the
+ * structure, the value type can also have private members. The private members
+ * of DynValue are also accessible via this interface, but this possibility
+ * should only be used in applications like in debuggers or inter-orb bridges.
+ * Unlike structure, the value can also be equal to <code>null</code>.
+ *
+ * @author Audrius Meskauskas, Lithuania (AudriusA@Bioinformatics.org)
+ */
+public interface DynValueOperations
+ extends DynAnyOperations, DynValueCommonOperations
+{
+ /**
+ * Get the kind of the current member.
+ *
+ * @return the kind of member at the current position.
+ *
+ * @throws TypeMismatch if this DynValue is holding <code>null</code>.
+ * @thorws InvalidValue if the current position does not indicate the member.
+ */
+ TCKind current_member_kind()
+ throws TypeMismatch, InvalidValue;
+
+ /**
+ * Get the name of the current member.
+ *
+ * @return the name of the current member as defined by the typecode. May be
+ * an empty string.
+ *
+ * @throws TypeMismatch if this DynValue is holding <code>null</code>.
+ * @thorws InvalidValue if the current position does not indicate the member.
+ */
+ String current_member_name()
+ throws TypeMismatch, InvalidValue;
+
+ /**
+ * Get all members as an array of the named DynAny's. The returned names are
+ * set as they are defined by typecode.
+ *
+ * @return the array, representing the members of this instance of value.
+ *
+ * @throws InvalidValue if this DynValue is holding <code>null</code>.
+ */
+ NameDynAnyPair[] get_members_as_dyn_any()
+ throws InvalidValue;
+
+ /**
+ * Get all members as an array of the named Any's. The returned names are set
+ * as they are defined by typecode.
+ *
+ * @return the array, representing the members of this instance of value.
+ *
+ * @throws InvalidValue if this DynValue is holding <code>null</code>.
+ */
+ NameValuePair[] get_members()
+ throws InvalidValue;
+
+ /**
+ * Set all members from the array of the named Any's.
+ *
+ * @param value the array, where the data for fields of the structure must
+ * occur exactly in the same order, as defined by typecode.
+ *
+ * @throws TypeMismatch if the type or name of the array member does not match
+ * the name and type of the corresponding field in the DynValue data
+ * structure. The empty string is assumed matching any name.
+ *
+ * @throws InvalidValue if the size of the array does not match the number of
+ * fields.
+ */
+ void set_members_as_dyn_any(NameDynAnyPair[] value)
+ throws TypeMismatch, InvalidValue;
+
+ /**
+ * Set all members from the array of the named Any's.
+ *
+ * @param value the array, where the data for fields of the structure must
+ * occur exactly in the same order, as defined by typecode.
+ *
+ * @throws TypeMismatch if the type or name of the array member does not match
+ * the name and type of the corresponding field in the DynValue data
+ * structure. The empty string is assumed matching any name.
+ *
+ * @throws InvalidValue if the size of the array does not match the number of
+ * fields.
+ */
+ void set_members(NameValuePair[] value)
+ throws TypeMismatch, InvalidValue;
+}
--- /dev/null
+/* 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., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 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.DynamicAny;
+
+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 helper for the FieldName. The fields {@link NameValuePair#id},
+ * {@link NameDynAnyPair#id} and return values of methods
+ * <code>current_member_name()</code>, <code>member_name()</code> in several
+ * interfaces officially have the "FieldName" type. This type is directly
+ * mapped into java String and needs no helper. The helper
+ * is included only as a part of the formal standard.
+ *
+ * @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 alias typecode.
+ */
+ 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/DynamicAny/FieldName:1.0", always.
+ */
+ public static String id()
+ {
+ return "IDL:omg.org/DynamicAny/FieldName: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 (FieldName) value to write.
+ */
+ public static void write(OutputStream ostream, String value)
+ {
+ ostream.write_string(value);
+ }
+}
\ No newline at end of file
--- /dev/null
+/* NameDynAnyPair.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., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 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.DynamicAny;
+
+import org.omg.CORBA.portable.IDLEntity;
+
+import java.io.Serializable;
+
+/**
+ * Stores the named value, representing the name by string and the value by
+ * {@link DynAny}.
+ *
+ * @author Audrius Meskauskas, Lithuania (AudriusA@Bioinformatics.org)
+ */
+public final class NameDynAnyPair
+ implements IDLEntity, Serializable
+{
+ /**
+ * Use serialVersionUID (v1.4) for interoperability.
+ */
+ private static final long serialVersionUID = -1992533286932908564L;
+
+ /**
+ * The name of the named value.
+ */
+ public String id;
+
+ /**
+ * The value of the named value.
+ */
+ public DynAny value;
+
+ /**
+ * Create unitialised instance with both fields left with default
+ * <code>null</code> value.
+ */
+ public NameDynAnyPair()
+ {
+ }
+
+ /**
+ * Create an instance with the given initial values.
+ *
+ * @param aName the name of the named value.
+ * @param aValue the value of the named value.
+ */
+ public NameDynAnyPair(String aName, DynAny aValue)
+ {
+ id = aName;
+ value = aValue;
+ }
+}
--- /dev/null
+/* NameDynAnyPairHelper.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., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 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.DynamicAny;
+
+import gnu.CORBA.NameDynAnyPairHolder;
+
+import org.omg.CORBA.Any;
+import org.omg.CORBA.BAD_OPERATION;
+import org.omg.CORBA.MARSHAL;
+import org.omg.CORBA.ORB;
+import org.omg.CORBA.StructMember;
+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 the structure {@link NameDynAnyPair}.
+ *
+ * Following the 1.5 JDK specifications, DynAny (and hence any structure,
+ * containing DynAny) is always a local object, so the two methods of this
+ * helper ({@link #read} and {@link #write} are not in use, always throwing
+ * {@link MARSHAL}.
+ *
+ * @author Audrius Meskauskas, Lithuania (AudriusA@Bioinformatics.org)
+ */
+public abstract class NameDynAnyPairHelper
+{
+ /**
+ * The cached typecode value, computed only once.
+ */
+ private static TypeCode typeCode;
+
+ /**
+ * Extract the NameDynAnyPair from given Any.
+ * This method uses the NameDynAnyPairHolder.
+ *
+ * @throws BAD_OPERATION if the passed Any does not contain NameDynAnyPair.
+ */
+ public static NameDynAnyPair extract(Any any)
+ {
+ try
+ {
+ return ((NameDynAnyPairHolder) any.extract_Streamable()).value;
+ }
+ catch (ClassCastException cex)
+ {
+ BAD_OPERATION bad = new BAD_OPERATION("NameDynAnyPair expected");
+ bad.initCause(cex);
+ throw bad;
+ }
+ }
+
+ /**
+ * Get the NameDynAnyPair repository id.
+ *
+ * @return "IDL:omg.org/DynamicAny/NameDynAnyPair:1.0", always.
+ */
+ public static String id()
+ {
+ return "IDL:omg.org/DynamicAny/NameDynAnyPair:1.0";
+ }
+
+ /**
+ * Create the NameDynAnyPair typecode (structure,
+ * named "NameDynAnyPair").
+ * The typecode states that the structure contains the
+ * following fields: id, value.
+ */
+ public static TypeCode type()
+ {
+ if (typeCode == null)
+ {
+ ORB orb = ORB.init();
+ StructMember[] members = new StructMember[ 2 ];
+
+ TypeCode field;
+
+ field =
+ orb.create_alias_tc("IDL:omg.org/DynamicAny/FieldName:1.0",
+ "FieldName",
+ orb.get_primitive_tc(TCKind.tk_string)
+ );
+ members [ 0 ] = new StructMember("id", field, null);
+
+ field = DynAnyHelper.type();
+ members [ 1 ] = new StructMember("value", field, null);
+ typeCode = orb.create_struct_tc(id(), "NameDynAnyPair", members);
+ }
+ return typeCode;
+ }
+
+ /**
+ * Insert the NameDynAnyPair into the given Any.
+ * This method uses the NameDynAnyPairHolder.
+ *
+ * @param any the Any to insert into.
+ * @param that the NameDynAnyPair to insert.
+ */
+ public static void insert(Any any, NameDynAnyPair that)
+ {
+ any.insert_Streamable(new NameDynAnyPairHolder(that));
+ }
+
+ /**
+ * The method should read this object from the CDR input stream, but
+ * (following the JDK 1.5 API) it does not.
+ *
+ * @param input a org.omg.CORBA.portable stream to read from.
+ *
+ * @specenote Sun throws the same exception.
+ *
+ * @throws MARSHAL always.
+ */
+ public static NameDynAnyPair read(InputStream input)
+ {
+ throw new MARSHAL(DynAnyFactoryHelper.not_applicable(id()));
+ }
+
+ /**
+ * The method should write this object to the CDR input stream, but
+ * (following the JDK 1.5 API) it does not.
+ *
+ * @param input a org.omg.CORBA.portable stream to read from.
+ *
+ * @specenote Sun throws the same exception.
+ *
+ * @throws MARSHAL always.
+ */
+ public static void write(OutputStream output, NameDynAnyPair value)
+ {
+ throw new MARSHAL(DynAnyFactoryHelper.not_applicable(id()));
+ }
+}
\ No newline at end of file
--- /dev/null
+/* NameDynAnyPairSeq.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., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 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.DynamicAny;
+
+import gnu.CORBA.NameDynAnyPairSeqHolder;
+
+import org.omg.CORBA.Any;
+import org.omg.CORBA.BAD_OPERATION;
+import org.omg.CORBA.MARSHAL;
+import org.omg.CORBA.ORB;
+import org.omg.CORBA.TypeCode;
+import org.omg.CORBA.portable.InputStream;
+import org.omg.CORBA.portable.OutputStream;
+
+/**
+ * A helper operations for the array of {@link NameDynAnyPair}
+ * ({@link NameDynAnyPairSeq}).
+ *
+ * Following the 1.5 JDK specifications, DynAny (and hence the sequence
+ * of structures, containing DynAny) is always a local object.
+ * Hence the two methods of this helper ({@link #read} and {@link #write} are
+ * not in use, always throwing {@link MARSHAL}.
+ *
+ * @author Audrius Meskauskas, Lithuania (AudriusA@Bioinformatics.org)
+ */
+public abstract class NameDynAnyPairSeqHelper
+{
+ /**
+ * The cached typecode value, computed only once.
+ */
+ private static TypeCode typeCode;
+
+ public static TypeCode type()
+ {
+ if (typeCode == null)
+ {
+ ORB orb = ORB.init();
+ TypeCode t = orb.create_sequence_tc(0, NameDynAnyPairHelper.type());
+ typeCode = orb.create_alias_tc(id(), "NameDynAnyPairSeq", t);
+ }
+ return typeCode;
+ }
+
+ /**
+ * Insert the NameDynAnyPairSeq into the given Any.
+ * This method uses the NameDynAnyPairSeqHolder.
+ *
+ * @param any the Any to insert into.
+ * @param those the NameDynAnyPair[] to insert.
+ */
+ public static void insert(Any any, NameDynAnyPair[] those)
+ {
+ any.insert_Streamable(new NameDynAnyPairSeqHolder(those));
+ }
+
+ /**
+ * Extract the NameDynAnyPairSeq from given Any.
+ * This method uses the NameDynAnyPairSeqHolder.
+ *
+ * @throws BAD_OPERATION if the passed Any does not contain NameDynAnyPairSeq.
+ */
+ public static NameDynAnyPair[] extract(Any any)
+ {
+ try
+ {
+ return ((NameDynAnyPairSeqHolder) any.extract_Streamable()).value;
+ }
+ catch (ClassCastException cex)
+ {
+ BAD_OPERATION bad = new BAD_OPERATION("NameDynAnyPairSeq expected");
+ bad.initCause(cex);
+ throw bad;
+ }
+ }
+
+ /**
+ * Get the NameDynAnyPairSeq repository id.
+ *
+ * @return "IDL:omg.org/DynamicAny/NameDynAnyPairSeq:1.0", always.
+ */
+ public static String id()
+ {
+ return "IDL:omg.org/DynamicAny/NameDynAnyPairSeq:1.0";
+ }
+
+ /**
+ * The method should read this object from the CDR input stream, but
+ * (following the JDK 1.5 API) it does not.
+ *
+ * @param input a org.omg.CORBA.portable stream to read from.
+ *
+ * @specenote Sun throws the same exception.
+ *
+ * @throws MARSHAL always.
+ */
+ public static NameDynAnyPair[] read(InputStream input)
+ {
+ throw new MARSHAL(DynAnyFactoryHelper.not_applicable(id()));
+ }
+
+ /**
+ * The method should write this object to the CDR input stream, but
+ * (following the JDK 1.5 API) it does not.
+ *
+ * @param input a org.omg.CORBA.portable stream to read from.
+ *
+ * @specenote Sun throws the same exception.
+ *
+ * @throws MARSHAL always.
+ */
+ public static void write(OutputStream output, NameDynAnyPair[] value)
+ {
+ throw new MARSHAL(DynAnyFactoryHelper.not_applicable(id()));
+ }
+}
\ No newline at end of file
--- /dev/null
+/* NameValuePair.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., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 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.DynamicAny;
+
+import org.omg.CORBA.Any;
+import org.omg.CORBA.DynStruct;
+import org.omg.CORBA.portable.IDLEntity;
+
+import java.io.Serializable;
+
+/**
+ * Holds the value, having the given name(id). This class is used by with
+ * {@link DynStruct} to name the fields of the record (structure).
+ *
+ * @author Audrius Meskauskas, Lithuania (AudriusA@Bioinformatics.org)
+ */
+public final class NameValuePair
+ implements Serializable, IDLEntity
+{
+ /**
+ * Use serialVersionUID (v1.4) for interoperability.
+ */
+ private static final long serialVersionUID = -1289460542874201736L;
+
+ /**
+ * The value of the structure record.
+ */
+ public Any value;
+
+ /**
+ * The name of the structure record.
+ */
+ public String id;
+
+ /**
+ * Cretes an unitialised instance of the name-value pair.
+ */
+ public NameValuePair()
+ {
+ }
+
+ /**
+ * Creates the name-value pair, initialising the fields to the passed values.
+ *
+ * @param aName the name (also called id) of the name-value pair, normally the
+ * name of the structure field.
+ *
+ * @param aValue the value of the name-value pair.
+ */
+ public NameValuePair(String aName, Any aValue)
+ {
+ id = aName;
+ value = aValue;
+ }
+}
\ No newline at end of file
--- /dev/null
+/* NameValuePairHelper.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., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 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.DynamicAny;
+
+import gnu.CORBA.NameValuePairHolder;
+
+import org.omg.CORBA.Any;
+import org.omg.CORBA.BAD_OPERATION;
+import org.omg.CORBA.ORB;
+import org.omg.CORBA.StructMember;
+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 the structure {@link NameValuePair}.
+ *
+ * @author Audrius Meskauskas, Lithuania (AudriusA@Bioinformatics.org)
+ */
+public abstract class NameValuePairHelper
+{
+ /**
+ * The cached typecode value, computed only once.
+ */
+ private static TypeCode typeCode;
+
+ /**
+ * Create the NameValuePair typecode (structure,
+ * named "NameValuePair").
+ * The typecode states that the structure contains the
+ * following fields: id, value.
+ */
+ public static TypeCode type()
+ {
+ if (typeCode == null)
+ {
+ ORB orb = ORB.init();
+ StructMember[] members = new StructMember[ 2 ];
+
+ TypeCode field;
+
+ field =
+ orb.create_alias_tc("IDL:omg.org/DynamicAny/FieldName:1.0",
+ "FieldName",
+ orb.get_primitive_tc(TCKind.tk_string)
+ );
+ members [ 0 ] = new StructMember("id", field, null);
+
+ field = orb.get_primitive_tc(TCKind.tk_any);
+ members [ 1 ] = new StructMember("value", field, null);
+ typeCode = orb.create_struct_tc(id(), "NameValuePair", members);
+ }
+ return typeCode;
+ }
+
+ /**
+ * Insert the NameValuePair into the given Any.
+ * This method uses the NameValuePairHolder.
+ *
+ * @param any the Any to insert into.
+ * @param that the NameValuePair to insert.
+ */
+ public static void insert(Any any, NameValuePair that)
+ {
+ any.insert_Streamable(new NameValuePairHolder(that));
+ }
+
+ /**
+ * Extract the NameValuePair from given Any.
+ * This method uses the NameValuePairHolder.
+ *
+ * @throws BAD_OPERATION if the passed Any does not contain NameValuePair.
+ */
+ public static NameValuePair extract(Any any)
+ {
+ try
+ {
+ return ((NameValuePairHolder) any.extract_Streamable()).value;
+ }
+ catch (ClassCastException cex)
+ {
+ BAD_OPERATION bad = new BAD_OPERATION("NameValuePair expected");
+ bad.initCause(cex);
+ throw bad;
+ }
+ }
+
+ /**
+ * Get the NameValuePair repository id.
+ *
+ * @return "IDL:omg.org/DynamicAny/NameValuePair:1.0", always.
+ */
+ public static String id()
+ {
+ return "IDL:omg.org/DynamicAny/NameValuePair:1.0";
+ }
+
+ /**
+ * Read the structure from the CDR intput stream.
+ *
+ * @param input a org.omg.CORBA.portable stream to read from.
+ */
+ public static NameValuePair read(InputStream input)
+ {
+ NameValuePair value = new NameValuePair();
+ value.id = input.read_string();
+ value.value = input.read_any();
+ return value;
+ }
+
+ /**
+ * Write the structure to the CDR output stream.
+ *
+ * @param output a org.omg.CORBA.portable stream stream to write into.
+ * @param value a value to write.
+ */
+ public static void write(OutputStream output, NameValuePair value)
+ {
+ output.write_string(value.id);
+ output.write_any(value.value);
+ }
+}
\ No newline at end of file
--- /dev/null
+/* NameValuePairSeq.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., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 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.DynamicAny;
+
+import gnu.CORBA.NameValuePairSeqHolder;
+
+import org.omg.CORBA.Any;
+import org.omg.CORBA.BAD_OPERATION;
+import org.omg.CORBA.ORB;
+import org.omg.CORBA.TypeCode;
+import org.omg.CORBA.portable.InputStream;
+import org.omg.CORBA.portable.OutputStream;
+
+/**
+ * A helper operations for the array of {@link NameValuePair}.
+ *
+ * @author Audrius Meskauskas, Lithuania (AudriusA@Bioinformatics.org)
+ */
+public abstract class NameValuePairSeqHelper
+{
+ /**
+ * The cached typecode value, computed only once.
+ */
+ private static TypeCode typeCode;
+
+ public static TypeCode type()
+ {
+ if (typeCode == null)
+ {
+ ORB orb = ORB.init();
+ TypeCode t = orb.create_sequence_tc(0, NameValuePairHelper.type());
+ typeCode = orb.create_alias_tc(id(), "NameValuePairSeq", t);
+ }
+ return typeCode;
+ }
+
+ /**
+ * Insert the NameValuePairSeq into the given Any.
+ * This method uses the NameValuePairSeqHolder.
+ *
+ * @param any the Any to insert into.
+ * @param those the NameValuePair[] to insert.
+ */
+ public static void insert(Any any, NameValuePair[] those)
+ {
+ any.insert_Streamable(new NameValuePairSeqHolder(those));
+ }
+
+ /**
+ * Extract the NameValuePairSeq from given Any.
+ * This method uses the NameValuePairSeqHolder.
+ *
+ * @throws BAD_OPERATION if the passed Any does not contain NameValuePairSeq.
+ */
+ public static NameValuePair[] extract(Any any)
+ {
+ try
+ {
+ return ((NameValuePairSeqHolder) any.extract_Streamable()).value;
+ }
+ catch (ClassCastException cex)
+ {
+ BAD_OPERATION bad = new BAD_OPERATION("NameValuePairSeq expected");
+ bad.initCause(cex);
+ throw bad;
+ }
+ }
+
+ /**
+ * Get the NameValuePairSeq repository id.
+ *
+ * @return "IDL:omg.org/DynamicAny/NameValuePairSeq:1.0", always.
+ */
+ public static String id()
+ {
+ return "IDL:omg.org/DynamicAny/NameValuePairSeq:1.0";
+ }
+
+ /**
+ * Read the sequence from the CDR intput stream.
+ * Expects the array size (as CORBA long), followed by
+ * the array members (if any).
+ *
+ * @param input a org.omg.CORBA.portable stream to read from.
+ */
+ public static NameValuePair[] read(InputStream input)
+ {
+ NameValuePair[] value;
+ value = new NameValuePair[ input.read_long() ];
+ for (int i = 0; i < value.length; i++)
+ value [ i ] = NameValuePairHelper.read(input);
+ return value;
+ }
+
+ /**
+ * Write the structure to the CDR output stream.
+ * Writes the array size (as CORBA long), followed by
+ * the array members (if any).
+ *
+ * @param output a org.omg.CORBA.portable stream stream to write into.
+ * @param value an array to write.
+ */
+ public static void write(OutputStream output, NameValuePair[] value)
+ {
+ output.write_long(value.length);
+ for (int i0 = 0; i0 < value.length; i0++)
+ {
+ NameValuePairHelper.write(output, value [ i0 ]);
+ }
+ }
+}
\ No newline at end of file
--- /dev/null
+/* _DynAnyFactoryStub.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., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 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.DynamicAny;
+
+import org.omg.CORBA.Any;
+import org.omg.CORBA.MARSHAL;
+import org.omg.CORBA.TypeCode;
+import org.omg.CORBA.portable.Delegate;
+import org.omg.CORBA.portable.ObjectImpl;
+import org.omg.DynamicAny.DynAnyFactoryPackage.InconsistentTypeCode;
+
+import java.io.Serializable;
+
+/**
+ * Should provide support for remote invocation of methods on
+ * DynAnyFactory. As DynAny can never be remote at least till 1.5 inclusive,
+ * this class is not in use. DynAnyFactory should be obtained from the
+ * {@link ORB#resolve_initial_references}.
+ *
+ * @author Audrius Meskauskas, Lithuania (AudriusA@Bioinformatics.org)
+ */
+public class _DynAnyFactoryStub
+ extends ObjectImpl
+ implements DynAnyFactory, Serializable
+{
+ /**
+ * Use serialVersionUID (v1.4) for interoperability.
+ */
+ private static final long serialVersionUID = -6575269659020082310L;
+
+ /**
+ * The purpose and value of this field are not documented.
+ */
+ public static final Class _opsClass = DynAnyFactoryOperations.class;
+
+ /**
+ * Create the DynAnyFactory stub.
+ */
+ public _DynAnyFactoryStub()
+ {
+ }
+
+ /**
+ * Create the naming context stub with the given delegate.
+ */
+ public _DynAnyFactoryStub(Delegate delegate)
+ {
+ _set_delegate(delegate);
+ }
+
+ /**
+ * Return the array of repository ids for this object.
+ */
+ public String[] _ids()
+ {
+ return new String[] { DynAnyFactoryHelper.id() };
+ }
+
+ /**
+ * The remote call of this DynAnyFactory method is not possible
+ * (the created DynAny would not be transferred to client).
+ *
+ * @throws MARSHAL, always.
+ */
+ public DynAny create_dyn_any(Any _0)
+ throws InconsistentTypeCode
+ {
+ throw new MARSHAL(NOT_APPLICABLE);
+ }
+
+ /**
+ * The remote call of this DynAnyFactory method is not possible
+ * (the created DynAny would not be transferred to client).
+ *
+ * @throws MARSHAL, always.
+ */
+ public DynAny create_dyn_any_from_type_code(TypeCode _0)
+ throws InconsistentTypeCode
+ {
+ throw new MARSHAL(NOT_APPLICABLE);
+ }
+
+ static String NOT_APPLICABLE =
+ "DynAnyFactory is always local objects. " +
+ "It is never accessed on remote side via stub.";
+}
\ No newline at end of file
--- /dev/null
+/* _DynAnyStub.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., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 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.DynamicAny;
+
+import org.omg.CORBA.Any;
+import org.omg.CORBA.MARSHAL;
+import org.omg.CORBA.TypeCode;
+import org.omg.CORBA.portable.Delegate;
+import org.omg.CORBA.portable.ObjectImpl;
+import org.omg.DynamicAny.DynAnyPackage.InvalidValue;
+import org.omg.DynamicAny.DynAnyPackage.TypeMismatch;
+
+import java.io.Serializable;
+
+/**
+ * Should provide support for remote invocation of methods on DynAny. As
+ * DynAny can never be remote at least till 1.5 inclusive, this class is
+ * not in use.
+ *
+ * @author Audrius Meskauskas, Lithuania (AudriusA@Bioinformatics.org)
+ */
+public class _DynAnyStub
+ extends ObjectImpl
+ implements DynAny, Serializable
+{
+ /**
+ * Use serialVersionUID (v1.4) for interoperability.
+ */
+ private static final long serialVersionUID = -6521892777941121597L;
+
+ /**
+ * The purpose and value of this field are not documented.
+ */
+ public static final Class _opsClass = DynAnyOperations.class;
+
+ /**
+ * Create the DynAny stub.
+ */
+ public _DynAnyStub()
+ {
+ }
+
+ /**
+ * Create the naming context stub with the given delegate.
+ */
+ public _DynAnyStub(Delegate delegate)
+ {
+ _set_delegate(delegate);
+ }
+
+ /**
+ * Return the array of repository ids for this object.
+ */
+ public String[] _ids()
+ {
+ return new String[] { DynAnyHelper.id() };
+ }
+
+ /**
+ * The remote call of DynAny methods is not possible.
+ *
+ * @throws MARSHAL, always.
+ */
+ public TypeCode type()
+ {
+ throw new MARSHAL(NOT_APPLICABLE);
+ }
+
+ /**
+ * The remote call of DynAny methods is not possible.
+ *
+ * @throws MARSHAL, always.
+ */
+ public boolean next()
+ {
+ throw new MARSHAL(NOT_APPLICABLE);
+ }
+
+ /**
+ * The remote call of DynAny methods is not possible.
+ *
+ * @throws MARSHAL, always.
+ */
+ public void destroy()
+ {
+ }
+
+ /**
+ * The remote call of DynAny methods is not possible.
+ *
+ * @throws MARSHAL, always.
+ */
+ public DynAny copy()
+ {
+ return this;
+ }
+
+ /**
+ * The remote call of DynAny methods is not possible.
+ *
+ * @throws MARSHAL, always.
+ */
+ public void rewind()
+ {
+ }
+
+ /**
+ * The remote call of DynAny methods is not possible.
+ *
+ * @throws MARSHAL, always.
+ */
+ public void assign(DynAny _0)
+ throws TypeMismatch
+ {
+ }
+
+ /**
+ * The remote call of DynAny methods is not possible.
+ *
+ * @throws MARSHAL, always.
+ */
+ public int component_count()
+ {
+ throw new MARSHAL(NOT_APPLICABLE);
+ }
+
+ /**
+ * The remote call of DynAny methods is not possible.
+ *
+ * @throws MARSHAL, always.
+ */
+ public DynAny current_component()
+ throws TypeMismatch
+ {
+ throw new MARSHAL(NOT_APPLICABLE);
+ }
+
+ /**
+ * The remote call of DynAny methods is not possible.
+ *
+ * @throws MARSHAL, always.
+ */
+ public boolean equal(DynAny _0)
+ {
+ throw new MARSHAL(NOT_APPLICABLE);
+ }
+
+ /**
+ * The remote call of DynAny methods is not possible.
+ *
+ * @throws MARSHAL, always.
+ */
+ public void from_any(Any _0)
+ throws TypeMismatch, InvalidValue
+ {
+ throw new MARSHAL(NOT_APPLICABLE);
+ }
+
+ /**
+ * The remote call of DynAny methods is not possible.
+ *
+ * @throws MARSHAL, always.
+ */
+ public Any get_any()
+ throws TypeMismatch, InvalidValue
+ {
+ throw new MARSHAL(NOT_APPLICABLE);
+ }
+
+ /**
+ * The remote call of DynAny methods is not possible.
+ *
+ * @throws MARSHAL, always.
+ */
+ public boolean get_boolean()
+ throws TypeMismatch, InvalidValue
+ {
+ throw new MARSHAL(NOT_APPLICABLE);
+ }
+
+ /**
+ * The remote call of DynAny methods is not possible.
+ *
+ * @throws MARSHAL, always.
+ */
+ public char get_char()
+ throws TypeMismatch, InvalidValue
+ {
+ throw new MARSHAL(NOT_APPLICABLE);
+ }
+
+ /**
+ * The remote call of DynAny methods is not possible.
+ *
+ * @throws MARSHAL, always.
+ */
+ public double get_double()
+ throws TypeMismatch, InvalidValue
+ {
+ throw new MARSHAL(NOT_APPLICABLE);
+ }
+
+ /**
+ * The remote call of DynAny methods is not possible.
+ *
+ * @throws MARSHAL, always.
+ */
+ public DynAny get_dyn_any()
+ throws TypeMismatch, InvalidValue
+ {
+ throw new MARSHAL(NOT_APPLICABLE);
+ }
+
+ /**
+ * The remote call of DynAny methods is not possible.
+ *
+ * @throws MARSHAL, always.
+ */
+ public float get_float()
+ throws TypeMismatch, InvalidValue
+ {
+ throw new MARSHAL(NOT_APPLICABLE);
+ }
+
+ /**
+ * The remote call of DynAny methods is not possible.
+ *
+ * @throws MARSHAL, always.
+ */
+ public int get_long()
+ throws TypeMismatch, InvalidValue
+ {
+ throw new MARSHAL(NOT_APPLICABLE);
+ }
+
+ /**
+ * The remote call of DynAny methods is not possible.
+ *
+ * @throws MARSHAL, always.
+ */
+ public long get_longlong()
+ throws TypeMismatch, InvalidValue
+ {
+ throw new MARSHAL(NOT_APPLICABLE);
+ }
+
+ /**
+ * The remote call of DynAny methods is not possible.
+ *
+ * @throws MARSHAL, always.
+ */
+ public byte get_octet()
+ throws TypeMismatch, InvalidValue
+ {
+ throw new MARSHAL(NOT_APPLICABLE);
+ }
+
+ /**
+ * The remote call of DynAny methods is not possible.
+ *
+ * @throws MARSHAL, always.
+ */
+ public org.omg.CORBA.Object get_reference()
+ throws TypeMismatch, InvalidValue
+ {
+ throw new MARSHAL(NOT_APPLICABLE);
+ }
+
+ /**
+ * The remote call of DynAny methods is not possible.
+ *
+ * @throws MARSHAL, always.
+ */
+ public short get_short()
+ throws TypeMismatch, InvalidValue
+ {
+ throw new MARSHAL(NOT_APPLICABLE);
+ }
+
+ /**
+ * The remote call of DynAny methods is not possible.
+ *
+ * @throws MARSHAL, always.
+ */
+ public String get_string()
+ throws TypeMismatch, InvalidValue
+ {
+ throw new MARSHAL(NOT_APPLICABLE);
+ }
+
+ /**
+ * The remote call of DynAny methods is not possible.
+ *
+ * @throws MARSHAL, always.
+ */
+ public TypeCode get_typecode()
+ throws TypeMismatch, InvalidValue
+ {
+ throw new MARSHAL(NOT_APPLICABLE);
+ }
+
+ /**
+ * The remote call of DynAny methods is not possible.
+ *
+ * @throws MARSHAL, always.
+ */
+ public int get_ulong()
+ throws TypeMismatch, InvalidValue
+ {
+ throw new MARSHAL(NOT_APPLICABLE);
+ }
+
+ /**
+ * The remote call of DynAny methods is not possible.
+ *
+ * @throws MARSHAL, always.
+ */
+ public long get_ulonglong()
+ throws TypeMismatch, InvalidValue
+ {
+ throw new MARSHAL(NOT_APPLICABLE);
+ }
+
+ /**
+ * The remote call of DynAny methods is not possible.
+ *
+ * @throws MARSHAL, always.
+ */
+ public short get_ushort()
+ throws TypeMismatch, InvalidValue
+ {
+ throw new MARSHAL(NOT_APPLICABLE);
+ }
+
+ /**
+ * The remote call of DynAny methods is not possible.
+ *
+ * @throws MARSHAL, always.
+ */
+ public Serializable get_val()
+ throws TypeMismatch, InvalidValue
+ {
+ throw new MARSHAL(NOT_APPLICABLE);
+ }
+
+ /**
+ * The remote call of DynAny methods is not possible.
+ *
+ * @throws MARSHAL, always.
+ */
+ public char get_wchar()
+ throws TypeMismatch, InvalidValue
+ {
+ throw new MARSHAL(NOT_APPLICABLE);
+ }
+
+ /**
+ * The remote call of DynAny methods is not possible.
+ *
+ * @throws MARSHAL, always.
+ */
+ public String get_wstring()
+ throws TypeMismatch, InvalidValue
+ {
+ throw new MARSHAL(NOT_APPLICABLE);
+ }
+
+ /**
+ * The remote call of DynAny methods is not possible.
+ *
+ * @throws MARSHAL, always.
+ */
+ public void insert_any(Any _0)
+ throws TypeMismatch, InvalidValue
+ {
+ throw new MARSHAL(NOT_APPLICABLE);
+ }
+
+ /**
+ * The remote call of DynAny methods is not possible.
+ *
+ * @throws MARSHAL, always.
+ */
+ public void insert_boolean(boolean _0)
+ throws TypeMismatch, InvalidValue
+ {
+ throw new MARSHAL(NOT_APPLICABLE);
+ }
+
+ /**
+ * The remote call of DynAny methods is not possible.
+ *
+ * @throws MARSHAL, always.
+ */
+ public void insert_char(char _0)
+ throws TypeMismatch, InvalidValue
+ {
+ throw new MARSHAL(NOT_APPLICABLE);
+ }
+
+ /**
+ * The remote call of DynAny methods is not possible.
+ *
+ * @throws MARSHAL, always.
+ */
+ public void insert_double(double _0)
+ throws TypeMismatch, InvalidValue
+ {
+ throw new MARSHAL(NOT_APPLICABLE);
+ }
+
+ /**
+ * The remote call of DynAny methods is not possible.
+ *
+ * @throws MARSHAL, always.
+ */
+ public void insert_dyn_any(DynAny _0)
+ throws TypeMismatch, InvalidValue
+ {
+ throw new MARSHAL(NOT_APPLICABLE);
+ }
+
+ /**
+ * The remote call of DynAny methods is not possible.
+ *
+ * @throws MARSHAL, always.
+ */
+ public void insert_float(float _0)
+ throws TypeMismatch, InvalidValue
+ {
+ throw new MARSHAL(NOT_APPLICABLE);
+ }
+
+ /**
+ * The remote call of DynAny methods is not possible.
+ *
+ * @throws MARSHAL, always.
+ */
+ public void insert_long(int _0)
+ throws TypeMismatch, InvalidValue
+ {
+ throw new MARSHAL(NOT_APPLICABLE);
+ }
+
+ /**
+ * The remote call of DynAny methods is not possible.
+ *
+ * @throws MARSHAL, always.
+ */
+ public void insert_longlong(long _0)
+ throws TypeMismatch, InvalidValue
+ {
+ throw new MARSHAL(NOT_APPLICABLE);
+ }
+
+ /**
+ * The remote call of DynAny methods is not possible.
+ *
+ * @throws MARSHAL, always.
+ */
+ public void insert_octet(byte _0)
+ throws TypeMismatch, InvalidValue
+ {
+ throw new MARSHAL(NOT_APPLICABLE);
+ }
+
+ /**
+ * The remote call of DynAny methods is not possible.
+ *
+ * @throws MARSHAL, always.
+ */
+ public void insert_reference(org.omg.CORBA.Object _0)
+ throws TypeMismatch, InvalidValue
+ {
+ throw new MARSHAL(NOT_APPLICABLE);
+ }
+
+ /**
+ * The remote call of DynAny methods is not possible.
+ *
+ * @throws MARSHAL, always.
+ */
+ public void insert_short(short _0)
+ throws TypeMismatch, InvalidValue
+ {
+ throw new MARSHAL(NOT_APPLICABLE);
+ }
+
+ /**
+ * The remote call of DynAny methods is not possible.
+ *
+ * @throws MARSHAL, always.
+ */
+ public void insert_string(String _0)
+ throws TypeMismatch, InvalidValue
+ {
+ throw new MARSHAL(NOT_APPLICABLE);
+ }
+
+ /**
+ * The remote call of DynAny methods is not possible.
+ *
+ * @throws MARSHAL, always.
+ */
+ public void insert_typecode(TypeCode _0)
+ throws TypeMismatch, InvalidValue
+ {
+ throw new MARSHAL(NOT_APPLICABLE);
+ }
+
+ /**
+ * The remote call of DynAny methods is not possible.
+ *
+ * @throws MARSHAL, always.
+ */
+ public void insert_ulong(int _0)
+ throws TypeMismatch, InvalidValue
+ {
+ throw new MARSHAL(NOT_APPLICABLE);
+ }
+
+ /**
+ * The remote call of DynAny methods is not possible.
+ *
+ * @throws MARSHAL, always.
+ */
+ public void insert_ulonglong(long _0)
+ throws TypeMismatch, InvalidValue
+ {
+ throw new MARSHAL(NOT_APPLICABLE);
+ }
+
+ /**
+ * The remote call of DynAny methods is not possible.
+ *
+ * @throws MARSHAL, always.
+ */
+ public void insert_ushort(short _0)
+ throws TypeMismatch, InvalidValue
+ {
+ throw new MARSHAL(NOT_APPLICABLE);
+ }
+
+ /**
+ * The remote call of DynAny methods is not possible.
+ *
+ * @throws MARSHAL, always.
+ */
+ public void insert_val(Serializable _0)
+ throws TypeMismatch, InvalidValue
+ {
+ throw new MARSHAL(NOT_APPLICABLE);
+ }
+
+ /**
+ * The remote call of DynAny methods is not possible.
+ *
+ * @throws MARSHAL, always.
+ */
+ public void insert_wchar(char _0)
+ throws TypeMismatch, InvalidValue
+ {
+ throw new MARSHAL(NOT_APPLICABLE);
+ }
+
+ /**
+ * The remote call of DynAny methods is not possible.
+ *
+ * @throws MARSHAL, always.
+ */
+ public void insert_wstring(String _0)
+ throws TypeMismatch, InvalidValue
+ {
+ throw new MARSHAL(NOT_APPLICABLE);
+ }
+
+ /**
+ * The remote call of DynAny methods is not possible.
+ *
+ * @throws MARSHAL, always.
+ */
+ public boolean seek(int _0)
+ {
+ throw new MARSHAL(NOT_APPLICABLE);
+ }
+
+ /**
+ * The remote call of DynAny methods is not possible.
+ *
+ * @throws MARSHAL, always.
+ */
+ public Any to_any()
+ {
+ throw new MARSHAL(NOT_APPLICABLE);
+ }
+
+ static String NOT_APPLICABLE =
+ "DynAnys are always local objects. " +
+ "They and are never accessed on remote side via stubs.";
+}
\ No newline at end of file
--- /dev/null
+/* _DynArrayStub.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., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 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.DynamicAny;
+
+import org.omg.CORBA.Any;
+import org.omg.CORBA.MARSHAL;
+import org.omg.CORBA.portable.Delegate;
+import org.omg.DynamicAny.DynAnyPackage.InvalidValue;
+import org.omg.DynamicAny.DynAnyPackage.TypeMismatch;
+
+import java.io.Serializable;
+
+/**
+ * Should provide support for remote invocation of methods on DynArray. As
+ * DynArray can never be remote at least till 1.5 inclusive, this class is
+ * not in use.
+ *
+ * @author Audrius Meskauskas, Lithuania (AudriusA@Bioinformatics.org)
+ */
+public class _DynArrayStub
+ extends _DynAnyStub
+ implements DynArray, Serializable
+{
+ /**
+ * Use serialVersionUID for interoperability.
+ */
+ private static final long serialVersionUID = -6302474930370950228L;
+
+ /**
+ * The purpose and value of this field are not documented.
+ */
+ public static final Class _opsClass = DynArrayOperations.class;
+
+ /**
+ * Create the DynArray stub.
+ */
+ public _DynArrayStub()
+ {
+ }
+
+ /**
+ * Create the naming context stub with the given delegate.
+ */
+ public _DynArrayStub(Delegate delegate)
+ {
+ _set_delegate(delegate);
+ }
+
+ /**
+ * Return the array of repository ids for this object.
+ */
+ public String[] _ids()
+ {
+ return new String[] { DynArrayHelper.id() };
+ }
+
+ /**
+ * The remote call of DynArray methods is not possible.
+ *
+ * @throws MARSHAL, always.
+ */
+ public Any[] get_elements()
+ {
+ throw new MARSHAL(_DynAnyStub.NOT_APPLICABLE);
+ }
+
+ /**
+ * The remote call of DynArray methods is not possible.
+ *
+ * @throws MARSHAL, always.
+ */
+ public DynAny[] get_elements_as_dyn_any()
+ {
+ throw new MARSHAL(_DynAnyStub.NOT_APPLICABLE);
+ }
+
+ /**
+ * The remote call of DynArray methods is not possible.
+ *
+ * @throws MARSHAL, always.
+ */
+ public void set_elements(Any[] _0)
+ throws TypeMismatch, InvalidValue
+ {
+ throw new MARSHAL(_DynAnyStub.NOT_APPLICABLE);
+ }
+
+ /**
+ * The remote call of DynArray methods is not possible.
+ *
+ * @throws MARSHAL, always.
+ */
+ public void set_elements_as_dyn_any(DynAny[] _0)
+ throws TypeMismatch, InvalidValue
+ {
+ throw new MARSHAL(_DynAnyStub.NOT_APPLICABLE);
+ }
+}
\ No newline at end of file
--- /dev/null
+/* _DynEnumStub.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., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 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.DynamicAny;
+
+import org.omg.CORBA.MARSHAL;
+import org.omg.CORBA.portable.Delegate;
+import org.omg.DynamicAny.DynAnyPackage.InvalidValue;
+
+import java.io.Serializable;
+
+/**
+ * Should provide support for remote invocation of methods on DynEnum. As
+ * DynEnum can never be remote at least till 1.5 inclusive, this class is
+ * not in use.
+ *
+ * @author Audrius Meskauskas, Lithuania (AudriusA@Bioinformatics.org)
+ */
+public class _DynEnumStub
+ extends _DynAnyStub
+ implements DynEnum, Serializable
+{
+ /**
+ * Use serialVersionUID (v1.4) for interoperability.
+ */
+ private static final long serialVersionUID = 696844314172031949L;
+
+ /**
+ * The purpose and value of this field are not documented.
+ */
+ public static final Class _opsClass = DynEnumOperations.class;
+
+ /**
+ * Create the DynEnum stub.
+ */
+ public _DynEnumStub()
+ {
+ }
+
+ /**
+ * Create the naming context stub with the given delegate.
+ */
+ public _DynEnumStub(Delegate delegate)
+ {
+ _set_delegate(delegate);
+ }
+
+ /**
+ * Return the array of repository ids for this object.
+ */
+ public String[] _ids()
+ {
+ return new String[] { DynEnumHelper.id() };
+ }
+
+ /**
+ * The remote call of DynEnum methods is not possible.
+ *
+ * @throws MARSHAL, always.
+ */
+ public String get_as_string()
+ {
+ throw new MARSHAL(_DynAnyStub.NOT_APPLICABLE);
+ }
+
+ /**
+ * The remote call of DynEnum methods is not possible.
+ *
+ * @throws MARSHAL, always.
+ */
+ public int get_as_ulong()
+ {
+ throw new MARSHAL(_DynAnyStub.NOT_APPLICABLE);
+ }
+
+ /**
+ * The remote call of DynEnum methods is not possible.
+ *
+ * @throws MARSHAL, always.
+ */
+ public void set_as_string(String _0)
+ throws InvalidValue
+ {
+ throw new MARSHAL(_DynAnyStub.NOT_APPLICABLE);
+ }
+
+ /**
+ * The remote call of DynEnum methods is not possible.
+ *
+ * @throws MARSHAL, always.
+ */
+ public void set_as_ulong(int _0)
+ throws InvalidValue
+ {
+ throw new MARSHAL(_DynAnyStub.NOT_APPLICABLE);
+ }
+}
\ No newline at end of file
--- /dev/null
+/* _DynFixedStub.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., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 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.DynamicAny;
+
+import org.omg.CORBA.MARSHAL;
+import org.omg.CORBA.portable.Delegate;
+import org.omg.DynamicAny.DynAnyPackage.InvalidValue;
+import org.omg.DynamicAny.DynAnyPackage.TypeMismatch;
+
+import java.io.Serializable;
+
+/**
+ * Should provide support for remote invocation of methods on DynFixed. As
+ * DynFixed can never be remote at least till 1.5 inclusive, this class is
+ * not in use.
+ *
+ * @author Audrius Meskauskas, Lithuania (AudriusA@Bioinformatics.org)
+ */
+public class _DynFixedStub
+ extends _DynAnyStub
+ implements DynFixed, Serializable
+{
+ /**
+ * Use serialVersionUID (v1.4) for interoperability.
+ */
+ private static final long serialVersionUID = -1932029532964417188L;
+
+ /**
+ * The purpose and value of this field are not documented.
+ */
+ public static final Class _opsClass = DynFixedOperations.class;
+
+ /**
+ * Create the DynFixed stub.
+ */
+ public _DynFixedStub()
+ {
+ }
+
+ /**
+ * Create the naming context stub with the given delegate.
+ */
+ public _DynFixedStub(Delegate delegate)
+ {
+ _set_delegate(delegate);
+ }
+
+ /**
+ * Return the array of repository ids for this object.
+ */
+ public String[] _ids()
+ {
+ return new String[] { DynFixedHelper.id() };
+ }
+
+ /**
+ * The remote call of DynAny methods is not possible.
+ *
+ * @throws MARSHAL, always.
+ */
+ public String get_value()
+ {
+ throw new MARSHAL(_DynAnyStub.NOT_APPLICABLE);
+ }
+
+ /**
+ * The remote call of DynAny methods is not possible.
+ *
+ * @throws MARSHAL, always.
+ */
+ public boolean set_value(String _0)
+ throws TypeMismatch, InvalidValue
+ {
+ throw new MARSHAL(_DynAnyStub.NOT_APPLICABLE);
+ }
+}
\ No newline at end of file
--- /dev/null
+/* _DynSequenceStub.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., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 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.DynamicAny;
+
+import org.omg.CORBA.Any;
+import org.omg.CORBA.MARSHAL;
+import org.omg.CORBA.portable.Delegate;
+import org.omg.DynamicAny.DynAnyPackage.InvalidValue;
+import org.omg.DynamicAny.DynAnyPackage.TypeMismatch;
+
+import java.io.Serializable;
+
+/**
+ * Should provide support for remote invocation of methods on DynSequence. As
+ * DynSequence can never be remote at least till 1.5 inclusive, this class is
+ * not in use.
+ *
+ * @author Audrius Meskauskas, Lithuania (AudriusA@Bioinformatics.org)
+ */
+public class _DynSequenceStub
+ extends _DynAnyStub
+ implements DynSequence, Serializable
+{
+ /**
+ * Use serialVersionUID (v1.4) for interoperability.
+ */
+ private static final long serialVersionUID = 7191437435669107554L;
+
+ /**
+ * The purpose and value of this field are not documented.
+ */
+ public static final Class _opsClass = DynSequenceOperations.class;
+
+ /**
+ * Create the DynSequence stub. To get the stub working,
+ * you must later set the delegate with
+ * {@link ObjectImpl#_set_delegate(Delegate)}.
+ */
+ public _DynSequenceStub()
+ {
+ }
+
+ /**
+ * Create the naming context stub with the given delegate.
+ */
+ public _DynSequenceStub(Delegate delegate)
+ {
+ _set_delegate(delegate);
+ }
+
+ /**
+ * Return the array of repository ids for this object.
+ */
+ public String[] _ids()
+ {
+ return new String[] { DynSequenceHelper.id() };
+ }
+
+ /**
+ * The remote call of DynAny methods is not possible.
+ *
+ * @throws MARSHAL, always.
+ */
+ public Any[] get_elements()
+ {
+ throw new MARSHAL(_DynAnyStub.NOT_APPLICABLE);
+ }
+
+ /**
+ * The remote call of DynAny methods is not possible.
+ *
+ * @throws MARSHAL, always.
+ */
+ public DynAny[] get_elements_as_dyn_any()
+ {
+ throw new MARSHAL(_DynAnyStub.NOT_APPLICABLE);
+ }
+
+ /**
+ * The remote call of DynAny methods is not possible.
+ *
+ * @throws MARSHAL, always.
+ */
+ public void set_elements(Any[] _0)
+ throws TypeMismatch, InvalidValue
+ {
+ throw new MARSHAL(_DynAnyStub.NOT_APPLICABLE);
+ }
+
+ /**
+ * The remote call of DynAny methods is not possible.
+ *
+ * @throws MARSHAL, always.
+ */
+ public void set_elements_as_dyn_any(DynAny[] _0)
+ throws TypeMismatch, InvalidValue
+ {
+ throw new MARSHAL(_DynAnyStub.NOT_APPLICABLE);
+ }
+
+ /**
+ * The remote call of DynAny methods is not possible.
+ *
+ * @throws MARSHAL, always.
+ */
+ public int get_length()
+ {
+ throw new MARSHAL(_DynAnyStub.NOT_APPLICABLE);
+ }
+
+ /**
+ * The remote call of DynAny methods is not possible.
+ *
+ * @throws MARSHAL, always.
+ */
+ public void set_length(int _0)
+ throws InvalidValue
+ {
+ throw new MARSHAL(_DynAnyStub.NOT_APPLICABLE);
+ }
+}
\ No newline at end of file
--- /dev/null
+/* _DynStructStub.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., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 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.DynamicAny;
+
+import org.omg.CORBA.MARSHAL;
+import org.omg.CORBA.TCKind;
+import org.omg.CORBA.portable.Delegate;
+import org.omg.DynamicAny.DynAnyPackage.InvalidValue;
+import org.omg.DynamicAny.DynAnyPackage.TypeMismatch;
+
+import java.io.Serializable;
+
+/**
+ * Should provide support for remote invocation of methods on DynStruct. As
+ * DynStruct can never be remote at least till 1.5 inclusive, this class is
+ * not in use.
+ *
+ * @author Audrius Meskauskas, Lithuania (AudriusA@Bioinformatics.org)
+ */
+public class _DynStructStub
+ extends _DynAnyStub
+ implements DynStruct, Serializable
+{
+ /**
+ * Use serialVersionUID (v1.4) for interoperability.
+ */
+ private static final long serialVersionUID = -8415786200783826656L;
+
+ /**
+ * The purpose and value of this field are not documented.
+ */
+ public static final Class _opsClass = DynStructOperations.class;
+
+ /**
+ * Create the DynStruct stub. To get the stub working,
+ * you must later set the delegate with
+ * {@link ObjectImpl#_set_delegate(Delegate)}.
+ */
+ public _DynStructStub()
+ {
+ }
+
+ /**
+ * Create the naming context stub with the given delegate.
+ */
+ public _DynStructStub(Delegate delegate)
+ {
+ _set_delegate(delegate);
+ }
+
+ /**
+ * Return the array of repository ids for this object.
+ */
+ public String[] _ids()
+ {
+ return new String[] { DynStructHelper.id() };
+ }
+
+ /**
+ * The remote call of DynAny methods is not possible.
+ *
+ * @throws MARSHAL, always.
+ */
+ public TCKind current_member_kind()
+ throws TypeMismatch, InvalidValue
+ {
+ throw new MARSHAL(_DynAnyStub.NOT_APPLICABLE);
+ }
+
+ /**
+ * The remote call of DynAny methods is not possible.
+ *
+ * @throws MARSHAL, always.
+ */
+ public String current_member_name()
+ throws TypeMismatch, InvalidValue
+ {
+ throw new MARSHAL(_DynAnyStub.NOT_APPLICABLE);
+ }
+
+ /**
+ * The remote call of DynAny methods is not possible.
+ *
+ * @throws MARSHAL, always.
+ */
+ public NameValuePair[] get_members()
+ {
+ throw new MARSHAL(_DynAnyStub.NOT_APPLICABLE);
+ }
+
+ /**
+ * The remote call of DynAny methods is not possible.
+ *
+ * @throws MARSHAL, always.
+ */
+ public NameDynAnyPair[] get_members_as_dyn_any()
+ {
+ throw new MARSHAL(_DynAnyStub.NOT_APPLICABLE);
+ }
+
+ /**
+ * The remote call of DynAny methods is not possible.
+ *
+ * @throws MARSHAL, always.
+ */
+ public void set_members(NameValuePair[] _0)
+ throws TypeMismatch, InvalidValue
+ {
+ throw new MARSHAL(_DynAnyStub.NOT_APPLICABLE);
+ }
+
+ /**
+ * The remote call of DynAny methods is not possible.
+ *
+ * @throws MARSHAL, always.
+ */
+ public void set_members_as_dyn_any(NameDynAnyPair[] _0)
+ throws TypeMismatch, InvalidValue
+ {
+ throw new MARSHAL(_DynAnyStub.NOT_APPLICABLE);
+ }
+}
\ No newline at end of file
--- /dev/null
+/* _DynUnionStub.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., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 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.DynamicAny;
+
+import org.omg.CORBA.MARSHAL;
+import org.omg.CORBA.TCKind;
+import org.omg.CORBA.portable.Delegate;
+import org.omg.DynamicAny.DynAnyPackage.InvalidValue;
+import org.omg.DynamicAny.DynAnyPackage.TypeMismatch;
+
+import java.io.Serializable;
+
+/**
+ * Should provide support for remote invocation of methods on DynUnion. As
+ * DynUnion can never be remote at least till 1.5 inclusive, this class is
+ * not in use.
+ *
+ * @author Audrius Meskauskas, Lithuania (AudriusA@Bioinformatics.org)
+ */
+public class _DynUnionStub
+ extends _DynAnyStub
+ implements DynUnion, Serializable
+{
+ /**
+ * Use serialVersionUID for interoperability.
+ */
+ private static final long serialVersionUID = -8921031953572009897L;
+
+ /**
+ * The purpose and value of this field are not documented.
+ */
+ public static final Class _opsClass = DynUnionOperations.class;
+
+ /**
+ * Create the DynUnion stub. To get the stub working,
+ * you must later set the delegate with
+ * {@link ObjectImpl#_set_delegate(Delegate)}.
+ */
+ public _DynUnionStub()
+ {
+ }
+
+ /**
+ * Create the naming context stub with the given delegate.
+ */
+ public _DynUnionStub(Delegate delegate)
+ {
+ _set_delegate(delegate);
+ }
+
+ /**
+ * Return the array of repository ids for this object.
+ */
+ public String[] _ids()
+ {
+ return new String[] { DynUnionHelper.id() };
+ }
+
+ /**
+ * The remote call of DynAny methods is not possible.
+ *
+ * @throws MARSHAL, always.
+ */
+ public DynAny member()
+ throws InvalidValue
+ {
+ throw new MARSHAL(_DynAnyStub.NOT_APPLICABLE);
+ }
+
+ /**
+ * The remote call of DynAny methods is not possible.
+ *
+ * @throws MARSHAL, always.
+ */
+ public TCKind discriminator_kind()
+ {
+ throw new MARSHAL(_DynAnyStub.NOT_APPLICABLE);
+ }
+
+ /**
+ * The remote call of DynAny methods is not possible.
+ *
+ * @throws MARSHAL, always.
+ */
+ public DynAny get_discriminator()
+ {
+ throw new MARSHAL(_DynAnyStub.NOT_APPLICABLE);
+ }
+
+ /**
+ * The remote call of DynAny methods is not possible.
+ *
+ * @throws MARSHAL, always.
+ */
+ public boolean has_no_active_member()
+ {
+ throw new MARSHAL(_DynAnyStub.NOT_APPLICABLE);
+ }
+
+ /**
+ * The remote call of DynAny methods is not possible.
+ *
+ * @throws MARSHAL, always.
+ */
+ public TCKind member_kind()
+ throws InvalidValue
+ {
+ throw new MARSHAL(_DynAnyStub.NOT_APPLICABLE);
+ }
+
+ /**
+ * The remote call of DynAny methods is not possible.
+ *
+ * @throws MARSHAL, always.
+ */
+ public String member_name()
+ throws InvalidValue
+ {
+ throw new MARSHAL(_DynAnyStub.NOT_APPLICABLE);
+ }
+
+ /**
+ * The remote call of DynAny methods is not possible.
+ *
+ * @throws MARSHAL, always.
+ */
+ public void set_discriminator(DynAny _0)
+ throws TypeMismatch
+ {
+ throw new MARSHAL(_DynAnyStub.NOT_APPLICABLE);
+ }
+
+ /**
+ * The remote call of DynAny methods is not possible.
+ *
+ * @throws MARSHAL, always.
+ */
+ public void set_to_default_member()
+ throws TypeMismatch
+ {
+ throw new MARSHAL(_DynAnyStub.NOT_APPLICABLE);
+ }
+
+ /**
+ * The remote call of DynAny methods is not possible.
+ *
+ * @throws MARSHAL, always.
+ */
+ public void set_to_no_active_member()
+ throws TypeMismatch
+ {
+ throw new MARSHAL(_DynAnyStub.NOT_APPLICABLE);
+ }
+}
\ No newline at end of file
--- /dev/null
+/* _DynValueStub.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., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 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.DynamicAny;
+
+import org.omg.CORBA.MARSHAL;
+import org.omg.CORBA.TCKind;
+import org.omg.CORBA.portable.Delegate;
+import org.omg.DynamicAny.DynAnyPackage.InvalidValue;
+import org.omg.DynamicAny.DynAnyPackage.TypeMismatch;
+
+import java.io.Serializable;
+
+/**
+ * Should provide support for remote invocation of methods on DynValue. As
+ * DynValue can never be remote at least till 1.5 inclusive, this class is
+ * not in use.
+ *
+ * @author Audrius Meskauskas, Lithuania (AudriusA@Bioinformatics.org)
+ */
+public class _DynValueStub
+ extends _DynAnyStub
+ implements DynValue, Serializable
+{
+ /**
+ * Use serialVersionUID (v1.4) for interoperability.
+ */
+ private static final long serialVersionUID = 5815313794012360824L;
+
+ /**
+ * The purpose and value of this field are not documented.
+ */
+ public static final Class _opsClass = DynValueOperations.class;
+
+ /**
+ * Create the DynValue stub. To get the stub working,
+ * you must later set the delegate with
+ * {@link ObjectImpl#_set_delegate(Delegate)}.
+ */
+ public _DynValueStub()
+ {
+ }
+
+ /**
+ * Create the naming context stub with the given delegate.
+ */
+ public _DynValueStub(Delegate delegate)
+ {
+ _set_delegate(delegate);
+ }
+
+ /**
+ * Return the array of repository ids for this object.
+ */
+ public String[] _ids()
+ {
+ return new String[] { DynValueHelper.id() };
+ }
+
+ /**
+ * The remote call of DynAny methods is not possible.
+ *
+ * @throws MARSHAL, always.
+ */
+ public TCKind current_member_kind()
+ throws TypeMismatch, InvalidValue
+ {
+ throw new MARSHAL(_DynAnyStub.NOT_APPLICABLE);
+ }
+
+ /**
+ * The remote call of DynAny methods is not possible.
+ *
+ * @throws MARSHAL, always.
+ */
+ public String current_member_name()
+ throws TypeMismatch, InvalidValue
+ {
+ throw new MARSHAL(_DynAnyStub.NOT_APPLICABLE);
+ }
+
+ /**
+ * The remote call of DynAny methods is not possible.
+ *
+ * @throws MARSHAL, always.
+ */
+ public NameValuePair[] get_members()
+ throws InvalidValue
+ {
+ throw new MARSHAL(_DynAnyStub.NOT_APPLICABLE);
+ }
+
+ /**
+ * The remote call of DynAny methods is not possible.
+ *
+ * @throws MARSHAL, always.
+ */
+ public NameDynAnyPair[] get_members_as_dyn_any()
+ throws InvalidValue
+ {
+ throw new MARSHAL(_DynAnyStub.NOT_APPLICABLE);
+ }
+
+ /**
+ * The remote call of DynAny methods is not possible.
+ *
+ * @throws MARSHAL, always.
+ */
+ public void set_members(NameValuePair[] a_members)
+ throws TypeMismatch, InvalidValue
+ {
+ throw new MARSHAL(_DynAnyStub.NOT_APPLICABLE);
+ }
+
+ /**
+ * The remote call of DynAny methods is not possible.
+ *
+ * @throws MARSHAL, always.
+ */
+ public void set_members_as_dyn_any(NameDynAnyPair[] a_members)
+ throws TypeMismatch, InvalidValue
+ {
+ throw new MARSHAL(_DynAnyStub.NOT_APPLICABLE);
+ }
+
+ /**
+ * The remote call of DynAny methods is not possible.
+ *
+ * @throws MARSHAL, always.
+ */
+ public boolean is_null()
+ {
+ throw new MARSHAL(_DynAnyStub.NOT_APPLICABLE);
+ }
+
+ /**
+ * The remote call of DynAny methods is not possible.
+ *
+ * @throws MARSHAL, always.
+ */
+ public void set_to_null()
+ {
+ throw new MARSHAL(_DynAnyStub.NOT_APPLICABLE);
+ }
+
+ /**
+ * The remote call of DynAny methods is not possible.
+ *
+ * @throws MARSHAL, always.
+ */
+ public void set_to_value()
+ {
+ throw new MARSHAL(_DynAnyStub.NOT_APPLICABLE);
+ }
+}
\ No newline at end of file
--- /dev/null
+<!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., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 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.DynamicAny</title></head>
+
+<body>
+<p>DynAny's allow to work with data structures, exact content of those is not
+known at the time of compilation. In this way, the conception of DynAny
+remebers the java reflection mechanism. DynAny usually obtain the value from
+the {@link org.omg.CORBA.Any} that, if needed, can carry highly nested data
+structures (like array of sequences of unions). DynAny's allow to see/modify
+all parts of such structures. This is especially helpful for writing generic
+servers (bridges, event channels supporting, filtering and so on). Similarly,
+DynAny's can create an Any at runtime, without having static knowledge of its
+type. This is helpful for writing generic clients like browsers, debuggers or
+ user interface tools.
+</p><p>
+The API clearly states that DynAny and DynAnyFactory objects are local and
+cannot be transferred to remote server or client. While such methods are
+formally defined in the corresponding helpers, they simply always throw MARSHAL.
+</p><p>
+DynAny's are created by {@link DynAnyFactory}. The factory is obtaines by
+{@link org.omg.CORBA.ORB#resolve_initial_references):
+<code>
+ORB orb = ORB.init(new String[0], null);
+DynAnyFactory f = DynAnyFactoryHelper.narrow(orb.resolve_initial_references("DynAnyFactory"));
+</code>
+DynAny's are also returned by some methods, invoked on another DynAny.
+</p><p>
+The primitive types like string or char are wrapped into an ordinary DynAny. It
+has multiple methods for setting/getting the content like
+{@link DynAnyOperations#get_string()} or
+{@link DynAnyOperations#insert_string(String)}. The more complex types like
+sequences or structures are wrapped into specialised DynAny's, providing means
+to access the enclosed members. In this case, the DynAny has the
+"internal cursor", normally pointing at one of the members in the data
+structure. The "internal cursor" can be set to the needed position
+{@link DynAnyOperations#seek(int)} or advanced forward
+({@link DynAnyOperations#next()}. The member under cursor is returned by
+{@link DynAnyOperations#current_component()}. For composite DynAnys the
+methods like {@link DynAnyOperations#get_string()} or
+{@link DynAnyOperations#insert_string(String)} apply to the selected member,
+not to the complex DynAny in general.
+</p><p>
+DynAnys are created and optimized for traversing values extracted from anys
+or constructing values of anys at runtime. OMG does not recommend to use them
+for other purposes.
+</p><p>
+@author Audrius Meskauskas, Lithuania (AudriusA@Bioinformatics.org)
+</body>
+</html>
\ No newline at end of file
--- /dev/null
+/* ClientRequestInfo.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., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 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.PortableInterceptor;
+
+import org.omg.CORBA.portable.IDLEntity;
+
+/**
+ * Provides request information, accessible for the
+ * {@link ClientRequestInterceptor}.
+ *
+ * @author Audrius Meskauskas, Lithuania (AudriusA@Bioinformatics.org)
+ */
+public interface ClientRequestInfo extends ClientRequestInfoOperations,
+ org.omg.CORBA.Object,
+ IDLEntity,
+ RequestInfo
+{
+}
\ No newline at end of file
--- /dev/null
+/* ClientRequestInfoOperations.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., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 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.PortableInterceptor;
+
+import org.omg.CORBA.Any;
+import org.omg.CORBA.BAD_PARAM;
+import org.omg.CORBA.INV_POLICY;
+import org.omg.CORBA.Policy;
+import org.omg.IOP.ServiceContext;
+import org.omg.IOP.TaggedComponent;
+import org.omg.IOP.TaggedProfile;
+
+/**
+ * Provides request information, accessible for the
+ * {@linkplain ClientRequestInterceptor}. Some methods of this interface are
+ * not valid at all interception points. The following table shows the validity
+ * of each method. If it is not valid, BAD_INV_ORDER minor 14 will be thrown.
+ *
+ * <table border="1">
+ * <tr>
+ * <th></th>
+ * <th>{@linkplain ClientRequestInterceptorOperations#send_request send_request}</th>
+ * <th>{@linkplain ClientRequestInterceptorOperations#send_poll send_poll}</th>
+ * <th>{@linkplain ClientRequestInterceptorOperations#receive_reply receive_reply}</th>
+ * <th>{@linkplain ClientRequestInterceptorOperations#receive_exception receive_exception}</th>
+ * <th>{@linkplain ClientRequestInterceptorOperations#receive_other receive_other}</th>
+ * </tr>
+ * <tr>
+ * <td colspan="6" align="center" bgcolor="#E0E0FF"><i>Inherited from
+ * {@linkplain RequestInfoOperations}:</i></td>
+ * </tr>
+ * <tr>
+ * <th>{@linkplain RequestInfoOperations#arguments arguments}</th>
+ * <td bgcolor="#E0E0E0" title="in and inout only">yes <sub><a href="#1">1</a></sub></td>
+ * <td bgcolor="lightgray">no </td>
+ * <td>yes</td>
+ * <td bgcolor="lightgray">no </td>
+ * <td bgcolor="lightgray">no </td>
+ * </tr>
+ * <tr>
+ * <th>{@linkplain RequestInfoOperations#exceptions exceptions}</th>
+ * <td>yes</td>
+ * <td bgcolor="lightgray">no </td>
+ * <td colspan="3" align ="center">yes</td>
+ * </tr>
+ * <tr>
+ * <th>{@linkplain RequestInfoOperations#contexts contexts}</th>
+ * <td>yes</td>
+ * <td bgcolor="lightgray">no </td>
+ * <td colspan="3" align ="center">yes</td>
+ * </tr>
+ * <tr>
+ * <th>{@linkplain RequestInfoOperations#operation_context operation_context}</th>
+ * <td>yes</td>
+ * <td bgcolor="lightgray">no </td>
+ * <td colspan="3" align ="center">yes</td>
+ * </tr>
+ * </tr>
+ * <tr>
+ * <th>{@linkplain RequestInfoOperations#result result}</th>
+ * <td bgcolor="lightgray">no </td>
+ * <td bgcolor="lightgray">no </td>
+ * <td>yes</td>
+ * <td bgcolor="lightgray">no </td>
+ * <td bgcolor="lightgray">no </td>
+ * </tr>
+ * <tr>
+ * <th>{@linkplain RequestInfoOperations#sync_scope sync_scope}</th>
+ * <td>yes</td>
+ * <td bgcolor="lightgray">no </td>
+ * <td colspan="3" align ="center">yes</td>
+ * </tr>
+ * </tr>
+ * <tr>
+ * <th>{@linkplain RequestInfoOperations#reply_status reply_status}</th>
+ * <td bgcolor="lightgray">no </td>
+ * <td bgcolor="lightgray">no </td>
+ * <td colspan="3" align ="center">yes</td>
+ * </tr>
+ * <tr>
+ * <th>{@linkplain RequestInfoOperations#forward_reference forward_reference}</th>
+ * <td>no</td>
+ * <td bgcolor="lightgray" colspan="3" align="center">no</td>
+ * <td bgcolor="#E0E0E0" title="When reply_status = LOCATION_FORWARD">yes <sub><a
+ * href="#2">2</a></sub> </td>
+ * </tr>
+ * <tr>
+ * <th>{@linkplain RequestInfoOperations#get_request_service_context get_request_service_context}</th>
+ * <td>yes</td>
+ * <td bgcolor="lightgray">no </td>
+ * <td colspan="3" align ="center">yes</td>
+ * </tr>
+ * <tr>
+ * <th>{@linkplain RequestInfoOperations#get_reply_service_context get_reply_service_context}</th>
+ * <td bgcolor="lightgray">no </td>
+ * <td bgcolor="lightgray">no </td>
+ * <td colspan="3" align ="center">yes</td>
+ * </tr>
+ * </tr>
+ * <tr>
+ * <th>{@linkplain RequestInfoOperations#request_id request_id}</th>
+ * <td colspan="5" align ="center">yes</td>
+ * </tr>
+ * <tr>
+ * <th>{@linkplain RequestInfoOperations#operation operation}</th>
+ * <td colspan="5" align ="center">yes</td>
+ * </tr>
+ * <tr>
+ * <th>{@linkplain RequestInfoOperations#response_expected response_expected}</th>
+ * <td colspan="5" align ="center">yes</td>
+ * </tr>
+ * <tr>
+ * <th>{@linkplain RequestInfoOperations#get_slot get_slot}</th>
+ * <td colspan="5" align ="center">yes</td>
+ * </tr>
+ * <tr>
+ * <td colspan="6" align="center" bgcolor="#E0E0FF"><i>ClientRequestInfo-specific:</i></td>
+ * </tr>
+ * <tr>
+ * <th>{@linkplain #target target}</th>
+ * <td colspan="5" align ="center">yes</td>
+ * </tr>
+ * <tr>
+ * <th>{@linkplain #effective_target effective_target}</th>
+ * <td colspan="5" align ="center">yes</td>
+ * </tr>
+ * <tr>
+ * <th>{@linkplain #effective_profile effective_profile}</th>
+ * <td colspan="5" align ="center">yes</td>
+ * </tr>
+ * <tr>
+ * <th>{@linkplain #received_exception received_exception}</th>
+ * <td bgcolor="lightgray" colspan="3" align="center">no</td>
+ * <td>yes</td>
+ * <td bgcolor="lightgray">no </td>
+ * </tr>
+ * <tr>
+ * <th>{@linkplain #received_exception_id received_exception_id}</th>
+ * <td bgcolor="lightgray" colspan="3" align="center">no</td>
+ * <td>yes</td>
+ * <td bgcolor="lightgray">no </td>
+ * </tr>
+ * <tr>
+ * <th>{@linkplain #get_effective_component get_effective_component}</th>
+ * <td>yes</td>
+ * <td bgcolor="lightgray">no </td>
+ * <td colspan="3" align ="center">yes</td>
+ * </tr>
+ * <tr>
+ * <th>{@linkplain #get_effective_components get_effective_components}</th>
+ * <td>yes</td>
+ * <td bgcolor="lightgray">no </td>
+ * <td colspan="3" align ="center">yes</td>
+ * </tr>
+ * <tr>
+ * <th>{@linkplain #get_request_policy get_request_policy}</th>
+ * <td>yes</td>
+ * <td bgcolor="lightgray">no </td>
+ * <td colspan="3" align ="center">yes</td>
+ * </tr>
+ * <tr>
+ * <th>{@linkplain #add_request_service_context add_request_service_context}</th>
+ * <td>yes</td>
+ * <td bgcolor="lightgray" colspan="4" align="center">no</td>
+ * </tr>
+ * <tr>
+ * <th></th>
+ * <th>{@linkplain ClientRequestInterceptorOperations#send_request send_request}</th>
+ * <th>{@linkplain ClientRequestInterceptorOperations#send_poll send_poll}</th>
+ * <th>{@linkplain ClientRequestInterceptorOperations#receive_reply receive_reply}</th>
+ * <th>{@linkplain ClientRequestInterceptorOperations#receive_exception receive_exception}</th>
+ * <th>{@linkplain ClientRequestInterceptorOperations#receive_other receive_other}</th>
+ * </tr>
+ * </table>
+ * <ol>
+ * <li><a name="1">When ClientRequestInfo is passed to send_request, there is
+ * an entry in the list for every argument, but only the in and inout arguments
+ * will be available.</a></li>
+ * <li><a name="2">If the reply_status atribute is not LOCATION_FORWARD,
+ * accessing this attribute will throw BAD_INV_ORDER with a standard minor code
+ * of 14.</a></li>
+ * </ol>
+ *
+ * @author Audrius Meskauskas, Lithuania (AudriusA@Bioinformatics.org)
+ */
+public interface ClientRequestInfoOperations extends RequestInfoOperations
+{
+ /**
+ * Returns the object on that the client has invoked the the operation. If the
+ * request was forwarded, it will not be the same object that actually
+ * processed the request.
+ *
+ * @return the initial client invocation target.
+ *
+ * @see #effective_target()
+ */
+ org.omg.CORBA.Object target();
+
+ /**
+ * Returns the object on that the operation will be invoked after handling the
+ * possible forwarding.
+ *
+ * @return the final invocation target.
+ *
+ * @see #target()
+ */
+ org.omg.CORBA.Object effective_target();
+
+ /**
+ * Returns the tagged profile (IOR) of the invocation target. If the request
+ * was forwarded, the method returns the new location, shown by the forwarding
+ * message.
+ *
+ * @return the invocation IOR.
+ */
+ TaggedProfile effective_profile();
+
+ /**
+ * Returns the given component of the invocation target profile. If the
+ * profile contains multiple components with the same Id, it is not defined,
+ * which one will be returned.
+ *
+ * @param id the component id.
+ *
+ * @return the profile component with the given Id.
+ *
+ * @throws BAD_PARAM minor 28 in there are no any components with the given Id
+ * in the profile.
+ */
+ TaggedComponent get_effective_component(int id) throws BAD_PARAM;
+
+ /**
+ * Returns the given components of the invocation target profile. This method
+ * is uses when the profile may contain multiple components with the same Id.
+ *
+ * @param id the component id.
+ *
+ * @return the array of all profile components with the given Id.
+ *
+ * @throws BAD_PARAM minor 28 in there are no any components with the given Id
+ * in the profile.
+ */
+ TaggedComponent[] get_effective_components(int id) throws BAD_PARAM;
+
+ /**
+ * This should return the policy of the given type that applies to this
+ * operation, but it is not implemented up till JDK 1.5 inclusive.
+ *
+ * @param type the type of the policy being requested.
+ *
+ * @return should return the policy that applies to this operation.
+ *
+ * @throws NO_IMPLEMENT always.
+ */
+ Policy get_request_policy(int type) throws INV_POLICY;
+
+ /**
+ * Returns the repository id of the remote exception that was thrown on the
+ * server side.
+ *
+ * @return the exception repository id.
+ *
+ * @see #received_exception()
+ */
+ String received_exception_id();
+
+ /**
+ * Returns the remote exception that was thrown on the server side.
+ *
+ * @return the Any, holding this exception.
+ *
+ * @see #received_exception_id()
+ */
+ Any received_exception();
+
+ /**
+ * Allows the interceptor to add the service contexts to the request. Such
+ * added contexts can carry arbitrary data and can be later accessed on the
+ * server side by the server request interceptor, using
+ * {@link RequestInfoOperations#get_request_service_context}.
+ *
+ * @param service_context the context to add.
+ * @param replace if true, the existing context with the same Id will be
+ * replaced. If false, the BAD_INV_ORDER will be thrown in that case.
+ *
+ * @throws BAD_INV_ORDER minor 15 if the context with the same Id already
+ * exists and replace=false.
+ */
+ void add_request_service_context(ServiceContext service_context,
+ boolean replace
+ );
+}
\ No newline at end of file
--- /dev/null
+/* ClientRequestInterceptor.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., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 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.PortableInterceptor;
+
+import org.omg.CORBA.portable.IDLEntity;
+
+/**
+ * A client side request interceptor that is notified on various request
+ * processing steps on a client side.
+ *
+ * @author Audrius Meskauskas, Lithuania (AudriusA@Bioinformatics.org)
+ */
+public interface ClientRequestInterceptor extends Interceptor,
+ ClientRequestInterceptorOperations,
+ org.omg.CORBA.Object,
+ IDLEntity
+{
+}
\ No newline at end of file
--- /dev/null
+/* ClientRequestInterceptorOperations.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., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 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.PortableInterceptor;
+
+
+/**
+ * Defines operations, applicable to the client side request interceptor. The
+ * operations are called by ORB at the appropriate interception points.
+ *
+ * @author Audrius Meskauskas, Lithuania (AudriusA@Bioinformatics.org)
+ */
+public interface ClientRequestInterceptorOperations
+ extends InterceptorOperations
+{
+ /**
+ * ORB calls this method before sending the request to the server.
+ *
+ * @param info the object for accessing and manipulating the request
+ * information.
+ *
+ * @throws SystemException if it does, the send_request is not called for the
+ * subsequent interceptors, calling receive_exception instead. The completion
+ * status of this exception must be COMPLETED_NO.
+ *
+ * @throws ForwardRequest to forward the invocation to another target. The
+ * send_request is not called for the subsequent interceptors, calling
+ * receive_other instead.
+ */
+ void send_request(ClientRequestInfo info) throws ForwardRequest;
+
+ /**
+ * ORB calls this method after the normal reply is received from the server
+ * and before the control is returned to the calling client code.
+ *
+ * @param info the object for accessing and manipulating the request
+ * information.
+ *
+ * @throws SystemException if it does, the receive_reply is not called for the
+ * subsequent interceptors, calling receive_exception instead. The completion
+ * status of this exception must be COMPLETED_YES.
+ */
+ void receive_reply(ClientRequestInfo info);
+
+ /**
+ * ORB calls this method after the receiving the message that a remote
+ * exception has been thrown on a server side and before raising this
+ * exception in the client side.
+ *
+ * @param info the object for accessing and manipulating the request
+ * information.
+ *
+ * @throws SystemException has the effect of changing the exception that
+ * successive interceptors receive on their calls to receive_other. If the
+ * original exception is a system exception, the completion_status of the new
+ * exception must match the exception being replaced. If the original
+ * exception is a user exception, then the completion_status of the new
+ * exception must be COMPLETED_YES.
+ *
+ * @throws ForwardRequest to forward the invocation to another target. The
+ * receive_exception is not called for the subsequent interceptors, calling
+ * receive_other instead. If the completion_status of the original exception
+ * is not a COMPLETED_NO, the ForwardRequest must not be raised.
+ */
+ void receive_exception(ClientRequestInfo info) throws ForwardRequest;
+
+ /**
+ * /** ORB normally calls this method after receiving the forwarding message.
+ *
+ * @param info the object for accessing and manipulating the request
+ * information.
+ *
+ * @throws SystemException if it does, the receive_other is not called for the
+ * subsequent interceptors, calling receive_exception instead.
+ *
+ * @throws ForwardRequest has the effect of changing the redirection that
+ * successive interceptors receive on their calls to receive_other.
+ */
+ void receive_other(ClientRequestInfo info) throws ForwardRequest;
+
+ /**
+ * This method is called by if ORB uses the Time- Independent Invocation (TII)
+ * polling.
+ *
+ * @param info the object for accessing and manipulating the request
+ * information.
+ *
+ * @throws SystemException if it does, the send_poll is not called for the
+ * subsequent interceptors, calling receive_exception instead. The completion
+ * status of this exception must be COMPLETED_NO.
+ */
+ void send_poll(ClientRequestInfo info);
+}
\ No newline at end of file
--- /dev/null
+/* Current.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., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 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.PortableInterceptor;
+
+import org.omg.CORBA.portable.IDLEntity;
+
+/**
+ * <p>
+ * The portable interceptor Current (PICurrent) contains multiple slots where an
+ * interceptor can rememeber the request - specific values between subsequent
+ * calls of the interceptor methods. In multithreaded environment, it is not
+ * possible just to store such data in the interceptor object fields.
+ * </p>
+ * <p>
+ * On the client side, it is possible to set the initial slot values by
+ * modifying slots on the Current, returend by ORB.resolve_initial_references
+ * ("PICurrent"). The returned value is narrowed with the
+ * {@link CurrentHelper#narrow}. On the subsequent invocation, made from the
+ * same thread, the interceptors will see the initial slot values as they were
+ * set using this approach.
+ * </p>
+ * <p>
+ * There are no way to set the initial values for the server side interceptors,
+ * the default values (Any with typecode TCKind.tk_null) should be always
+ * assumed.
+ * </p>
+ * <p>
+ * Since an Interceptor is running in a thread, it is running with a thread
+ * context and there is a PICurrent on that context. If the Interceptor calls
+ * ORB.resolve_initial_references ("PICurrent"), it gets the PICurrent within
+ * its thread scope. This PICurrent is different than the request scope
+ * PICurrent that the Interceptor obtains via calls to the Client- or Server-
+ * RequestInfo object.
+ * </p>
+ * <p>
+ * On the client side the PICurrent can be used to detect the recursive
+ * invocations, performed by interceptors. If one of the interceptors makes call
+ * via the same ORB, this call is then showed to all interceptors, including the
+ * interceptor that made it. To avoid infinite recursion, the during each call
+ * this interceptor can set some "recursion flag" into one of the slots of the
+ * PICurrent. If the flag is set on the entry point, this indicates a recursive
+ * call of that request.
+ * </p>
+ */
+public interface Current extends CurrentOperations,
+ org.omg.CORBA.Current,
+ IDLEntity
+{
+}
\ No newline at end of file
--- /dev/null
+/* CurrentHelper.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., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 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.PortableInterceptor;
+
+import org.omg.CORBA.Any;
+import org.omg.CORBA.BAD_PARAM;
+import org.omg.CORBA.MARSHAL;
+import org.omg.CORBA.ORB;
+import org.omg.CORBA.TypeCode;
+import org.omg.CORBA.portable.InputStream;
+import org.omg.CORBA.portable.OutputStream;
+
+/**
+ * The helper operations for the CORBA object {@link Current}.
+ *
+ * @author Audrius Meskauskas, Lithuania (AudriusA@Bioinformatics.org)
+ */
+public abstract class CurrentHelper
+{
+ /**
+ * The cached {@link Current} typecode, computed once.
+ */
+ private static TypeCode typeCode;
+
+ /**
+ * Get the type code of the {@link Current}.
+ */
+ public static TypeCode type()
+ {
+ if (typeCode == null)
+ {
+ typeCode = ORB.init().create_interface_tc(id(), "Current");
+ }
+ return typeCode;
+ }
+
+ /**
+ * Insert the Current into the given Any.
+ *
+ * @param any the Any to insert into.
+ * @param that the Current to insert.
+ */
+ public static void insert(Any any, Current that)
+ {
+ any.insert_Object(that);
+ }
+
+ /**
+ * Extract the Current from given Any.
+ *
+ * @throws BAD_OPERATION if the passed Any does not contain Current.
+ */
+ public static Current extract(Any any)
+ {
+ return narrow(any.extract_Object());
+ }
+
+ /**
+ * Get the Current repository id.
+ *
+ * @return "org.omg.PortableInterceptor.CurrentOperations", always.
+ */
+ public static String id()
+ {
+ return "IDL:omg.org/PortableInterceptor/Current:1.0";
+ }
+
+ /**
+ * Cast the passed object into the Current.
+ *
+ * @param obj the object to narrow.
+ * @return narrowed instance.
+ * @throws BAD_PARAM if the passed object is not a Current.
+ */
+ public static Current narrow(org.omg.CORBA.Object obj)
+ {
+ if (obj == null)
+ {
+ return null;
+ }
+ else if (obj instanceof Current)
+ {
+ return (Current) obj;
+ }
+ else
+ {
+ throw new BAD_PARAM("Not a Current");
+ }
+ }
+
+ /**
+ * Not supported for compatibility reasons.
+ *
+ * @specnote Not supported by Sun at least till jdk 1.5 inclusive.
+ *
+ * @throws MARSHAL always.
+ */
+ public static Current read(InputStream input)
+ {
+ throw new MARSHAL();
+ }
+
+ /**
+ * Not supported for compatibility reasons.
+ *
+ * @specnote Not supported by Sun at least till jdk 1.5 inclusive.
+ *
+ * @throws MARSHAL always.
+ */
+ public static void write(OutputStream output, Current value)
+ {
+ throw new MARSHAL();
+ }
+}
\ No newline at end of file
--- /dev/null
+/* CurrentOperations.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., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 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.PortableInterceptor;
+
+import org.omg.CORBA.Any;
+import org.omg.CORBA.BAD_INV_ORDER;
+
+/**
+ * Defines the operations, applicable to the portable interceptor Current.
+ *
+ * Portable Interceptors Current (also known as PICurrent) is a slot table. Each
+ * slot has an integer identifier, can hold a CORBA {@link Any} and is used by
+ * some service to transfer data between thread and request contexts. Each
+ * service which wishes to use PICurrent reserves a slot or slots at
+ * initialization time and uses those slots during the processing of requests
+ * and replies.
+ *
+ * @author Audrius Meskauskas, Lithuania (AudriusA@Bioinformatics.org)
+ */
+public interface CurrentOperations
+ extends org.omg.CORBA.CurrentOperations
+{
+ /**
+ * Get data from the slot with the given slot_id.
+ *
+ * @param slot_id the slot slot_id.
+ *
+ * @return the Any that was stored in the slot. If the given slot has not been
+ * set, the returned Any contains a type code with a TCKind value of tk_null
+ * and has no value.
+ *
+ * @throws InvalidSlot for the unknown slot.
+ * @throws BAD_INV_ORDER minor 10 if called from the {@link ORBInitializer}
+ * methods.
+ */
+ Any get_slot(int slot_id) throws InvalidSlot, BAD_INV_ORDER;
+
+ /**
+ * Sets data for the slot with the given slot_id.
+ *
+ * @param slot_id the slot slot_id.
+ *
+ * @param data the Any that will be stored into the slot.
+ *
+ * @throws InvalidSlot for the unknown slot.
+ * @throws BAD_INV_ORDER minor 10 if called from the {@link ORBInitializer}
+ * methods.
+ *
+ */
+ void set_slot(int slot_id, Any data) throws InvalidSlot, BAD_INV_ORDER;
+}
\ No newline at end of file
--- /dev/null
+/* ForwardRequest.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., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 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.PortableInterceptor;
+
+import org.omg.CORBA.UserException;
+import org.omg.CORBA.portable.IDLEntity;
+
+import java.io.Serializable;
+
+/**
+ * The ForwardRequest is thrown by interceptors to forward the request to
+ * another target. The field {@link #forward} contains the reference to this
+ * alternative location.
+ *
+ * @author Audrius Meskauskas, Lithuania (AudriusA@Bioinformatics.org)
+ */
+public class ForwardRequest extends UserException implements IDLEntity,
+ Serializable
+{
+ /**
+ * Use serialVersionUID (v1.4) for interoperability.
+ */
+ private static final long serialVersionUID = 2128007517550526397L;
+
+ /**
+ * The field forward.
+ */
+ public org.omg.CORBA.Object forward;
+
+ /**
+ * Create ForwardRequest with no explaining
+ * message and all fields left unitialised with the default initial java values.
+ */
+ public ForwardRequest()
+ {
+ }
+
+ /**
+ * Create the ForwardRequest with explaining
+ * message and all fields initialised to the given values.
+ *
+ * @param why a string, explaining, why this exception has been thrown.
+ * @param a_forward a value for forward.
+ */
+ public ForwardRequest(String why, org.omg.CORBA.Object a_forward)
+ {
+ super(why);
+ this.forward = a_forward;
+ }
+
+ /**
+ * Create the ForwardRequest without explaining
+ * message and all fields initialised to the given values.
+ *
+ * @param a_forward a value for forward.
+ */
+ public ForwardRequest(org.omg.CORBA.Object a_forward)
+ {
+ this.forward = a_forward;
+ }
+}
\ No newline at end of file
--- /dev/null
+/* ForwardRequestHelper.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., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 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.PortableInterceptor;
+
+import gnu.CORBA.Interceptor.ForwardRequestHolder;
+
+import org.omg.CORBA.Any;
+import org.omg.CORBA.BAD_OPERATION;
+import org.omg.CORBA.ORB;
+import org.omg.CORBA.ObjectHelper;
+import org.omg.CORBA.StructMember;
+import org.omg.CORBA.TypeCode;
+import org.omg.CORBA.portable.InputStream;
+import org.omg.CORBA.portable.OutputStream;
+
+/**
+ * The helper operations for the exception {@link ForwardRequest}.
+ *
+ * @author Audrius Meskauskas, Lithuania (AudriusA@Bioinformatics.org)
+ */
+public abstract class ForwardRequestHelper
+{
+ /**
+ * The cached typecode value, computed only once.
+ */
+ private static TypeCode typeCode;
+
+ /**
+ * Create the ForwardRequest typecode (structure, named "ForwardRequest"). The
+ * typecode states that the structure contains the following fields: forward.
+ */
+ public static TypeCode type()
+ {
+ if (typeCode == null)
+ {
+ ORB orb = ORB.init();
+ StructMember[] members = new StructMember[ 1 ];
+
+ TypeCode field = ObjectHelper.type();
+ members [ 0 ] = new StructMember("forward", field, null);
+ typeCode = orb.create_exception_tc(id(), "ForwardRequest", members);
+ }
+ return typeCode;
+ }
+
+ /**
+ * Insert the ForwardRequest into the given Any. This method uses the
+ * ForwardRequestHolder.
+ *
+ * @param any the Any to insert into.
+ * @param that the ForwardRequest to insert.
+ */
+ public static void insert(Any any, ForwardRequest that)
+ {
+ any.insert_Streamable(new ForwardRequestHolder(that));
+ }
+
+ /**
+ * Extract the ForwardRequest from given Any. This method uses the
+ * ForwardRequestHolder.
+ *
+ * @throws BAD_OPERATION if the passed Any does not contain ForwardRequest.
+ */
+ public static ForwardRequest extract(Any any)
+ {
+ try
+ {
+ return ((ForwardRequestHolder) any.extract_Streamable()).value;
+ }
+ catch (ClassCastException cex)
+ {
+ BAD_OPERATION bad = new BAD_OPERATION(id() + " expected");
+ bad.initCause(cex);
+ throw bad;
+ }
+ }
+
+ /**
+ * Get the ForwardRequest repository id.
+ *
+ * @return "IDL:omg.org/PortableInterceptor/ForwardRequest:1.0", always.
+ */
+ public static String id()
+ {
+ return "IDL:omg.org/PortableInterceptor/ForwardRequest:1.0";
+ }
+
+ /**
+ * Read the exception from the CDR intput stream.
+ *
+ * @param input a org.omg.CORBA.portable stream to read from.
+ */
+ public static ForwardRequest read(InputStream input)
+ {
+ // Read (and discard) the exception repository id.
+ input.read_string();
+
+ ForwardRequest value = new ForwardRequest();
+
+ value.forward = input.read_Object();
+ return value;
+ }
+
+ /**
+ * Write the exception to the CDR output stream.
+ *
+ * @param output a org.omg.CORBA.portable stream stream to write into.
+ * @param value a value to write.
+ */
+ public static void write(OutputStream output, ForwardRequest value)
+ {
+ // Write the exception repository id.
+ output.write_string(id());
+ output.write_Object(value.forward);
+ }
+}
\ No newline at end of file
--- /dev/null
+/* IORInfo.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., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 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.PortableInterceptor;
+
+import org.omg.CORBA.portable.IDLEntity;
+
+import java.io.Serializable;
+
+/**
+ * Provides the server-side ORB service possibility to add components to the new
+ * IOR being created. Also, provides access to policies, applicable to the
+ * object, referenced by that IOR. The ORB passes an instance of IORInfo as a
+ * parameter to {@link IORInterceptor#establish_components}.
+ *
+ * @author Audrius Meskauskas, Lithuania (AudriusA@Bioinformatics.org)
+ */
+public interface IORInfo extends IORInfoOperations,
+ IDLEntity,
+ org.omg.CORBA.Object,
+ Serializable
+{
+}
\ No newline at end of file
--- /dev/null
+/* IORInfoOperations.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., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 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.PortableInterceptor;
+
+import org.omg.CORBA.Policy;
+import org.omg.IOP.TaggedComponent;
+
+/**
+ * The ORB service uses this interface to add the service specific components to
+ * the new IOR being constructed. The interface provides also possibility to get
+ * the POA policies the apply to the IOR being constructed.
+ *
+ * @author Audrius Meskauskas, Lithuania (AudriusA@Bioinformatics.org)
+ */
+public interface IORInfoOperations
+{
+ /**
+ * Adds a service-specific component to the IOR profile being constructed.
+ *
+ * @param tagged_component a tagged component being added.
+ *
+ * @param profile_id the IOR profile to that the component must be added.
+ * The 0 value ({@link org.omg.IOP.TAG_INTERNET_IOP#value}) adds to the
+ * Internet profile where host and port are stored by default.
+ */
+ void add_ior_component_to_profile(TaggedComponent tagged_component,
+ int profile_id
+ );
+
+ /**
+ * Adds a service-specific component to the IOR profile being constructed.
+ * The specified component will be included in all profiles, present in the
+ * IOR being constructed.
+ *
+ * @param tagged_component a tagged component being added.
+ */
+ void add_ior_component(TaggedComponent tagged_component);
+
+ /**
+ * Get the server side policy for an IOR being constructed. The method returns
+ * policies applying for POA where the object, represented by this IOR, is
+ * connected.
+ *
+ * @param policy_type the type of the policy.
+ *
+ * @return the policy of the given type that applies to the IOR being
+ * constructed.
+ *
+ * @see org.omg.PortableServer.POAOperations#create_POA
+ */
+ Policy get_effective_policy(int policy_type);
+}
\ No newline at end of file
--- /dev/null
+/* IORInterceptor.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., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 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.PortableInterceptor;
+
+import org.omg.CORBA.portable.IDLEntity;
+
+import java.io.Serializable;
+
+/**
+ * An ORB service implementation may need to add information describing the
+ * serverORB service related capabilities to object references
+ * (IORs). This is supported through the IORInterceptor and {@link IORInfo}
+ * interfaces. The IOR Interceptor is used to establish tagged components in the
+ * profiles within a new IOR being created.
+ *
+ * @author Audrius Meskauskas, Lithuania (AudriusA@Bioinformatics.org)
+ */
+public interface IORInterceptor extends IDLEntity,
+ Interceptor,
+ InterceptorOperations,
+ IORInterceptorOperations,
+ org.omg.CORBA.Object,
+ Serializable
+{
+}
\ No newline at end of file
--- /dev/null
+/* IORInterceptorOperations.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., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 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.PortableInterceptor;
+
+
+/**
+ * Defines operation, applicable to the IORInterceptor.
+ *
+ * @author Audrius Meskauskas, Lithuania (AudriusA@Bioinformatics.org)
+ */
+public interface IORInterceptorOperations extends InterceptorOperations
+{
+ /**
+ * A server side ORB calls this method on all registered IORInterceptor's when
+ * creating the object reference (IOR). The interceptors have the possibility
+ * to add additional tags to the IOR being created.
+ *
+ * @param info the interface class providing methods to insert additional tags
+ * into IOR being constructed. The same instan
+ */
+ public void establish_components(IORInfo info);
+}
\ No newline at end of file
--- /dev/null
+/* Interceptor.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., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 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.PortableInterceptor;
+
+import org.omg.CORBA.Object;
+import org.omg.CORBA.portable.IDLEntity;
+
+/**
+ * Portable Interceptors are hooks into the ORB through which ORB services can
+ * intercept the normal flow of execution in creation of IOR, sending request,
+ * receiving request and returning the reply.
+ *
+ * See {@link ORBInitializer} for explanation, how the interceptors are
+ * registered within the ORB.
+ *
+ * @author Audrius Meskauskas, Lithuania (AudriusA@Bioinformatics.org)
+ */
+public interface Interceptor extends InterceptorOperations,
+ Object,
+ IDLEntity
+{
+}
\ No newline at end of file
--- /dev/null
+/* InterceptorOperations.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., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 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.PortableInterceptor;
+
+
+/**
+ * Defines operations, applicable for all types of {@link Interceptor}.
+ * The the derived interfaces define additional operations for they
+ * specific functionality.
+ *
+ * Portable Interceptors are hooks into the ORB through which ORB services can
+ * intercept the normal flow of execution in creation of IOR, sending request,
+ * receiving request and returning the reply.
+ *
+ * See {@link org.omg.PortableInterceptor} for more details about the possible
+ * interceptors and how to register them within the ORB.
+ *
+ * @author Audrius Meskauskas, Lithuania (AudriusA@Bioinformatics.org)
+ */
+public interface InterceptorOperations
+{
+ /**
+ * This method is called when orb is being destroyed and destroys
+ * the interceptor. The ORB calls this method after completing all
+ * incoming requests. The method body should not invoke methods on other
+ * object, belonging to ORB being destoryed, as in this stage it is no
+ * longer capable to act as server. It is still, however, capable
+ * to act as a client, permitting remote invocations on other objects.
+ */
+ void destroy();
+
+ /**
+ * All interceptors of the same type, registered on the single ORB, must
+ * either have different names or be anonymous. The name of the anonymous
+ * interceptor is an empty string. The ORB supports multiple anonymous
+ * interceptors of the same type.
+ *
+ * @return the name of the interceptor.
+ */
+ String name();
+}
\ No newline at end of file
--- /dev/null
+/* InvalidSlot.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., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 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.PortableInterceptor;
+
+import org.omg.CORBA.UserException;
+import org.omg.CORBA.portable.IDLEntity;
+
+import java.io.Serializable;
+
+/**
+ * The InvalidSlot is thrown when the slot identifier, passed in one of the
+ * methods, related to {@link Current}, does not define a valid slot.
+ *
+ * @author Audrius Meskauskas, Lithuania (AudriusA@Bioinformatics.org)
+ */
+public class InvalidSlot extends UserException implements IDLEntity,
+ Serializable
+{
+ /**
+ * Use serialVersionUID (v1.4) for interoperability.
+ */
+ private static final long serialVersionUID = 2471643293291821501L;
+
+ /**
+ * Create InvalidSlot with no explaining message.
+ */
+ public InvalidSlot()
+ {
+ }
+
+ /**
+ * Create the InvalidSlot with explaining message.
+ *
+ * @param why a string, explaining, why this exception has been thrown.
+ */
+ public InvalidSlot(String why)
+ {
+ super(why);
+ }
+}
\ No newline at end of file
--- /dev/null
+/* InvalidSlotHelper.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., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 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.PortableInterceptor;
+
+import gnu.CORBA.EmptyExceptionHolder;
+
+import org.omg.CORBA.Any;
+import org.omg.CORBA.BAD_OPERATION;
+import org.omg.CORBA.ORB;
+import org.omg.CORBA.StructMember;
+import org.omg.CORBA.TypeCode;
+import org.omg.CORBA.portable.InputStream;
+import org.omg.CORBA.portable.OutputStream;
+
+/**
+ * The helper operations for the exception {@link InvalidSlot}.
+ *
+ * @author Audrius Meskauskas, Lithuania (AudriusA@Bioinformatics.org)
+ */
+public abstract class InvalidSlotHelper
+{
+ /**
+ * The cached typecode value, computed only once.
+ */
+ private static TypeCode typeCode;
+
+ /**
+ * Create the InvalidSlot typecode (structure, named "InvalidSlot").
+ */
+ public static TypeCode type()
+ {
+ if (typeCode == null)
+ {
+ ORB orb = ORB.init();
+ StructMember[] members = new StructMember[ 0 ];
+ typeCode = orb.create_exception_tc(id(), "InvalidSlot", members);
+ }
+ return typeCode;
+ }
+
+ /*
+ * Every user exception with no user defined fields can use
+ * EmptyExceptionHolder
+ */
+
+ /**
+ * Insert the InvalidSlot into the given Any.
+ *
+ * @param any the Any to insert into.
+ * @param that the InvalidSlot to insert.
+ */
+ public static void insert(Any any, InvalidSlot that)
+ {
+ any.insert_Streamable(new EmptyExceptionHolder(that, type()));
+ }
+
+ /**
+ * Extract the InvalidSlot from given Any.
+ *
+ * @throws BAD_OPERATION if the passed Any does not contain InvalidSlot.
+ */
+ public static InvalidSlot extract(Any any)
+ {
+ try
+ {
+ EmptyExceptionHolder h =
+ (EmptyExceptionHolder) any.extract_Streamable();
+ return (InvalidSlot) h.value;
+ }
+ catch (ClassCastException cex)
+ {
+ BAD_OPERATION bad = new BAD_OPERATION("InvalidSlot expected");
+ bad.initCause(cex);
+ throw bad;
+ }
+ }
+
+ /**
+ * Get the InvalidSlot repository id.
+ *
+ * @return "IDL:omg.org/PortableInterceptor/InvalidSlot:1.0", always.
+ */
+ public static String id()
+ {
+ return "IDL:omg.org/PortableInterceptor/InvalidSlot:1.0";
+ }
+
+ /**
+ * Read the exception from the CDR intput stream.
+ *
+ * @param input a org.omg.CORBA.portable stream to read from.
+ */
+ public static InvalidSlot read(InputStream input)
+ {
+ // Read the exception repository id.
+ String id = input.read_string();
+ InvalidSlot value = new InvalidSlot(id);
+
+ return value;
+ }
+
+ /**
+ * Write the exception to the CDR output stream.
+ *
+ * @param output a org.omg.CORBA.portable stream stream to write into.
+ * @param value a value to write.
+ */
+ public static void write(OutputStream output, InvalidSlot value)
+ {
+ // Write the exception repository id.
+ output.write_string(id());
+ }
+}
\ No newline at end of file
--- /dev/null
+/* ORBInitInfo.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., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 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.PortableInterceptor;
+
+import org.omg.CORBA.Object;
+import org.omg.CORBA.portable.IDLEntity;
+
+/**
+ * The instance of this interface is passed to {@link ORBInitializerOperations}
+ * and is used by {@link ORBInitializer} to register its {@link Interceptor}.
+ *
+ * @author Audrius Meskauskas, Lithuania (AudriusA@Bioinformatics.org)
+ */
+public interface ORBInitInfo extends ORBInitInfoOperations,
+ Object,
+ IDLEntity
+{
+}
\ No newline at end of file
--- /dev/null
+/* ORBInitInfoOperations.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., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 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.PortableInterceptor;
+
+import org.omg.IOP.CodecFactory;
+import org.omg.PortableInterceptor.ORBInitInfoPackage.DuplicateName;
+
+/**
+ * Defines operations, applicable to {@link ORBInitInfo}. The
+ * {@link ORBInitInfo} is passed to the {@link ORBInitializer} that is
+ * reponsible for registering an {@link Interceptor}.
+ *
+ * @author Audrius Meskauskas, Lithuania (AudriusA@Bioinformatics.org)
+ */
+public interface ORBInitInfoOperations
+{
+ /**
+ * Register the client request interceptor.
+ *
+ * @param interceptor the interceptor to register.
+ *
+ * @throws DuplicateName if the interceptor name is not an empty string and an
+ * interceptor with this name is already registered with the ORB being
+ * created.
+ */
+ void add_client_request_interceptor(ClientRequestInterceptor interceptor)
+ throws DuplicateName;
+
+ /**
+ * Register the IOR (object reference) interceptor.
+ *
+ * @param interceptor the interceptor to register.
+ *
+ * @throws DuplicateName if the interceptor name is not an empty string and an
+ * interceptor with this name is already registered with the ORB being
+ * created.
+ */
+ void add_ior_interceptor(IORInterceptor interceptor)
+ throws DuplicateName;
+
+ /**
+ * Register the server request interceptor.
+ *
+ * @param interceptor the interceptor to register.
+ *
+ * @throws DuplicateName if the interceptor name is not an empty string and an
+ * interceptor with this name is already registered with the ORB being
+ * created.
+ */
+ void add_server_request_interceptor(ServerRequestInterceptor interceptor)
+ throws DuplicateName;
+
+ /**
+ * Allocate a slot on a {@link PortableInterceptor.Current}. While slots can
+ * be allocated by this method, they cannot be initialized.
+ * {@link CurrentOperations#get_slot} and {@link CurrentOperations#set_slot}
+ * throw {@link org.omg.CORBA.BAD_INV_ORDER} while called from the interceptor
+ * initializer.
+ *
+ * @return the index to the slot that has been allocated.
+ */
+ int allocate_slot_id();
+
+ /**
+ * Returns the arguments passed to the ORB.init.
+ *
+ * @return the first parameter, passed to the method
+ * {@link org.omg.CORBA.ORB#init}.
+ */
+ String[] arguments();
+
+ /**
+ * Get the CodecFactory that may be needed during the interceptor
+ * initialization. The method ORB.resolve_initial_references ("CodecFactory")
+ * cannot be used during ORB initialization.
+ *
+ * @return the CodecFactory.
+ */
+ CodecFactory codec_factory();
+
+ /**
+ * Returns the ID of the ORB being initialized.
+ *
+ * @return the ORB id that differs for each new ORB being created during the
+ * current run of the java virtual machine.
+ */
+ String orb_id();
+
+ /**
+ * Register the initial reference. The registered object will be accessible by
+ * the {@link ORB.resolve_initial_references} under the object_name.
+ *
+ * @param object_name the name of the object to register.
+ * @param object the object to register.
+ *
+ * @throws org.omg.PortableInterceptor.ORBInitInfoPackage.InvalidName if the
+ * name being registered is assumed to be invalid.
+ */
+ void register_initial_reference(String object_name,
+ org.omg.CORBA.Object object
+ ) throws org.omg.PortableInterceptor.ORBInitInfoPackage.InvalidName;
+
+ /**
+ * Identical to {@link org.omg.CORBA.ORB#resolve_initial_references}.
+ *
+ * This method can only be called from
+ * {@link ORBInitializerOperations#post_init} and not during
+ * {@link ORBInitializerOperations#pre_init}.
+ *
+ * @param object_name the name of the object to search.
+ *
+ * @return the object, accessible by the given name.
+ *
+ * @throws org.omg.PortableInterceptor.ORBInitInfoPackage.InvalidName if the
+ * given name is not associated with the known object.
+ *
+ * @see org.omg.CORBA.ORB#resolve_initial_references
+ */
+ org.omg.CORBA.Object resolve_initial_references(String object_name)
+ throws org.omg.PortableInterceptor.ORBInitInfoPackage.InvalidName;
+
+ /**
+ * Registers a PolicyFactory for the given PolicyType.
+ *
+ * @param policy_type the type of policy for that the factory is being
+ * registered.
+ * @param policy_factory the policy factory to register.
+ *
+ * @throws BAD_INV_ORDER minor 16 if the policy of the given type already has
+ * the registered factory in this ORB.
+ */
+ void register_policy_factory(int policy_type, PolicyFactory policy_factory);
+}
\ No newline at end of file
--- /dev/null
+/* ORBInitializer.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., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 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.PortableInterceptor;
+
+import org.omg.CORBA.Object;
+import org.omg.CORBA.portable.IDLEntity;
+
+/**
+ * <p>
+ * Registers the interceptor.
+ *
+ * Direct interceptor registration would open a security hole. Hence instead the
+ * interceptors from the ORB.init(..) method, passing the names of the needed
+ * initialized classes via properties.
+ * </p>
+ * <p>
+ * These property names are of the form
+ * </p>
+ * <p><i>org.omg.PortableInterceptor.ORBInitializerClass.<Service></i></p>
+ * where <i><Service></i> is the string name of a class, which implements
+ * {@link ORBInitializer}. During <code>ORB.init(..)</code>, the properties
+ * begining with <i>org.omg.PortableInterceptor.ORBInitializerClass</i> are
+ * collected, the <i><Service></i> portion of each property is extracted,
+ * the initialiser is instantiated with the <i><Service></i> string as its
+ * class name and then <code>pre_init</code> and <code>post_init</code>
+ * (defined in {@link ORBInitializerOperations}) are called on that initializer.
+ * The runtime exceptions, thrown by these two methods, are ignored.
+ * </p>
+ * <p>
+ * <h3>Example</h3>
+ * A client-side logging service may have the following ORBInitializer
+ * implementation:
+ *
+ * <code><pre>
+ * package gnu.x.logging;
+ *
+ * import org.omg.PortableInterceptor.*;
+ * import org.omg.CORBA.LocalObject;
+ *
+ * public class LoggingService extends LocalObject implements ORBInitializer
+ * {
+ * public void pre_init (ORBInitInfo info)
+ * {
+ * // More than one interceptor can be registered.
+ * ServerRequestInterceptor log_requests = new rLoggingInterceptor();
+ * info.add_server_request_interceptor(log_requests);
+ *
+ * IORInterceptor log_iors = new iLoggingInterceptor();
+ * info.add_ior_interceptor(log_iors);
+ * }
+ *
+ * public void post_init (ORBInitInfo info)
+ * {
+ * // Unused.
+ * }
+ * }
+ * </code></pre>
+ * <p>
+ * Then, one of the used set of properties then must contain the property, named
+ * <i>
+ * org.omg.PortableInterceptor.ORBInitializerClass.gnu.x.Logging.LoggingService
+ * </i>.
+ * The value of the property is ignored and may empty string. The
+ * agreed locations, where this property will be searched for, are:
+ * </p><p>
+ * 1. The properties parameter in the ORB.init(..), if any.<br>
+ * 2. The System properties.<br>
+ * 3. The orb.properties file located in the user.home directory (if any).<br>
+ * 4. The orb.properties file located in the java.home/lib directory (if any).
+ * </p>
+ * <p>
+ * The applet parameters and command line arguments are <i>not</i> scanned
+ * for the possible initializers.
+ * </p>
+ * <p>
+ * Interceptors are registered on a per-ORB basis. The virtual per-object
+ * Interceptors can be simulated by checking the policies on the target from
+ * within the interception points to determine whether they should work. The
+ * virtual per-POA Interceptors can be obtained instantiating each POA such with
+ * a different ORB.
+ * </p>
+ * <p>
+ * The registration code should not call directly any methods on the ORB being
+ * registered.
+ * </p>
+ * <p>
+ * The new interceptors cannot be registered after the ORB.init(..) returns.
+ * </p>
+ *
+ * @author Audrius Meskauskas, Lithuania (AudriusA@Bioinformatics.org)
+ */
+public interface ORBInitializer extends ORBInitializerOperations,
+ Object,
+ IDLEntity
+{
+}
\ No newline at end of file
--- /dev/null
+/* ORBInitializerOperations.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., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 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.PortableInterceptor;
+
+
+/**
+ * Defines operations, applicable to the ORBInitializer. These operations are
+ * invoked on initializer from the ORB.init.
+ *
+ * @see ORBInitializer
+ */
+public interface ORBInitializerOperations
+{
+ /**
+ * This method is called during the first step of initialization. It must
+ * register all initial references that are expected to be used by other
+ * interceptors.
+ *
+ * @param info the object describing ORB being created and containing methods
+ * to register the interceptor.
+ *
+ * @see ORBInitInfoOperations#register_initial_reference
+ */
+ void pre_init(ORBInitInfo info);
+
+ /**
+ * This method called during the subsequent step of initialization. In this
+ * method it can be assumed that all required initial references are already
+ * registered.
+ *
+ * @param info the object describing ORB being created and containing methods
+ * to register the interceptor.
+ *
+ * @see ORBInitInfoOperations#register_initial_references
+ */
+ void post_init(ORBInitInfo info);
+}
\ No newline at end of file
--- /dev/null
+/* PolicyFactory.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., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 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.PortableInterceptor;
+
+import org.omg.CORBA.portable.IDLEntity;
+
+/**
+ * The {@link ORBInitializer} may register the PolicyFactory to create the
+ * service specific policies later. The factory will be later used by
+ * {@link org.omg.CORBA.ORB#create_policy}.
+ *
+ * @see org.omg.PortableInterceptor.ORBInitInfoOperations#register_policy_factory
+ * @see org.omg.CORBA.ORB#create_policy
+ *
+ * @author Audrius Meskauskas, Lithuania (AudriusA@Bioinformatics.org)
+ */
+public interface PolicyFactory extends PolicyFactoryOperations,
+ org.omg.CORBA.Object,
+ IDLEntity
+{
+}
\ No newline at end of file
--- /dev/null
+/* PolicyFactoryOperations.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., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 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.PortableInterceptor;
+
+import org.omg.CORBA.Any;
+import org.omg.CORBA.Policy;
+import org.omg.CORBA.PolicyError;
+
+/**
+ * A service implementation can register policy factory during ORB initialization
+ * for creating the service-specific policies. This factory then will be
+ * invoked form {@link org.omg.CORBA.ORB#create_policy(int, Any)}.
+ *
+ * @author Audrius Meskauskas, Lithuania (AudriusA@Bioinformatics.org)
+ *
+ * @see org.omg.CORBA.ORB#create_policy
+ * @see ORBInitInfoOperations#register_policy_factory
+ */
+public interface PolicyFactoryOperations
+{
+ /**
+ * Create and return the policy of the given type, having the given value.
+ *
+ * @param policy_type the type of the policy being created
+ * @param policy_value the value of the policy, wrapped in {@link Any}.
+ * Depending from the policy, the Any can hold various values,
+ * including complex data structures.
+ *
+ * @return the created policy.
+ */
+ Policy create_policy(int policy_type, Any policy_value)
+ throws PolicyError;
+}
\ No newline at end of file
--- /dev/null
+/* RequestInfo.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., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 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.PortableInterceptor;
+
+import org.omg.CORBA.portable.IDLEntity;
+
+/**
+ * Provides access to request information, available to the
+ * {@link ClientRequestInterceptor} or {@link ServerRequestInterceptor}. The
+ * additional operations, specific to the server and client are defined in the
+ * derived interfaces {@link ServerRequestInfo} and {@link ClientRequestInfo}.
+ *
+ * @author Audrius Meskauskas, Lithuania (AudriusA@Bioinformatics.org)
+ */
+public interface RequestInfo extends RequestInfoOperations,
+ org.omg.CORBA.Object,
+ IDLEntity
+{
+}
\ No newline at end of file
--- /dev/null
+/* RequestInfoOperations.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., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 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.PortableInterceptor;
+
+import org.omg.CORBA.Any;
+import org.omg.CORBA.BAD_PARAM;
+import org.omg.CORBA.TypeCode;
+import org.omg.Dynamic.Parameter;
+import org.omg.IOP.ServiceContext;
+
+/**
+ * Defines operations that are applicable for both server and client request.
+ * The additional operations, specific to the server and client request are
+ * defined in the derived interfaces {@link ServerRequestInfoOperations} and
+ * {@link ClientRequestInfoOperations}.
+ *
+ * @author Audrius Meskauskas, Lithuania (AudriusA@Bioinformatics.org)
+ */
+public interface RequestInfoOperations
+{
+ /**
+ * Return the parameters of the operation being invoked.
+ *
+ * @return the array, containing parameters of the operations or an empty
+ * array for the operations with no parameters.
+ *
+ * @throws NO_RESOURCES if the parameters are not available. The parameters
+ * are only available for DII (via {@link org.omg.CORBA.Request} or DSI calls.
+ * They are not available for calls via IDL - generated stubs.
+ */
+ Parameter[] arguments();
+
+ /**
+ * Returns the names of all contexts of the operation being invoked.
+ *
+ * @return the array of strings, defining contexts.
+ *
+ * @throws NO_RESOURCES if the contexts are not available. The contexts are
+ * only available for DII (via {@link org.omg.CORBA.Request} or DSI calls.
+ * They are not available for calls via IDL - generated stubs.
+ */
+ String[] contexts();
+
+ /**
+ * Returns the typecodes, defining all exceptions that the operation may
+ * throw.
+ *
+ * @return the array of exception typecodes, empty array if the operation
+ * should not throw any exceptions.
+ *
+ * @throws NO_RESOURCES if the exception list is not available. This list is
+ * only available for DII (via {@link org.omg.CORBA.Request} or DSI calls and
+ * only on the client side. It is not available for calls via IDL - generated
+ * stubs or on the server side.
+ */
+ TypeCode[] exceptions();
+
+ /**
+ * If the request contains forwarding information (the reply_status attribute
+ * being LOCATION_FORWARD), return the forwarding target.
+ *
+ * @return the object where the request should be forwarded.
+ */
+ org.omg.CORBA.Object forward_reference();
+
+ /**
+ * Get the service context with the given ctx_name that is associated with the
+ * reply.
+ *
+ * @param ctx_name the name of the service context
+ *
+ * @return the copy of the corresponding context.
+ *
+ * @throws BAD_PARAM minor 26, if the context with the give ctx_name does not
+ * exist.
+ */
+ ServiceContext get_reply_service_context(int ctx_name)
+ throws BAD_PARAM;
+
+ /**
+ * Get the service context with the given ctx_name that is associated with the
+ * request.
+ *
+ * @param ctx_name the name of the service context
+ *
+ * @return the copy of the corresponding context.
+ *
+ * @throws BAD_PARAM minor 26, if the context with the give ctx_name does not
+ * exist.
+ */
+ ServiceContext get_request_service_context(int ctx_name)
+ throws BAD_PARAM;
+
+ /**
+ * Get the data from the given slot of the PortableInterceptor.Current that is
+ * in the scope of the request.
+ */
+ Any get_slot(int id) throws InvalidSlot;
+
+ /**
+ * Get the names of the service contexts being sent on the request.
+ *
+ * @return array of strings, naming the contexts.
+ */
+ String[] operation_context();
+
+ /**
+ * Get the name of the operation being invoked.
+ *
+ * @return the name of the operation, usually the name of method being called.
+ */
+ String operation();
+
+ /**
+ * Get the reoly state as result of the operation invocation.
+ *
+ * @return the value field of one of the following: {@link SUCCESSFUL},
+ * {@link SYSTEM_EXCEPTION}, {@link USER_EXCEPTION},
+ * {@link LOCATION_FORWARD} or {@link TRANSPORT_RETRY}.
+ */
+ short reply_status();
+
+ /**
+ * Get the request id.
+ *
+ * @return an id that uniquely identifies the current request/reply sequence.
+ */
+ int request_id();
+
+ /**
+ * Indicates whether request sender expected any response.
+ *
+ * @return true if the response was expected, false otherwise.
+ */
+ boolean response_expected();
+
+ /**
+ * Get the result of the operation invocation.
+ *
+ * @return an Any, containing the value, returned by the performed operation.
+ */
+ Any result();
+
+ /**
+ * Determines how far the request shall progress before control is returned to
+ * the client. However up till JDK 1.5 inclusive this method always returns
+ * SYNC_WITH_TRANSPORT.
+ *
+ * @return {@link org.omg.Messaging.SYNC_WITH_TRANSPORT.value (1), always.
+ *
+ * @specnote as defined in the Suns 1.5 JDK API.
+ */
+ short sync_scope();
+}
\ No newline at end of file
--- /dev/null
+/* ServerRequestInfo.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., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 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.PortableInterceptor;
+
+import org.omg.CORBA.portable.IDLEntity;
+
+/**
+ * Provides request information, accessible for the
+ * {@link ServerRequestInterceptor}.
+ *
+ * @author Audrius Meskauskas, Lithuania (AudriusA@Bioinformatics.org)
+ */
+public interface ServerRequestInfo extends ServerRequestInfoOperations,
+ org.omg.CORBA.Object,
+ IDLEntity,
+ RequestInfo
+{
+}
\ No newline at end of file
--- /dev/null
+/* ServerRequestInfoOperations.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., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 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.PortableInterceptor;
+
+import org.omg.CORBA.Any;
+import org.omg.CORBA.INV_POLICY;
+import org.omg.CORBA.Policy;
+import org.omg.IOP.ServiceContext;
+
+/**
+ * Provides request information, accessible for the
+ * {@link ClientRequestInterceptor}. Some methods of this interface are not
+ * valid at all interception points. The following table shows the validity of
+ * each method. If it is not valid, BAD_INV_ORDER minor 14 will be thrown.
+ *
+ * <table border="1">
+ * <tr>
+ * <th></th>
+ * <th>{@link ServerRequestInterceptorOperations#receive_request_service_contexts receive_request_<br>service_contexts}</th>
+ * <th>{@link ServerRequestInterceptorOperations#receive_request receive_request}</th>
+ * <th>{@link ServerRequestInterceptorOperations#send_reply send_reply}</th>
+ * <th>{@link ServerRequestInterceptorOperations#send_exception send_exception}</th>
+ * <th>{@link ServerRequestInterceptorOperations#send_other send_other}</th>
+ * </tr>
+ * <tr>
+ * <td colspan="6" align="center" bgcolor="#E0E0FF"><i>Inherited from
+ * {@link RequestInfoOperations}:</i></td>
+ * </tr>
+ * <tr>
+ * <th>{@linkplain RequestInfoOperations#arguments arguments}</th>
+ * <td bgcolor="lightgray">no </td>
+ * <td bgcolor="#E0E0E0" title="in and inout only">yes<sub><a href="#1">1</a></sub></td>
+ * <td>yes</td>
+ * <td bgcolor="#E0E0E0" title="When reply_status = LOCATION_FORWARD">no<sub><a
+ * href="#2">2</a></sub></td>
+ * <td bgcolor="#E0E0E0" title="When reply_status = LOCATION_FORWARD">no<sub><a
+ * href="#2">2</a></sub> </td>
+ * </tr>
+ * <tr>
+ * <th>{@linkplain RequestInfoOperations#exceptions exceptions}</th>
+ * <td bgcolor="lightgray">no </td>
+ * <td colspan="4" align ="center">yes</td>
+ * </tr>
+ * <tr>
+ * <th>{@linkplain RequestInfoOperations#contexts contexts}</th>
+ * <td bgcolor="lightgray">no </td>
+ * <td colspan="4" align ="center">yes</td>
+ * </tr>
+ * <tr>
+ * <th>{@linkplain RequestInfoOperations#operation_context operation_context}</th>
+ * <td bgcolor="lightgray">no </td>
+ * <td>yes</td>
+ * <td>yes</td>
+ * <td bgcolor="lightgray">no </td>
+ * <td bgcolor="lightgray">no </td>
+ * </tr>
+ * <tr>
+ * <th>{@linkplain RequestInfoOperations#result result}</th>
+ * <td bgcolor="lightgray">no </td>
+ * <td bgcolor="lightgray">no </td>
+ * <td>yes</td>
+ * <td bgcolor="lightgray">no </td>
+ * <td bgcolor="lightgray">no </td>
+ * </tr>
+ * <tr>
+ * <th>{@linkplain RequestInfoOperations#reply_status reply_status}</th>
+ * <td bgcolor="lightgray">no </td>
+ * <td bgcolor="lightgray">no </td>
+ * <td colspan="3" align="center">yes</td> * </tr>
+ * <tr>
+ * <th>{@linkplain RequestInfoOperations#forward_reference forward_reference}</th>
+ * <td bgcolor="lightgray" colspan="4" align="center">no</td>
+ * <td bgcolor="#E0E0E0" title="When reply_status = LOCATION_FORWARD">yes<sub><a
+ * href="#2">2</a></sub> </td>
+ * </tr>
+ * <tr>
+ * <th>{@linkplain RequestInfoOperations#get_request_service_context get_request_service_context}</th>
+ * <td>yes</td>
+ * <td bgcolor="lightgray">no </td>
+ * <td colspan="3" align="center">yes</td> * </tr>
+ * <tr>
+ * <th>{@linkplain RequestInfoOperations#get_reply_service_context get_reply_service_context}</th>
+ * <td bgcolor="lightgray">no </td>
+ * <td bgcolor="lightgray">no </td>
+ * <td colspan="3" align="center">yes</td>
+ * </tr>
+ * <tr>
+ * <th>{@linkplain RequestInfoOperations#request_id request_id}</th>
+ * <td colspan="5" align ="center">yes</td>
+ * </tr>
+ * <tr>
+ * <th>{@linkplain RequestInfoOperations#operation operation}</th>
+ * <td colspan="5" align ="center">yes</td>
+ * </tr>
+ * <tr>
+ * <th>{@linkplain RequestInfoOperations#response_expected response_expected}</th>
+ * <td colspan="5" align ="center">yes</td>
+ * </tr>
+ * <tr>
+ * <th>{@linkplain RequestInfoOperations#sync_scope sync_scope}</th>
+ * <td colspan="5" align ="center">yes</td>
+ * </tr>
+ * <tr>
+ * <th>{@linkplain RequestInfoOperations#get_slot get_slot}</th>
+ * <td colspan="5" align ="center">yes</td>
+ * </tr>
+ * <tr>
+ * <td colspan="6" align="center" bgcolor="#E0E0FF">
+ * <i>ServerRequestInfo-specific:</i></td>
+ * </tr>
+ * <tr>
+ * <th>{@linkplain #get_server_policy get_server_policy}</th>
+ * <td colspan="5" align ="center">yes</td>
+ * </tr>
+ * <tr>
+ * <th>{@linkplain #add_reply_service_context add_reply_service_context}</th>
+ * <td colspan="5" align ="center">yes</td>
+ * </tr>
+ * <tr>
+ * <th>{@linkplain #set_slot set_slot}</th>
+ * <td colspan="5" align ="center">yes</td>
+ * </tr>
+ * <tr>
+ * <th>{@linkplain #sending_exception sending_exception}</th>
+ * <td bgcolor="lightgray" colspan="3" align="center">no</td>
+ * <td>yes</td>
+ * <td bgcolor="lightgray">no </td>
+ * </tr>
+ * <tr>
+ * <th>{@linkplain #object_id object_id}</th>
+ * <td bgcolor="lightgray">no </td>
+ * <td>yes</td>
+ * <td>yes</td>
+ * <td bgcolor="#E0E0E0" title="Not always (see note)">yes<sub><a
+ * href="#3">3</a></sub></td>
+ * <td bgcolor="#E0E0E0" title="Not always (see note)">yes<sub><a
+ * href="#3">3</a></sub> </td>
+ * </tr>
+ * <tr>
+ * <th>{@linkplain #adapter_id adapter_id}</th>
+ * <td bgcolor="lightgray">no </td>
+ * <td>yes</td>
+ * <td>yes</td>
+ * <td bgcolor="#E0E0E0" title="Not always (see note)">yes<sub><a
+ * href="#3">3</a></sub></td>
+ * <td bgcolor="#E0E0E0" title="Not always (see note)">yes<sub><a
+ * href="#3">3</a></sub> </td>
+ * </tr>
+ * <tr>
+ * <th>{@linkplain #target_most_derived_interface target_most_derived_interface}</th>
+ * <td bgcolor="lightgray">no </td>
+ * <td>yes</td>
+ * <td bgcolor="lightgray" colspan="3" align="center">no</td>
+ * </tr>
+ * <tr>
+ * <th>{@linkplain #target_is_a target_is_a}</th>
+ * <td bgcolor="lightgray">no </td>
+ * <td>yes</td>
+ * <td bgcolor="lightgray" colspan="3" align="center">no</td>
+ * </tr>
+ * <tr>
+ * <th></th>
+ * <th>{@link ServerRequestInterceptorOperations#receive_request_service_contexts receive_request_<br>service_contexts }</th>
+ * <th>{@link ServerRequestInterceptorOperations#receive_request receive_request}</th>
+ * <th>{@link ServerRequestInterceptorOperations#send_reply send_reply}</th>
+ * <th>{@link ServerRequestInterceptorOperations#send_exception send_exception}</th>
+ * <th>{@link ServerRequestInterceptorOperations#send_other send_other}</th>
+ * </tr>
+ * </table>
+ * <ol>
+ * <li><a name="1">When ServerRequestInfo is passed to receive_request, there
+ * is an entry in the list for every argument. But only the in and inout
+ * arguments will be available.</a></li>
+ * <li><a name="2">If the reply_status attribute is not LOCATION_FORWARD,
+ * accessing this attribute throws BAD_INV_ORDER minor code of 14.</a></li>
+ * <li><a name="3">If the servant locator caused a location forward, or thrown
+ * an exception, this attribute/operation may not be available (NO_RESOURCES
+ * with a standard minor code of 1 will be thrown).</a></li>
+ * </ol>
+ *
+ * @author Audrius Meskauskas, Lithuania (AudriusA@Bioinformatics.org)
+ */
+public interface ServerRequestInfoOperations extends RequestInfoOperations
+{
+ /**
+ * Allows the interceptor to add service contexts to the request. Such added
+ * contexts can carry arbitrary data and can be later accessed on the client
+ * side by the client request interceptor using
+ * {@link RequestInfoOperations#get_reply_service_context}.
+ *
+ * @param service_context the context to add.
+ * @param replace if true, the existing context with the same Id will be
+ * replaced. If false, the BAD_INV_ORDER will be thrown in that case.
+ *
+ * @throws BAD_INV_ORDER minor 15 if the context with the same Id already
+ * exists and replace=false.
+ */
+ void add_reply_service_context(ServiceContext service_context,
+ boolean replace
+ );
+
+ /**
+ * Get the identifier for the object adapter (POA).
+ */
+ byte[] adapter_id();
+
+ /**
+ * Get the object_id describing the target of the operation invocation.
+ */
+ byte[] object_id();
+
+ /**
+ * Return the policy of the given type that applies to this operation. This
+ * method should only be used with policies, produced by the registered
+ * {@link PolicyFactory}.
+ *
+ * @param type the type of the policy being requested.
+ *
+ * @return the policy that applies to this operation.
+ *
+ * @throws INV_POLICY minor 2 if no factory was registered to produce this
+ * type of policy or the policy is otherwise invalid.
+ */
+ Policy get_server_policy(int type) throws INV_POLICY;
+
+ /**
+ * Get the exception to be returned to the client. If the returned Any cannot
+ * not support holding of that exception, it holds
+ * {@link org.omg.CORBA.UNKNOWN} minor 1 instead.
+ *
+ * @return an Any, holding exception that has been thrown and will be returned
+ * to client.
+ */
+ Any sending_exception();
+
+ /**
+ * Allows the interceptor to set a slot in the PortableInterceptor.Current
+ * that is in the scope of the request.
+ *
+ * @param id the Id of the slot.
+ * @param data the value of the slot, replacing the previous value.
+ *
+ * @throws InvalidSlot if the slot with the given Id does not exist.
+ *
+ * @see RequestInfoOperations#get_slot(int)
+ * @see org.omg.PortableInterceptor#Current
+ */
+ void set_slot(int id, Any data) throws InvalidSlot;
+
+ /**
+ * Checks if the servant is the given repository id.
+ *
+ * @param the repository id to compare.
+ *
+ * @return true if the servant repository id matches the parameter, false
+ * otherwise.
+ */
+ boolean target_is_a(String id);
+
+ /**
+ * Get the most derived (most specific) repository Id of the servant.
+ *
+ * @return the repository id of the servant.
+ */
+ String target_most_derived_interface();
+}
\ No newline at end of file
--- /dev/null
+/* ServerRequestInterceptor.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., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 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.PortableInterceptor;
+
+import org.omg.CORBA.portable.IDLEntity;
+
+/**
+ * A server side request interceptor that is notified on various request
+ * processing steps on a server side.
+ *
+ * @author Audrius Meskauskas, Lithuania (AudriusA@Bioinformatics.org)
+ */
+public interface ServerRequestInterceptor extends Interceptor,
+ ServerRequestInterceptorOperations,
+ org.omg.CORBA.Object,
+ IDLEntity
+{
+}
\ No newline at end of file
--- /dev/null
+/* ServerRequestInterceptorOperations.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., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 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.PortableInterceptor;
+
+
+/**
+ * Defines operations, applicable to the server side request interceptor. The
+ * operations are called by ORB at the appropriate interception points.
+ *
+ * @author Audrius Meskauskas, Lithuania (AudriusA@Bioinformatics.org)
+ */
+public interface ServerRequestInterceptorOperations
+ extends InterceptorOperations
+{
+ /**
+ * ORB calls this method before invoking the servant manager. Operation
+ * parameters are not available at this point. The interceptor has possibility
+ * to forward the request by throwing {@link ForwardRequest}.
+ *
+ * @throws SystemException if it does, the receive_request_service_contexts is
+ * not called for the subsequent interceptors, calling send_exception instead.
+ * The completion status of such exception must be COMPLETED_NO.
+ *
+ * @throws ForwardRequest to forward the invocation to another target. The
+ * receive_request_service_contexts is not called for the subsequent
+ * interceptors, calling send_other instead.
+ */
+ void receive_request_service_contexts(ServerRequestInfo info)
+ throws ForwardRequest;
+
+ /**
+ * ORB calls this method after all the information, including operation
+ * parameters, are available. The interceptor has possibility to forward the
+ * request by throwing {@link ForwardRequest}.
+ *
+ * @param info the object for accessing and manipulating the request
+ * information.
+ *
+ * @throws SystemException if it does, the receive_request is not called for
+ * the subsequent interceptors, calling send_exception instead. The completion
+ * status of such exception must be COMPLETED_NO.
+ *
+ * @throws ForwardRequest to forward the invocation to another target. The
+ * receive_request is not called for the subsequent interceptors, calling
+ * send_other instead.
+ */
+ void receive_request(ServerRequestInfo info) throws ForwardRequest;
+
+ /**
+ * ORB calls this method after the target operation has been invoked and
+ * before the reply is returned to the client. This interception point shall
+ * execute in the same thread as the target invocation.
+ *
+ * @param info the object for accessing and manipulating the request
+ * information.
+ *
+ * @throws SystemException if it does, the send_reply is not called for the
+ * subsequent interceptors, calling send_exception instead. The completion
+ * status of such exception must be COMPLETED_YES.
+ */
+ void send_reply(ServerRequestInfo info);
+
+ /**
+ * ORB calls this method if the exception has been throw during the request
+ * processing. The interceptor has possibility to forward the request by
+ * throwing {@link ForwardRequest}.
+ *
+ * @param info the object for accessing and manipulating the request
+ * information.
+ *
+ * @throws SystemException has the effect of changing the exception that
+ * successive interceptors receive on their calls to send_exception. If the
+ * original exception is a system exception, the completion_status of the new
+ * exception must match the exception being replaced. If the original
+ * exception is a user exception, then the completion_status of the new
+ * exception must be COMPLETED_YES.
+ *
+ * @throws ForwardRequest to forward the invocation to another target. The
+ * send_exception is not called for the subsequent interceptors, calling
+ * send_other instead. If the completion_status of the original exception is
+ * not a COMPLETED_NO, the ForwardRequest must not be raised.
+ */
+ void send_exception(ServerRequestInfo info) throws ForwardRequest;
+
+ /**
+ * ORB normally calls this method if the request has been forwarded.
+ *
+ * @param info the object for accessing and manipulating the request
+ * information.
+ *
+ * @throws SystemException if it does, the send_other is not called for the
+ * subsequent interceptors, calling send_exception instead.
+ *
+ * @throws ForwardRequest has the effect of changing the redirection that
+ * successive interceptors receive on their calls to send_other.
+ */
+ void send_other(ServerRequestInfo info) throws ForwardRequest;
+}
\ No newline at end of file
--- /dev/null
+<!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., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 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.PortableInterceptor</title></head>
+
+<body>
+Interceptors are hooks than can monitor various stages of the CORBA request
+processing. The {@link org.omg.PortableInterceptor.IORInterceptor} monitors
+all new object refereces (IORs) being created and can add to them additional
+information. The {@link org.omg.PortableInterceptor.ClientRequestInterceptor}
+monitors request handling on the client side and the
+{@link org.omg.PortableInterceptor.ServerRequestInterceptor} monitors request
+handling on the server side. The client and server request interceptors can
+add additional data to the CORBA message that is accessible on remote side
+after the message is transmitted. They can also forward request to another
+target. All interceptor functions also work for the local invocations. The
+interceptors are registered in ORB.init(...) using
+{@link org.omg.PortableInterceptor.ORBInitializer}.
+
+@author Audrius Meskauskas, Lithuania (AudriusA@Bioinformatics.org)
+</body>
+</html>
--- /dev/null
+/* AdapterActivator.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., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 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.PortableServer;
+
+import org.omg.CORBA.portable.IDLEntity;
+
+/**
+ * Adapter activators are associated with POAs and supply the
+ * the ability to create child POAs on demand. The new POA can be created
+ * <ul>
+ * <li>As a side-effect of receiving a request that names the child POA
+ * (or one of its children).</li>
+ * <li>When calling
+ * {@link POAOperations}.find_POA(name, true) if the parameter
+ * <code>name</code> refers a non existing POA.
+ * </li></ul>
+ * An AdapterActivator is always a local object.
+ *
+ * @see AdapterActivatorOperations#unknown_adapter
+ *
+ * @author Audrius Meskauskas, Lithuania (AudriusA@Bioinformatics.org)
+ */
+public interface AdapterActivator
+ extends AdapterActivatorOperations, IDLEntity, org.omg.CORBA.Object
+{
+}
\ No newline at end of file
--- /dev/null
+/* AdapterActivatorOperations.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., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 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.PortableServer;
+
+
+/**
+ * Defines the operations, applicable to the AdapterActivator.
+ *
+ * @author Audrius Meskauskas, Lithuania (AudriusA@Bioinformatics.org)
+ */
+public interface AdapterActivatorOperations
+{
+ /**
+ * This method is invoked when the ORB receives a request for an object
+ * reference that identifies a non-existing target POA, to create it.
+ * The ORB invokes this operation once for each POA that must be created
+ * in order for the target POA to exist. The process remebers creating a
+ * nested folder structure, starting from the ancestor POA closest to the
+ * root POA. The operation is invoked on the adapter activator of
+ * POA that is the parent of the POA that needs to be created.
+ *
+ * @param parent the parent POA, for that the child POA must be created.
+ * @param child_name the name of the child POA that must be created.
+ *
+ * @return true if the operation has successfully created the needed POA,
+ * false that POA cannot be created. In this case, the client will receive
+ * the remote exception ({@link OBJECT_NOT_EXIST}, minor code 2).
+ */
+ boolean unknown_adapter(POA parent, String child_name);
+}
\ No newline at end of file
--- /dev/null
+/* Current.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., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 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.PortableServer;
+
+import org.omg.CORBA.portable.IDLEntity;
+
+/**
+ * <p>Provides the Id of the object currently being served and POA
+ * to that this object is connected. Both Id and POA can be
+ * simpler obtained from the servant by {@link Servant#_object_id() }
+ * and {@link Servant#_poa()} that use POA Current indirectly.
+ * The operations on Current for obtaining
+ * these data are defined in {@link CurrentOperations}.
+ * </p><p>
+ * As long as the ORB reference is still available, the current information
+ * is available via {@link Current} that is returned by
+ * ORB.resolve_initial_references("POACurrent"). To support this call,
+ * the ORB maintains the thread to invocation data map for all calls that
+ * are currently being processed.
+ * </p>
+ *
+ * @author Audrius Meskauskas, Lithuania (AudriusA@Bioinformatics.org)
+ */
+public interface Current
+ extends CurrentOperations, org.omg.CORBA.Current, IDLEntity
+{
+}
\ No newline at end of file
--- /dev/null
+/* CurrentHelper.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., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 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.PortableServer;
+
+import org.omg.CORBA.Any;
+import org.omg.CORBA.BAD_PARAM;
+import org.omg.CORBA.NO_IMPLEMENT;
+import org.omg.CORBA.ORB;
+import org.omg.CORBA.TypeCode;
+import org.omg.CORBA.portable.InputStream;
+import org.omg.CORBA.portable.OutputStream;
+
+/**
+* The helper operations for the
+* CORBA object {@link Current}.
+*
+* @author Audrius Meskauskas, Lithuania (AudriusA@Bioinformatics.org)
+*/
+public abstract class CurrentHelper
+{
+ /**
+ * Get the type code of the POA Current.
+ *
+ * @return a type code of the object with POA Current id, named "Current".
+ */
+ public static TypeCode type()
+ {
+ return ORB.init().create_interface_tc(id(), "Current");
+ }
+
+ /**
+ * Insert the POA Current into the given Any.
+ *
+ * @param any the Any to insert into.
+ * @param that the POA Current to insert.
+ */
+ public static void insert(Any any, Current that)
+ {
+ any.insert_Object(that);
+ }
+
+ /**
+ * Extract the POA Current from given Any.
+ *
+ * @throws BAD_OPERATION if the passed Any does not contain a POA Current.
+ */
+ public static Current extract(Any any)
+ {
+ return narrow(any.extract_Object());
+ }
+
+ /**
+ * Get the POA Current repository id.
+ *
+ * @return "IDL:omg.org/PortableServer/Current:2.3", always.
+ */
+ public static String id()
+ {
+ return "IDL:omg.org/PortableServer/Current:2.3";
+ }
+
+ /**
+ * Cast the passed object into the POA Current.
+ *
+ * @param obj the object to narrow.
+ * @return narrowed instance.
+ * @throws BAD_PARAM if the passed object is not a Current.
+ */
+ public static Current narrow(org.omg.CORBA.Object obj)
+ {
+ try
+ {
+ return (Current) obj;
+ }
+ catch (ClassCastException ex)
+ {
+ BAD_PARAM bad = new BAD_PARAM("Not a POA Current");
+ bad.initCause(ex);
+ throw bad;
+ }
+ }
+
+ /**
+ * Not supported for compatibility reasons.
+ *
+ * @specnote Not supported by Sun at least till jdk 1.4 inclusive.
+ *
+ * @throws NO_IMPLEMENT always.
+ */
+ public static Current read(InputStream input)
+ {
+ throw new NO_IMPLEMENT();
+ }
+
+ /**
+ * Not supported for compatibility reasons.
+ *
+ * @specnote Not supported by Sun at least till jdk 1.4 inclusive.
+ *
+ * @throws NO_IMPLEMENT always.
+ */
+ public static void write(OutputStream output, Current value)
+ {
+ throw new NO_IMPLEMENT();
+ }
+}
\ No newline at end of file
--- /dev/null
+/* CurrentOperations.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., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 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.PortableServer;
+
+import org.omg.PortableServer.CurrentPackage.NoContext;
+
+/**
+ * Provides the Id of the object currently being served and POA
+ * to that this object is connected. Both Id and POA can be much
+ * simpler obtained from the servant by {@link Servant#_object_id() }
+ * and {@link Servant#_poa()} that use the CurrentOperations indirectly.
+ *
+ * As long as the ORB reference is still available, the current information
+ * is available via {@link Current} that is returned by
+ * ORB.resolve_initial_references("POACurrent"). To support this call,
+ * the ORB maintains the thread to invocation data map for all calls that
+ * are currently being processed.
+ *
+ * @author Audrius Meskauskas, Lithuania (AudriusA@Bioinformatics.org)
+ */
+public interface CurrentOperations
+ extends org.omg.CORBA.CurrentOperations
+{
+ /**
+ * Returns the Id of the object currently being served. The returned
+ * value is also correct if the calling code is running is several
+ * paralled threads.
+ *
+ * @return the Id of the object that is currently being served by this
+ * thread.
+ */
+ byte[] get_object_id()
+ throws NoContext;
+
+ /**
+ * Returns POA to that the object currently being served is connected.
+ * The returned value is also correct if the calling code is running is several
+ * paralled threads.
+ *
+ * @return the Id of the object that is currently being served by this
+ * thread.
+ */
+ POA get_POA()
+ throws NoContext;
+}
\ No newline at end of file
--- /dev/null
+/* DynamicImplementation.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., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 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.PortableServer;
+
+import org.omg.CORBA.ServerRequest;
+
+/**
+ * This class is used for servants that support calling via server request.
+ *
+ * @author Audrius Meskauskas, Lithuania (AudriusA@Bioinformatics.org)
+ */
+public abstract class DynamicImplementation
+ extends Servant
+{
+ /**
+ * Handle the invocation via passed request.
+ *
+ * @param request the data structure, used both to pass parameters
+ * and return results of the invocation.
+ */
+ public abstract void invoke(ServerRequest request);
+}
\ No newline at end of file
--- /dev/null
+/* ForwardRequest.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., 51 Franklin Street, Fifth Floor, Boston, MA
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 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.PortableServer;
+
+import org.omg.CORBA.UserException;
+import org.omg.CORBA.portable.IDLEntity;
+
+import java.io.Serializable;
+
+/**
+ * <p>
+ * This exception is raised by {@link ServantManager} to indicate that the
+ * invocation target has moved to another known location. In this case,
+ * the client will receive a redirection (LOCATION_FORWARD) message and should
+ * resend the request to the new target. The exception contains the object
+ * reference, indicating the new location.
+ * </p><p>
+ * The exception can be thrown both by servant locators and servant activators.
+ * If the exception is raised anywhere else than in the ServantManager
+ * methods, it is handled as an ordinary user excepton.
+ * </p>
+ *
+ * @author Audrius Meskauskas, Lithuania (AudriusA@Bioinformatics.org)
+*/
+public class ForwardRequest
+ extends UserException
+ implements IDLEntity, Serializable
+{
+ /**
+ * Use serialVersionUID (v1.4) for interoperability.
+ */
+ private static final long serialVersionUID = -4159318367582473975L;
+
+ /**
+ * The object reference, indicating the new location of the invocation target.
+ */
+ public org.omg.CORBA.Object forward_reference;
+
+ /**
+ * Create ForwardRequest with no explaining message and stating the
+ * new location is <code>null</code>.
+ */
+ public ForwardRequest()
+ {
+ }
+
+ /**
+ * Create the ForwardRequest with explaining message and
+ * initialising the object reference to the given value.
+ *
+ * @param why a string, explaining, why this exception has been thrown.
+ * @param a_forward_reference a value for forward_reference.
+ */
+ public ForwardRequest(String why, org.omg.CORBA.Object a_forward_reference)
+ {
+ super(why);
+ this.forward_reference = a_forward_reference;
+ }
+
+ /**
+ * Create the ForwardRequest without explaining
+ * message and initialising the object reference to the given value.
+ *
+ * @param a_forward_reference a value for forward_reference.
+ */
+ public ForwardRequest(org.omg.CORBA.Object a_forward_reference)
+ {
+ this.forward_reference = a_forward_reference;
+ }
+}
\ No newline at end of file
--- /dev/null
+/* ForwardRequestHelper.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., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 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.PortableServer;
+
+import gnu.CORBA.Poa.ForwardRequestHolder;
+
+import org.omg.CORBA.Any;
+import org.omg.CORBA.BAD_OPERATION;
+import org.omg.CORBA.ORB;
+import org.omg.CORBA.ObjectHelper;
+import org.omg.CORBA.StructMember;
+import org.omg.CORBA.TypeCode;
+import org.omg.CORBA.portable.InputStream;
+import org.omg.CORBA.portable.OutputStream;
+
+/**
+ * The helper operations for the exception {@link ForwardRequest}.
+ *
+ * @specnote The helper must be here and not in POA subpackage as it must
+ * be discovered by the {@link ObjectCreator} when reading this remote
+ * exception.
+ *
+ * @author Audrius Meskauskas, Lithuania (AudriusA@Bioinformatics.org)
+ */
+public abstract class ForwardRequestHelper
+{
+ /**
+ * The cached typecode value, computed only once.
+ */
+ private static TypeCode typeCode;
+
+ /**
+ * Extract the ForwardRequest from given Any.
+ * This method uses the ForwardRequestHolder.
+ *
+ * @throws BAD_OPERATION if the passed Any does not contain ForwardRequest.
+ */
+ public static ForwardRequest extract(Any any)
+ {
+ try
+ {
+ return ((ForwardRequestHolder) any.extract_Streamable()).value;
+ }
+ catch (ClassCastException cex)
+ {
+ BAD_OPERATION bad = new BAD_OPERATION("ForwardRequest expected");
+ bad.initCause(cex);
+ throw bad;
+ }
+ }
+
+ /**
+ * Get the ForwardRequest repository id.
+ *
+ * @return "ForwardRequest", always.
+ */
+ public static String id()
+ {
+ return "ForwardRequest";
+ }
+
+ /**
+ * Insert the ForwardRequest into the given Any.
+ * This method uses the ForwardRequestHolder.
+ *
+ * @param any the Any to insert into.
+ * @param that the ForwardRequest to insert.
+ */
+ public static void insert(Any any, ForwardRequest that)
+ {
+ any.insert_Streamable(new ForwardRequestHolder(that));
+ }
+
+ /**
+ * Read the exception from the CDR intput stream.
+ *
+ * @param input a org.omg.CORBA.portable stream to read from.
+ */
+ public static ForwardRequest read(InputStream input)
+ {
+ // Read the exception repository id.
+ String id = input.read_string();
+ ForwardRequest value = new ForwardRequest();
+
+ value.forward_reference = input.read_Object();
+ return value;
+ }
+
+ /**
+ * Create the ForwardRequest typecode (structure,
+ * named "ForwardRequest").
+ * The typecode states that the structure contains the
+ * following fields: forward_reference.
+ */
+ public static TypeCode type()
+ {
+ if (typeCode == null)
+ {
+ ORB orb = ORB.init();
+ StructMember[] members = new StructMember[ 1 ];
+
+ TypeCode field;
+
+ field = ObjectHelper.type();
+ members [ 0 ] = new StructMember("forward_reference", field, null);
+ typeCode = orb.create_exception_tc(id(), "ForwardRequest", members);
+ }
+ return typeCode;
+ }
+
+ /**
+ * Write the exception to the CDR output stream.
+ *
+ * @param output a org.omg.CORBA.portable stream stream to write into.
+ * @param value a value to write.
+ */
+ public static void write(OutputStream output, ForwardRequest value)
+ {
+ // Write the exception repository id.
+ output.write_string(id());
+ output.write_Object(value.forward_reference);
+ }
+}
\ No newline at end of file
--- /dev/null
+/* IdAssignmentPolicy.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., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 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.PortableServer;
+
+import org.omg.CORBA.Policy;
+import org.omg.CORBA.portable.IDLEntity;
+
+/**
+ * Specifies the Object Id assignment policy.
+ *
+ * The policy can return its current value, as defined.
+ * in {@link IdAssignmentPolicyOperations}.
+ *
+ * @see IdAssignmentPolicyValue for the possible values of this policy.
+ *
+ * @author Audrius Meskauskas, Lithuania (AudriusA@Bioinformatics.org)
+ */
+public interface IdAssignmentPolicy
+ extends Policy, IdAssignmentPolicyOperations, IDLEntity
+{
+}
\ No newline at end of file
--- /dev/null
+/* IdAssignmentPolicyOperations.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., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 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.PortableServer;
+
+import org.omg.CORBA.PolicyOperations;
+
+/**
+ * Defines the operations, applicable to the IdAssignmentPolicy.
+ *
+ * @author Audrius Meskauskas, Lithuania (AudriusA@Bioinformatics.org)
+ */
+public interface IdAssignmentPolicyOperations
+ extends PolicyOperations
+{
+ /**
+ * Return the value of this policy type, stated by the current instance.
+ */
+ IdAssignmentPolicyValue value();
+}
\ No newline at end of file
--- /dev/null
+/* IdUniquenessPolicy.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., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 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.PortableServer;
+
+import org.omg.CORBA.Policy;
+import org.omg.CORBA.portable.IDLEntity;
+
+/**
+ * Specfies the Id uniqueness policy.
+ *
+ * The policy can return its current value, as defined.
+ * in {@link IdUniquenessPolicyOperations}.
+ *
+ * @see IdUniquenessPolicyValue for the possible values of this policy.
+ *
+ * @author Audrius Meskauskas, Lithuania (AudriusA@Bioinformatics.org)
+ */
+public interface IdUniquenessPolicy
+ extends Policy, IdUniquenessPolicyOperations, IDLEntity
+{
+}
\ No newline at end of file
--- /dev/null
+/* IdUniquenessPolicyOperations.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., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 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.PortableServer;
+
+import org.omg.CORBA.PolicyOperations;
+
+/**
+ * Defines the operations, applicable to the IdUniquenessPolicy.
+ *
+ * @author Audrius Meskauskas, Lithuania (AudriusA@Bioinformatics.org)
+ */
+public interface IdUniquenessPolicyOperations
+ extends PolicyOperations
+{
+ /**
+ * Return the value of this policy type, stated by the current instance.
+ */
+ IdUniquenessPolicyValue value();
+}
\ No newline at end of file
--- /dev/null
+/* ImplicitActivationPolicy.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., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 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.PortableServer;
+
+import org.omg.CORBA.Policy;
+import org.omg.CORBA.portable.IDLEntity;
+
+/**
+ * Specifies the implicit activation policy.
+ *
+ * The policy can return its current value, as defined.
+ * in {@link ImplicitActivationPolicyOperations}.
+ *
+ * @see ImplicitActivationPolicyValue for the possible values of this policy.
+ *
+ * @author Audrius Meskauskas, Lithuania (AudriusA@Bioinformatics.org)
+ */
+public interface ImplicitActivationPolicy
+ extends Policy, ImplicitActivationPolicyOperations, IDLEntity
+{
+}
\ No newline at end of file
--- /dev/null
+/* ImplicitActivationPolicyOperations.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., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 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.PortableServer;
+
+import org.omg.CORBA.PolicyOperations;
+
+/**
+ * Defines the operations, applicable to the ImplicitActivationPolicy.
+ *
+ * @author Audrius Meskauskas, Lithuania (AudriusA@Bioinformatics.org)
+ */
+public interface ImplicitActivationPolicyOperations
+ extends PolicyOperations
+{
+ /**
+ * Return the value of this policy type, stated by the current instance.
+ */
+ ImplicitActivationPolicyValue value();
+}
\ No newline at end of file
--- /dev/null
+/* LifespanPolicy.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., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 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.PortableServer;
+
+import org.omg.CORBA.Policy;
+import org.omg.CORBA.portable.IDLEntity;
+
+/**
+ * Specifies the object life span policy, if they can outlive the POA
+ * with that they were first created.
+ *
+ * The policy can return its current value, as defined.
+ * in {@link LifespanPolicyOperations}.
+ *
+ * @see LifespanPolicyValue for the possible values of this policy.
+ *
+ * @author Audrius Meskauskas, Lithuania (AudriusA@Bioinformatics.org)
+ */
+public interface LifespanPolicy
+ extends Policy, LifespanPolicyOperations, IDLEntity
+{
+}
\ No newline at end of file
--- /dev/null
+/* LifespanPolicyOperations.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., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 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.PortableServer;
+
+import org.omg.CORBA.PolicyOperations;
+
+/**
+ * Defines the operations, applicable to the LifespanPolicy.
+ *
+ * @author Audrius Meskauskas, Lithuania (AudriusA@Bioinformatics.org)
+ */
+public interface LifespanPolicyOperations
+ extends PolicyOperations
+{
+ /**
+ * Return the value of this policy type, stated by the current instance.
+ */
+ LifespanPolicyValue value();
+}
\ No newline at end of file
--- /dev/null
+/* POA.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., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 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.PortableServer;
+
+import org.omg.CORBA.portable.IDLEntity;
+
+/**
+ * <p>
+ * The Portable Object Adapter (POA) provides more control on the request
+ * processing than it is possible when connecting objects directly to the
+ * ORB. For details, see the general description of the
+ * <code>org.omg.PortableServer</code> package.
+ * </p><p>
+ * The operations, supported by POA are defined
+ * separately in {@link POAOperations}. In the simpliest case, the servant
+ * implementation is connected to POA by
+ * {@link POAOperations#servant_to_reference}, the returned object being a
+ * target of remote and local invocations, despite the numerous other
+ * strategies are possible.
+ * </p>
+ *
+ * @see org.omg.CORBA.ORB.resolve_initial_references
+ * @see POAOperations.servant_to_reference
+ *
+ * @author Audrius Meskauskas, Lithuania (AudriusA@Bioinformatics.org)
+ */
+public interface POA
+ extends POAOperations, IDLEntity, org.omg.CORBA.Object
+{
+}
\ No newline at end of file
--- /dev/null
+/* POAHelper.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., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 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.PortableServer;
+
+import org.omg.CORBA.BAD_PARAM;
+import org.omg.CORBA.TypeCode;
+import org.omg.CORBA.ORB;
+import org.omg.CORBA.Any;
+import org.omg.CORBA.portable.InputStream;
+import org.omg.CORBA.MARSHAL;
+import org.omg.CORBA.portable.OutputStream;
+
+/**
+ * The helper operations for the CORBA object {@link POA}.
+ *
+ * @author Audrius Meskauskas, Lithuania (AudriusA@Bioinformatics.org)
+ */
+public abstract class POAHelper
+{
+ /**
+ * Cast the passed object into the POA. As POA is a local object, the method
+ * just uses java type cast.
+ *
+ * @param obj the object to narrow.
+ * @return narrowed instance.
+ * @throws BAD_PARAM if the passed object is not a POA.
+ */
+ public static POA narrow(org.omg.CORBA.Object obj)
+ {
+ try
+ {
+ return (POA) obj;
+ }
+ catch (ClassCastException cex)
+ {
+ throw new BAD_PARAM(obj.getClass().getName() + " is not a POA");
+ }
+ }
+
+ /**
+ * Get the type code of the {@link POA}.
+ */
+ public static TypeCode type()
+ {
+ return ORB.init().create_interface_tc(id(), "POA");
+ }
+
+ /**
+ * Insert the POA into the given Any.
+ *
+ * @param any the Any to insert into.
+ *
+ * @param that the POA to insert.
+ */
+ public static void insert(Any any, POA that)
+ {
+ any.insert_Object(that);
+ }
+
+ /**
+ * Extract the POA from given Any.
+ *
+ * @throws BAD_OPERATION if the passed Any does not contain POA.
+ */
+ public static POA extract(Any any)
+ {
+ return narrow(any.extract_Object());
+ }
+
+ /**
+ * Get the POA repository id.
+ *
+ * @return "IDL:omg.org/PortableServer/POA:2.3", always.
+ */
+ public static String id()
+ {
+ return "IDL:omg.org/PortableServer/POA:2.3";
+ }
+
+ /**
+ * This should read POA from the CDR input stream, but, following the specs,
+ * it doesnot. The jdk 1.5 API specification defines that POA cannot be
+ * exported.
+ *
+ * @param input a org.omg.CORBA.portable stream to read from.
+ *
+ * @specenote Sun throws the same exception.
+ *
+ * @throws MARSHAL, always.
+ */
+ public static POA read(InputStream input)
+ {
+ throw new MARSHAL("Not applicable");
+ }
+
+ /**
+ * This should read POA from the CDR input stream, but, following the specs,
+ * it doesnot. The jdk 1.5 API specification defines that POA cannot be
+ * exported.
+ *
+ * @param input a org.omg.CORBA.portable stream to read from.
+ *
+ * @specenote Sun throws the same exception.
+ *
+ * @throws MARSHAL, always.
+ */
+ public static void write(OutputStream output, POA value)
+ {
+ throw new MARSHAL("Not applicable");
+ }
+}
\ No newline at end of file
--- /dev/null
+/* POAManager.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., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 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.PortableServer;
+
+import org.omg.CORBA.portable.IDLEntity;
+
+/**
+ * <p>
+ * A POA manager is associated with one or more POAs and provides means
+ * to regulate they activity. Using manage, it is possible to force
+ * requests for those POAs to be queued or discarded or have those POAs
+ * deactivated. The manager can turn POAs to and from holding,
+ * active and discarding states, but the incative state is irreversible.
+ * </p>
+ * <p>
+ * The manager of the ORBs root POA can be obtained by resolving initial
+ * reference "RootPOAManager".
+ * </p>
+ *
+ * @see POAManagerOperations
+ *
+ * @author Audrius Meskauskas, Lithuania (AudriusA@Bioinformatics.org)
+ */
+public interface POAManager
+ extends POAManagerOperations, IDLEntity, org.omg.CORBA.Object
+{
+}
\ No newline at end of file
--- /dev/null
+/* POAManagerOperations.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., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 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.PortableServer;
+
+import org.omg.PortableServer.POAManagerPackage.AdapterInactive;
+import org.omg.PortableServer.POAManagerPackage.State;
+
+/**
+ * Defines the operations, applicable to the {@link POAManager}.
+ * These operations can turn the associated POAs to and from holding,
+ * active and discarding states, but the incative state is irreversible.
+ * The inactivated POAs can only be recreated after they were destroyed.
+ *
+ * @author Audrius Meskauskas, Lithuania (AudriusA@Bioinformatics.org)
+ */
+public interface POAManagerOperations
+{
+ /**
+ * Turns the associated POAs into active state, allowing them to receive
+ * and process requests.
+ *
+ * @throws AdapterInactive if the POAs are in the inactive state. If
+ * once inactivated, the POA cannot be activated again.
+ * This method can only be called to leave the holding or discarding state.
+ */
+ void activate()
+ throws AdapterInactive;
+
+ /**
+ * <p>
+ * Turns the asociated POAs into inactive state. The POAs in the incative
+ * state will reject new requests. A cliet, trying to invoke an
+ * object, belonging to the inactivated POA, will receive the remote exception
+ * ({@link org.omg.CORBA.OBJ_ADAPTER}, minor code 0x535503ea, incomplete).
+ * </p><p>
+ * If the POA is once inactivated, it cannot be activated again.
+ * The operation is used when the associated POAs are to be shut down.
+ * </p>
+ * <p>
+ * Some independent implementations may set the minor code of the
+ * OBJ_ADAPTER to 1, as recommended by OMG (formal/04-03-12).
+ * The interoperable systems should expect any of these two values.
+ * </p>
+ *
+ * @param etherealize_objects if true, the servant managers of the
+ * associated POAs, having RETAIN and USE_SERVANT_MANAGER policies,
+ * will receive a call of {@link ServantActivatorOperations#etherealize}.
+ *
+ * @param wait_for_completion if true, the method call suspends the current
+ * thread till POAs complete the requests they are currently processing. If
+ * false, the method returns immediately.
+ * <p>
+ *
+ * @specnote The 0x535503ea is a Sun specific minor exception code 1002,
+ * used for interoperability reasons.
+ *
+ * @throws AdapterInactive if the POAs are already in the inactive state.
+ *
+ * @see POAOperations#destroy
+ */
+ void deactivate(boolean etherealize_objects, boolean wait_for_completion)
+ throws AdapterInactive;
+
+ /**
+ * <p>
+ * Turns the associated POAs into discaring state. In this state, the POAs
+ * discard the incoming requests. This mode is used in situations when
+ * the server is flooded with requests. The client receives remote exception
+ * ({@link org.omg.CORBA.TRANSIENT}, minor code 0x535503e9, incomplete).
+ * </p><p>
+ * Some independent implementations may set the minor code of the
+ * TRANSIENT to 1, as recommended by OMG (formal/04-03-12).
+ * The interoperable systems should expect any of these two values.
+ * </p>
+ *
+ * @param wait_for_completion if true, the method call suspends the current
+ * thread till POAs complete the requests they are currently processing. If
+ * false, the method returns immediately.
+ *
+ * @specnote The 0x535503e9 is a Sun specific minor exception code 1001,
+ * used for interoperability reasons.
+ *
+ * @throws AdapterInactive if the POAs are in the inactive state.
+ */
+ void discard_requests(boolean wait_for_completion)
+ throws AdapterInactive;
+
+ /**
+ * Get the state of the POA manager.
+ */
+ State get_state();
+
+ /**
+ * Turns the associated POAs into holding state. In this state, the POAs
+ * queue incoming requests but do not process them.
+ *
+ * @param wait_for_completion if true, the method call suspends the current
+ * thread till POAs complete the requests they are currently processing. If
+ * false, the method returns immediately.
+
+ * @throws AdapterInactive if the POAs are in the inactive state.
+ */
+ void hold_requests(boolean wait_for_completion)
+ throws AdapterInactive;
+}
\ No newline at end of file
--- /dev/null
+/* POAOperations.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., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 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.PortableServer;
+
+import org.omg.CORBA.Policy;
+import org.omg.PortableServer.POAPackage.AdapterAlreadyExists;
+import org.omg.PortableServer.POAPackage.AdapterNonExistent;
+import org.omg.PortableServer.POAPackage.InvalidPolicy;
+import org.omg.PortableServer.POAPackage.NoServant;
+import org.omg.PortableServer.POAPackage.ObjectAlreadyActive;
+import org.omg.PortableServer.POAPackage.ObjectNotActive;
+import org.omg.PortableServer.POAPackage.ServantAlreadyActive;
+import org.omg.PortableServer.POAPackage.ServantNotActive;
+import org.omg.PortableServer.POAPackage.WrongAdapter;
+import org.omg.PortableServer.POAPackage.WrongPolicy;
+
+/**
+ * Defines the operations, applicable to the POA.
+ *
+ * @author Audrius Meskauskas, Lithuania (AudriusA@Bioinformatics.org)
+ */
+public interface POAOperations
+{
+ /**
+ * Creates a new POA as a child of the target POA.
+ *
+ * @param child_name the name of the child POA being created.
+ * @param manager the manager that will control the new POA. If this parameter
+ * is null, a new POA manager is created and associated with the new POA.
+ *
+ * @param policies the policies, applicable for the parent POA. Policies
+ * are <i>not</i> inherited from the parent POA. If some policy type
+ * is missing in the array (or the zero size array is passed), the missing
+ * policies obtain the default values from the table, specified
+ * in the {@link POA} documentation header.
+ *
+ * @return an newly created POA. The POA will be intially in the holding
+ * state and must be activated to start processing requests.
+ *
+ * @throws AdapterAlreadyExists if the child with the given child_name
+ * already exists for the current POA.
+ * @throws InvalidPolicy if the policies conflict with each other or are
+ * otherwise inappropriate.
+ *
+ * @see POA for the list of required policies.
+ * @see #the_children()
+ */
+ POA create_POA(String child_name, POAManager manager, Policy[] policies)
+ throws AdapterAlreadyExists, InvalidPolicy;
+
+ /**
+ * Find and optionally activate the child POA with the given name.
+ *
+ * @param poa_name the name of the POA to find.
+ * @param activate_it if the child with the specified name is not found
+ * or inactive and this parameter is true, the target POA activator is
+ * invoked to activate that child. If this succeeds, that child POA
+ * is returned.
+ *
+ * @throws AdapterNonExistent if no active child with the given name
+ * is found and one of the following is true:
+ * a) the target POA has no associated
+ * {@link AdapterActivator}. b) that activator fails to activate the
+ * child POA. c) <code>activate_id</code> = false.
+ */
+ POA find_POA(String poa_name, boolean activate_it)
+ throws AdapterNonExistent;
+
+ /**
+ * Generate the Object Id for the given servant and add the servant to
+ * the Active Object Map using this Id a a key. If the servant
+ * activator is set, its incarnate method will be called. In this case,
+ * the passed servant in this method can be null; in this case, the servant,
+ * returned by {@link ServantLocatorOperations#incarnate} will
+ * be used.
+ *
+ * @param a_servant a servant that would serve the object with the
+ * returned Object Id.
+ *
+ * @return the generated objert Id for the given servant.
+ *
+ * @throws ServantAlreadyActive if this servant is already in the
+ * Active Object Map and the UNIQUE_ID policy applies.
+ *
+ * @throws WrongPolicy if the required policies SYSTEM_ID and RETAIN
+ * do not apply to this POA.
+ */
+ byte[] activate_object(Servant a_servant)
+ throws ServantAlreadyActive, WrongPolicy;
+
+ /**
+ * Add the given servant to the Active Object Map as a servant for the
+ * object with the provided Object Id. If the servant activator is
+ * set, its incarnate method will be called. In this case,
+ * the passed servant in this method can be null; in this case, the servant,
+ * returned by {@link ServantLocatorOperations#incarnate} will
+ * be used.
+ *
+ * @param an_Object_Id an object id for the given object.
+ * @param a_servant a servant that will serve the object with the given
+ * Object Id.
+ *
+ * @throws ObjectAlreadyActive if the given object id is already in the
+ * Active Object Map.
+ * @throws WrongPolicy if the required RETAIN policy does not apply to
+ * this POA.
+ * @throws BAD_PARAM if the passed object id is invalid due any reason.
+ */
+ void activate_object_with_id(byte[] an_Object_Id, Servant a_servant)
+ throws ServantAlreadyActive, ObjectAlreadyActive,
+ WrongPolicy;
+
+ /**
+ * <p>Deactivate object with the given id. Client, trying to call
+ * method on the deactivated object will either receive the remote
+ * exception ({@link org.omg.CORBA.OBJECT_NOT_EXIST}, minor 0x535503ec),
+ * incomplete) or the object will be reactivated and serve the request.
+ * The object can be reactivated only if the implicit activation
+ * policy applies and the servant activator is set.</p><p>
+ * The deactivated object will continue to process requests that arrived
+ * before decativation.
+ * If this POA has the associated servant manager, a
+ * {@link ServantActivatorOperations#etherealize} is <i>immediately</i>
+ * invoked on the passed id. The deactivated object can be reactivated
+ * by {@link #activate_object_with_id}.</p>
+ * <p>The deactivation will not release thread, port or memory resources,
+ * taken by that object. This is due requirement to make the
+ * object reactivation possible at any time. To release the resources,
+ * you must destroy the POA.
+ * </p>
+ *
+ * @throws WrongPolicy if the required RETAIN policy does not apply to
+ * this POA.
+ */
+ void deactivate_object(byte[] the_Object_Id)
+ throws ObjectNotActive, WrongPolicy;
+
+ /**
+ * Create the object reference, encapsulating the given repository Id and
+ * the Object Id, generated by this POA. The returned object will not be
+ * activated by default and may be activated on the first invocation by
+ * the servant manager (if it is set and if policies are applicable).
+ * The returned object can also be narrowed by helper and used locally.
+ * In this case, the servant will be activated on the first local call of
+ * any method. The methods on returned object can also be invoked by
+ * name, using {@link org.omg.CORBA.Request}.
+ *
+ * @param a_repository_id the repository id for the given object. When
+ * narrowing the returned object with some helper, it will be checked for
+ * equality with value, returned by the the helper id().
+ *
+ * @throws WrongPolicy if the required SYSTEM_ID policy does not apply to
+ * this POA.
+ */
+ org.omg.CORBA.Object create_reference(String a_repository_id)
+ throws WrongPolicy;
+
+ /**
+ * <p> Create the object reference, encapsulating the given repository Id and
+ * the given Object Id. The returned object will not be
+ * activated by default and may be activated on the first invocation by
+ * the servant manager (if it is set and if policies are applicable).
+ * </p><p>
+ * The returned object can also be narrowed by helper and used locally.
+ * In this case, the servant will be activated on the first local call of
+ * any method. The methods on returned object can also be invoked by
+ * name, using {@link org.omg.CORBA.Request}.
+ * </p>
+ *
+ * @param an_object_id the object id for the object being created.
+ * If the POA uses the SYSTEM_ID policy, the portable application
+ * must only supply ids, generated by that POA.
+ *
+ * @param a_repository_id the repository id for the given object. When
+ * narrowing the returned object with some helper, it will be checked for
+ * equality with value, returned by the the helper id().
+ */
+ org.omg.CORBA.Object create_reference_with_id(byte[] an_object_id,
+ String a_repository_id
+ );
+
+ /**
+ * Returns a default servant for this POA.
+ *
+ * @return a servant that will be used for requests for
+ * which no servant is found in the Active Object Map.
+ *
+ * @throws NoServant if there is no default servant associated with this POA.
+ * @throws WrongPolicy if the USE_DEFAULT_SERVANT policy is not active.
+ */
+ Servant get_servant()
+ throws NoServant, WrongPolicy;
+
+ /**
+ * Sets the default servant for this POA.
+ *
+ * @param a_servant a servant that will be used for requests for
+ * which no servant is found in the Active Object Map.
+ *
+ * @throws WrongPolicy if the USE_DEFAULT_SERVANT policy is not active.
+ */
+ void set_servant(Servant a_servant)
+ throws WrongPolicy;
+
+ /**
+ * Set a servant manager for this POA.
+ *
+ * @param a servant manager being set. If the RETAIN policy applies, the
+ * manager must implement a {@link ServantActivator}. If the NON_RETAIN
+ * policy applies, the manager must implement a {@link ServantLocator}.
+ *
+ * @throws WrongPolicy if the required USE_SERVANT_MANAGER policy does not
+ * apply to this POA.
+ *
+ * @throws OBJ_ADAPTER minor code 4 if the passed manager does not
+ * implement the required interface ({@link ServantActivator},
+ * {@link ServantLocator}).
+ *
+ * @throws BAD_INV_ORDER minor code 6 if the method is called more than once
+ * on the same POA. The manager can be set only once.
+ */
+ void set_servant_manager(ServantManager a_manager)
+ throws WrongPolicy;
+
+ /**
+ * Get the servant manager, associated with this POA.
+ *
+ * @return the associated servant manager or null if it has
+ * been previously set.
+ *
+ * @throws WrongPolicy if the required USE_SERVANT_MANAGER policy does not
+ * apply to this POA.
+ */
+ ServantManager get_servant_manager()
+ throws WrongPolicy;
+
+ /**
+ * Get the unique Id of the POA in the process in which it is created.
+ * This Id is needed by portable interceptors. The id is unique
+ * for the life span of the POA in the process. For persistent
+ * POAs, if a POA is created in the same path with the same name as
+ * another POA, these POAs are identical have the same id. All transient
+ * POAs are assumed unique.
+ */
+ byte[] id();
+
+ /**
+ * Returns the reference to the active object with the given Id.
+ *
+ * @param the_Object_Id the object id.
+ *
+ * @throws ObjectNotActive if there is no active object with such Id.
+ * @throws WrongPolicy if the required RETAIN policy does not apply to
+ * this POA.
+ */
+ org.omg.CORBA.Object id_to_reference(byte[] the_Object_Id)
+ throws ObjectNotActive, WrongPolicy;
+
+ /**
+ * Returns the servant that serves the active object with the given Id.
+ *
+ * @param the_Object_Id the object id.
+ *
+ * @throws ObjectNotActive if there is no active object with such Id.
+ * @throws WrongPolicy. This method requires either RETAIN or
+ * USE_DEFAULT_SERVANT policies and reaises the WrongPolicy if none of them
+ * apply to this POA.
+ */
+ Servant id_to_servant(byte[] the_Object_Id)
+ throws ObjectNotActive, WrongPolicy;
+
+ /**
+ * Returns the Object Id, encapsulated in the given object reference.
+ *
+ * @param the_Object the object that has been previously created with this
+ * POA. It need not be active.
+ *
+ * @throws WrongAdapter if the passed object has not been previously created
+ * with this POA.
+ * @throws WrongPolicy never (declared for the future extensions only).
+ */
+ byte[] reference_to_id(org.omg.CORBA.Object the_Object)
+ throws WrongAdapter, WrongPolicy;
+
+ /**
+ * Returns the servant that is serving this object.
+ *
+ * @return if the RETAIN policy applies and the object is in the Active
+ * Object Map, the method returns the servant, associated with this object.
+ * Otherwise, if the USE_DEFAULT_SERVANT policy applies, the method returns
+ * the default servant (if one was set).
+ *
+ * @throws ObjectNotActive if none of the conditions above are satisfied.
+ * @throws WrongAdapter if the object reference was not created with this POA.
+ * @throws WrongPolicy. This method requires either RETAIN or
+ * USE_DEFAULT_SERVANT policies and reaises the WrongPolicy if none of them
+ * apply to this POA.
+ */
+ Servant reference_to_servant(org.omg.CORBA.Object the_Object)
+ throws ObjectNotActive, WrongPolicy, WrongAdapter;
+
+ /**
+ * Returns the id of the object, served by the given servant. The id is found
+ * in one of the following ways.
+ * <ul>
+ * <li>If the POA has both the RETAIN and the UNIQUE_ID policy and
+ * the specified servant is active, the method return the Object Id associated
+ * with that servant.
+ * </li><li>
+ * If the POA has both the RETAIN and the IMPLICIT_ACTIVATION policy and
+ * either the POA has the MULTIPLE_ID policy or the specified servant is
+ * inactive, the method activates the servant using a POA-generated Object Id
+ * and the Interface Id associated with the servant, and returns that
+ * Object Id.
+ * </li>
+ * <li>If the POA has the USE_DEFAULT_SERVANT policy, the servant specified
+ * is the default servant, and the method is being invoked in the context o
+ * f executing a request on the default servant, the method returns the
+ * ObjectId associated with the current invocation.
+ * </li>
+ * </ul>
+ * @throws ServantNotActive in all cases, not listed in the list above.
+ * @throws WrongPolicy The method requres USE_DEFAULT_SERVANT policy or
+ * a combination of the RETAIN policy and either the UNIQUE_ID or
+ * IMPLICIT_ACTIVATION policies and throws the WrongPolicy if these conditions
+ * are not satisfied.
+ */
+ byte[] servant_to_id(Servant the_Servant)
+ throws ServantNotActive, WrongPolicy;
+
+ /**
+ * <p>Converts the given servant to the object reference.
+ * The servant will serve all methods, invoked on the returned object.
+ * The returned object reference can be passed to the remote client,
+ * enabling remote invocations.
+ * </p><p>
+ * If the specified servant already serves some active object, that
+ * object is returned. Otherwise,
+ * if the POA has the IMPLICIT_ACTIVATION policy the method activates
+ * the servant, creating an new object with the POA-generated Object Id.
+ * In this case, if the servant activator is set, the
+ * {@link ServantActivatorOperations#incarnate} method will be called.
+ * </p>
+ *
+ * @throws ServantNotActive if the servant is inactive and no
+ * IMPLICIT_ACTIVATION policy applies.
+ * @throws WrongPolicy This method needs the RETAIN policy and either the
+ * UNIQUE_ID or IMPLICIT_ACTIVATION policies.
+ *
+ * @return the object, exposing the given servant in the context of this POA.
+ */
+ org.omg.CORBA.Object servant_to_reference(Servant the_Servant)
+ throws ServantNotActive, WrongPolicy;
+
+ /**
+ * Return the POA manager, associated with this POA.
+ *
+ * @return the associated POA manager (always available).
+ */
+ POAManager the_POAManager();
+
+ /**
+ * Returns the adapter activator, associated with this POA.
+ * The newly created POA has no activator (null would be
+ * returned). The ORB root POA also initially has no activator.
+ *
+ * @return tha adapter activator or null if this POA has no
+ * associated adapter activator.
+ */
+ AdapterActivator the_activator();
+
+ /**
+ * Set the adapter activator for this POA.
+ *
+ * @param the activator being set.
+ */
+ void the_activator(AdapterActivator activator);
+
+ /**
+ * The children of this POA.
+ *
+ * @return the array of all childs for this POA.
+ */
+ POA[] the_children();
+
+ /**
+ * Return the name of this POA.
+ *
+ * @return the name of POA, relative to its parent.
+ */
+ String the_name();
+
+ /**
+ * Return the parent of this POA.
+ *
+ * @return the parent POA or <code>null</code> if this is a root POA.
+ */
+ POA the_parent();
+
+ /**
+ * <p> Destroy this POA and all descendant POAs. The destroyed POAs can be
+ * later re-created via {@link AdapterActivator} or by invoking
+ * {@link #create_POA}.
+ * This differs from {@link PoaManagerOperations#deactivate} that does
+ * not allow recreation of the deactivated POAs. After deactivation,
+ * recreation is only possible if the POAs were later destroyed.
+ * </p><p>
+ * The remote invocation on the target, belonging to the POA that is
+ * currently destroyed return the remote exception ({@link TRANSIENT},
+ * minor code 4).
+ * </p>
+ * @param etherealize_objects if true, and POA has RETAIN policy, and the
+ * servant manager is available, the servant manager method
+ * {@link ServantActivatorOperations#etherealize} is called for each
+ * <i>active</i> object in the Active Object Map. This method should not
+ * try to access POA being destroyed. If <code>destroy</code> is called
+ * multiple times before the destruction completes,
+ * the etherialization should be invoked only once.
+ *
+ * @param wait_for_completion if true, the method waits till the POA being
+ * destroyed completes all current requests and etherialization. If false,
+ * the method returns immediately.
+ */
+ void destroy(boolean etherealize_objects, boolean wait_for_completion);
+
+ /**
+ * Create the IdUniquenessPolicy policy.
+ *
+ * @param value states which one Id uniqueness policy will apply.
+ *
+ * @return the created policy.
+ */
+ IdUniquenessPolicy create_id_uniqueness_policy(IdUniquenessPolicyValue a_value);
+
+ /**
+ * Create the ImplicitActivationPolicy policy.
+ *
+ * @param value states which one activation policy will apply.
+ *
+ * @return the created policy.
+ */
+ ImplicitActivationPolicy create_implicit_activation_policy(ImplicitActivationPolicyValue a_value);
+
+ /**
+ * Create the LifespanPolicy policy.
+ *
+ * @param value states which one object lifespan policy will apply.
+ *
+ * @return the created policy.
+ */
+ LifespanPolicy create_lifespan_policy(LifespanPolicyValue a_value);
+
+ /**
+ * Create the RequestProcessingPolicy policy.
+ *
+ * @param value states which one request processing policy will apply.
+ *
+ * @return the created policy.
+ */
+ RequestProcessingPolicy create_request_processing_policy(RequestProcessingPolicyValue a_value);
+
+ /**
+ * Create the ServantRetentionPolicy policy.
+ *
+ * @param value states which one servant retention policy will apply.
+ *
+ * @return the created policy.
+ */
+ ServantRetentionPolicy create_servant_retention_policy(ServantRetentionPolicyValue a_value);
+
+ /**
+ * Create the ThreadPolicy policy.
+ *
+ * @param value states which one thread policy will apply.
+ *
+ * @return the created policy.
+ */
+ ThreadPolicy create_thread_policy(ThreadPolicyValue a_value);
+
+ /**
+ * Create the ID assignment policy with the given value.
+ *
+ * @param value states which one ID assignment policy will apply.
+ *
+ * @return the created policy.
+ */
+ IdAssignmentPolicy create_id_assignment_policy(IdAssignmentPolicyValue value);
+
+}
\ No newline at end of file
--- /dev/null
+/* RequestProcessingPolicy.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., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 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.PortableServer;
+
+import org.omg.CORBA.Policy;
+import org.omg.CORBA.portable.IDLEntity;
+
+/**
+ * Specifies the behaviour in the case when the
+ * requested object is not found in the Active Object Map or that map
+ * is not in use.
+ *
+ * The policy can return its current value, as defined.
+ * in {@link RequestProcessingPolicyOperations}.
+ *
+ * @see RequestProcessingPolicyValue for the possible values of this policy.
+ *
+ * @author Audrius Meskauskas, Lithuania (AudriusA@Bioinformatics.org)
+ */
+public interface RequestProcessingPolicy
+ extends Policy, RequestProcessingPolicyOperations, IDLEntity
+{
+}
\ No newline at end of file
--- /dev/null
+/* RequestProcessingPolicyOperations.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., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 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.PortableServer;
+
+import org.omg.CORBA.PolicyOperations;
+
+/**
+ * Defines the operations, applicable to the RequestProcessingPolicy.
+ *
+ * @author Audrius Meskauskas, Lithuania (AudriusA@Bioinformatics.org)
+ */
+public interface RequestProcessingPolicyOperations
+ extends PolicyOperations
+{
+ /**
+ * Return the value of this policy type, stated by the current instance.
+ */
+ RequestProcessingPolicyValue value();
+}
\ No newline at end of file
--- /dev/null
+/* Servant.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., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 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.PortableServer;
+
+import org.omg.CORBA.BAD_OPERATION;
+import org.omg.CORBA.NO_IMPLEMENT;
+import org.omg.CORBA.OBJECT_NOT_EXIST;
+import org.omg.CORBA.ORB;
+import org.omg.PortableServer.POAPackage.ServantNotActive;
+import org.omg.PortableServer.POAPackage.WrongPolicy;
+import org.omg.PortableServer.portable.Delegate;
+import gnu.CORBA.Poa.ORB_1_4;
+import gnu.CORBA.Poa.gnuPOA;
+
+/**
+ * <p>
+ * The servant is responsible for handling the method invocation on the
+ * target object. It can be one servant per object, or the same servant can
+ * support several (possibly all) objects, associated with the given POA.
+ * </p> <p>
+ * Till JDK 1.3 inclusive, a typical IDL to java compiler generates an
+ * implementation base (name pattern _*ImplBase.java) that is derived from the
+ * {@link org.omg.CORBA.portable.ObjectImpl}. Since JDK 1.4 the implementation
+ * base is derived from the Servant, also having a different name pattern
+ * (*POA.java). This suffix may be confusing, as the servant itself is
+ * <i>not</i> POA nor it is derived from it.
+ * </p><p>
+ * In both cases, the implementation base also inherits an interface, containing
+ * definitions of the application specific methods. The application programmer
+ * writes a child of the implementation base, implementing these methods
+ * for the application-specific functionality. The ObjectImpl is connected
+ * directly to the ORB. The Servant is connected to POA that can be obtained
+ * from the ORB.
+ * </p><p>
+ * If the servant is connected to more than one object, the exact object
+ * being currently served can be identified with {@link #_object_id}.
+ * </p><p>
+ * The derivativ of Servant, being directly connected to serve requests,
+ * must inherit either from {@link org.omg.CORBA.portable.InvokeHandler}
+ * or from {@link org.omg.PortableServer.DynamicImplementation}).
+ * </p><p>
+ * The Servant type is a CORBA <code>native</code> type.
+ * </p>
+ *
+ * @see POA.servant_to_reference(Servant)
+ *
+ * @author Audrius Meskauskas, Lithuania (AudriusA@Bioinformatics.org)
+ */
+public abstract class Servant
+{
+ /**
+ * The delegate, where calls to some Servant methods are forwarded.
+ */
+ private Delegate delegate;
+
+ /**
+ * Get the repository ids of all interfaces, supported by the
+ * CORBA object, identified by the passed Id. In the typical code the
+ * passed parameters are ignored, returning an array of repository ids,
+ * supported by the servant implementation.
+ *
+ * @param poa a POA of the given object.
+ * @param object_ID the object Id of the given object.
+ *
+ * @return an array, containing the repository ids.
+ */
+ public abstract String[] _all_interfaces(POA poa, byte[] object_ID);
+
+ /**
+ * Get the delegate, where calls to some Servant methods are forwarded.
+ */
+ public final Delegate _get_delegate()
+ {
+ return delegate;
+ }
+
+ /**
+ * Get the interface repository definition <code>InterfaceDef</code> for this
+ * Object. By default, forwards request to the delegate.
+ *
+ * @specnote The interface repository is officially not implemented up till
+ * JDK 1.5 inclusive. The delegate throws NO_IMPLEMENT, always.
+ */
+ public org.omg.CORBA.Object _get_interface_def()
+ {
+ throw new NO_IMPLEMENT();
+ }
+
+ /**
+ * Checks if the passed servant is an instance of the given CORBA IDL type.
+ * By default, forwards the requet to the delegate.
+ *
+ * @param a_servant a servant to check.
+ * @param an_id a repository ID, representing an IDL type for that the
+ * servant must be checked.
+ *
+ * @return true if the servant is an instance of the given type, false
+ * otherwise.
+ */
+ public boolean _is_a(String repository_id)
+ {
+ return delegate.is_a(this, repository_id);
+ }
+
+ /**
+ * Determines if the server object for this reference has already
+ * been destroyed. By default, forwards request to the delegate.
+ *
+ * @return true if the object has been destroyed, false otherwise.
+ */
+ public boolean _non_existent()
+ {
+ return delegate.non_existent(this);
+ }
+
+ /**
+ * Returns the ORB that is directly associated with the given servant.
+ * In this implementation, the method is overridden to return
+ */
+ public final ORB _orb()
+ {
+ return delegate.orb(this);
+ }
+
+ /**
+ * Returns the root POA of the ORB instance, associated with this servant.
+ * It is the same POA that would be returned by resolving the initial
+ * reference "RootPOA" for that orb. By default, forwards request to the
+ * delegate.
+ *
+ * @see ORB.resolve_initial_references
+ */
+ public POA _default_POA()
+ {
+ return delegate == null ? null : delegate.default_POA(this);
+ }
+
+ /**
+ * Return the invocation target object identifier as a byte array.
+ * This is typically used when the same servant serves multiple objects,
+ * and the object id can encapsulated the whole description of the
+ * object.
+ *
+ * This method returns correct values even when the same
+ * servant serves several objects in parallel threads. The ORB maintains the
+ * thread to invocation data map for all calls that are currently being
+ * processed.
+ */
+ public final byte[] _object_id()
+ {
+ if (delegate != null)
+ return delegate.object_id(this);
+ else
+ throw new OBJECT_NOT_EXIST();
+ }
+
+ /**
+ * Get POA that is directly associated with the given servant.
+ * By default, forwards request to the delegate.
+ */
+ public final POA _poa()
+ {
+ return delegate.poa(this);
+ }
+
+ /**
+ * Set the delegate for this servant.
+ */
+ public final void _set_delegate(Delegate a_delegate)
+ {
+ delegate = a_delegate;
+ }
+
+ /**
+ * Obtains the CORBA object reference that is a current invocation target for
+ * the given servant. This is important when the same servant serves
+ * multiple objects. If the servant is not yet connected to the passed
+ * orb, the method will try to connect it to that orb on POA, returned
+ * by the method {@link _default_POA}. That method can be overridden to
+ * get poa where the object must be automatically connected when
+ * calling this method.
+ *
+ * @param an_orb the ORB with relate to that the object is requested.
+ */
+ public final org.omg.CORBA.Object _this_object(ORB an_orb)
+ {
+ if (delegate != null)
+ return delegate.this_object(this);
+ else
+ {
+ if (an_orb instanceof ORB_1_4)
+ {
+ ORB_1_4 m_orb = (ORB_1_4) an_orb;
+
+ gnuPOA dp = (gnuPOA) _default_POA();
+ if (dp == null)
+ dp = m_orb.rootPOA;
+
+ try
+ {
+ return dp.servant_to_reference(this);
+ }
+ catch (WrongPolicy unexp)
+ {
+ BAD_OPERATION bad = new BAD_OPERATION();
+ bad.initCause(unexp);
+ throw bad;
+ }
+ catch (ServantNotActive ex)
+ {
+ try
+ {
+ return dp.id_to_reference(dp.activate_object(this));
+ }
+ catch (Exception unexp)
+ {
+ unexp.initCause(ex);
+
+ BAD_OPERATION bad = new BAD_OPERATION();
+ bad.initCause(unexp);
+ throw bad;
+ }
+ }
+ }
+ }
+ throw new OBJECT_NOT_EXIST();
+ }
+
+ /**
+ * Obtains the CORBA object reference that is a current invocation target for
+ * the given servant. This is important when the same servant serves
+ * multiple objects. This method required the servant to be connected
+ * to a single orb, and a delegate set.
+ *
+ * This method returns correct values even when the same
+ * servant serves several objects in parallel threads. The ORB maintains the
+ * thread to invocation data map for all calls that are currently being
+ * processed.
+ */
+ public final org.omg.CORBA.Object _this_object()
+ {
+ if (delegate != null)
+ return _this_object(_orb());
+ else
+ {
+ POA def = _default_POA();
+ if (def instanceof gnuPOA)
+ return _this_object(((gnuPOA) def).orb());
+ }
+ throw new OBJECT_NOT_EXIST();
+ }
+}
\ No newline at end of file
--- /dev/null
+/* ServantActivator.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., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 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.PortableServer;
+
+import org.omg.CORBA.portable.IDLEntity;
+
+/**
+ * The POA, that has the RETAIN policy uses servant managers that are
+ * ServantActivators. The operations, that must be supported by these
+ * managers, are defined separately in {@link ServantActivatorOperations}.
+ *
+ * @see ServantLocator
+ * @see ServantRetentionPolicyValue
+ * @see ServantManager
+ * @see POAOperations#set_servant_manager
+ *
+ * @author Audrius Meskauskas, Lithuania (AudriusA@Bioinformatics.org)
+ */
+public interface ServantActivator
+ extends ServantManager, ServantActivatorOperations, IDLEntity,
+ org.omg.CORBA.Object
+{
+}
\ No newline at end of file
--- /dev/null
+/* ServantActivatorHelper.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., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 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.PortableServer;
+
+import org.omg.CORBA.Any;
+import org.omg.CORBA.BAD_PARAM;
+import org.omg.CORBA.MARSHAL;
+import org.omg.CORBA.ORB;
+import org.omg.CORBA.TypeCode;
+import org.omg.CORBA.portable.InputStream;
+import org.omg.CORBA.portable.OutputStream;
+
+/**
+* The helper operations for the CORBA object {@link ServantActivator}.
+*
+* @author Audrius Meskauskas, Lithuania (AudriusA@Bioinformatics.org)
+*/
+public abstract class ServantActivatorHelper
+{
+ /**
+ * Get the type code of the {@link ServantActivator}.
+ */
+ public static TypeCode type()
+ {
+ return ORB.init().create_interface_tc(id(), "ServantActivator");
+ }
+
+ /**
+ * Insert the ServantActivator into the given Any.
+ *
+ * @param any the Any to insert into.
+ * @param that the ServantActivator to insert.
+ */
+ public static void insert(Any any, ServantActivator that)
+ {
+ any.insert_Object(that);
+ }
+
+ /**
+ * Extract the ServantActivator from given Any.
+ *
+ * @throws BAD_OPERATION if the passed Any does not contain ServantActivator.
+ */
+ public static ServantActivator extract(Any any)
+ {
+ return narrow(any.extract_Object());
+ }
+
+ /**
+ * Get the ServantActivator repository id.
+ *
+ * @return "IDL:omg.org/PortableServer/ServantActivator:2.3", always.
+ */
+ public static String id()
+ {
+ return "IDL:omg.org/PortableServer/ServantActivator:2.3";
+ }
+
+ /**
+ * Casts the passed object into the ServantActivator.
+ *
+ * @param obj the object to cast.
+ * @return casted instance.
+ * @throws BAD_PARAM if the passed object is not a ServantActivator.
+ */
+ public static ServantActivator narrow(org.omg.CORBA.Object obj)
+ {
+ try
+ {
+ return (ServantActivator) obj;
+ }
+ catch (ClassCastException ex)
+ {
+ BAD_PARAM bad = new BAD_PARAM();
+ bad.initCause(ex);
+ throw bad;
+ }
+ }
+
+ /**
+ * This should read the servant activator, but it cannot be transferred
+ * this way as its operations cannot be remote. The operations cannot
+ * be remote because one of the method parameters, POA, is required to be
+ * always a local object (both by 1.5 API and 3.0.3 OMG).
+ *
+ * @throws MARSHAL, always.
+ *
+ * @specnote Same as Sun.
+ */
+ public static ServantActivator read(InputStream input)
+ {
+ throw new MARSHAL();
+ }
+
+ /**
+ * This should write the servant activator, but it cannot be transferred
+ * this way as its operations cannot be remote. The operations cannot
+ * be remote because one of the method parameters, POA, is required to be
+ * always a local object (both by 1.5 API and 3.0.3 OMG).
+ *
+ * @throws MARSHAL, always.
+ *
+ * @specnote Same as Sun.
+ */
+ public static void write(OutputStream output, ServantActivator value)
+ {
+ throw new MARSHAL();
+ }
+}
\ No newline at end of file
--- /dev/null
+/* ServantActivatorOperations.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., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 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.PortableServer;
+
+
+/**
+ * Defines the operations, applicable to the {@link ServantActivator}.
+ *
+ * @author Audrius Meskauskas, Lithuania (AudriusA@Bioinformatics.org)
+ */
+public interface ServantActivatorOperations
+ extends ServantManagerOperations
+{
+ /**
+ * This method is invoked whenever a servant for an object is deactivated,
+ * assuming the POA has the USE_SERVANT_MANAGER and RETAIN policies.
+ *
+ * @param Object_Id the Id of the object being deactivated.
+ *
+ * @param poa the POA in those scope the object was active.
+ *
+ * @param servant the servant, serving the object being deactivated.
+ *
+ * @param cleanup_in_progress if true, this method was called from due
+ * deactivation or destruction operation. False indicates that the method
+ * was called due other reasons.
+ *
+ * @param remaining_activations if true, at the invocation moment the
+ * passed servant is also associated with other objects in the active
+ * object map of the given POA.
+ */
+ void etherealize(byte[] Object_Id, POA poa, Servant servant,
+ boolean cleanup_in_progress, boolean remaining_activations
+ );
+
+ /**
+ * This method is invoked whenever the POA receives a request for an
+ * object that is not currently active, assuming the POA has the
+ * USE_SERVANT_MANAGER and RETAIN policies. The user-supplied servant
+ * manager is responsible for locating or creating an appropriate servant
+ * that corresponds to the ObjectId value. The subsequent requests with
+ * the same ObjectId value will be delivered directly to that servant
+ * without invoking the servant manager.
+ *
+ * @param Object_Id the ObjectId value associated with the incoming request.
+ * @param poa the POA in which the object is being activated.
+ *
+ * @return a servant that will be used to process the incoming request.
+ *
+ * @throws ForwardRequest if the activator decides to forward the request
+ * to another object. The exception contains the object that should
+ * handle this request. This object is usually remote, but can also
+ * be local. The throws exception will forward all subsequent requests
+ * till the new activation.
+ */
+ Servant incarnate(byte[] Object_Id, POA poa)
+ throws ForwardRequest;
+}
\ No newline at end of file
--- /dev/null
+/* ServantActivatorPOA.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., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 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.PortableServer;
+
+import gnu.CORBA.Poa.gnuServantObject;
+
+import org.omg.CORBA.NO_IMPLEMENT;
+import org.omg.CORBA.ORB;
+import org.omg.CORBA.SystemException;
+import org.omg.CORBA.portable.InputStream;
+import org.omg.CORBA.portable.InvokeHandler;
+import org.omg.CORBA.portable.OutputStream;
+import org.omg.CORBA.portable.ResponseHandler;
+
+/**
+ * <p>This ServantActivator stub is an optional base for the
+ * servant activators. This stub cannot serve remote invocations, as
+ * methods in {@link ServantActivatorOperations} take POA as one of parameters.
+ * Both JDK 1.5 API and OMG specifies that POA is a local object that must not
+ * be transferred to the remote invocation target.
+ * </p><p>
+ * You do not need to derive your servant activator from this stub,
+ * it is enough to implement the {@link ServantActivator} interface.
+ * But you may choose to do this if you need the functional
+ * {@link #_all_interfaces()} method or want to keep default behavior during
+ * the incarnation or etherialization.
+ * </p>
+ */
+public class ServantActivatorPOA
+ extends Servant
+ implements InvokeHandler, ServantActivatorOperations
+{
+ /**
+ * Used to access the outer class in the nested delegator class.
+ */
+ final ServantActivatorPOA THIS = this;
+
+ /**
+ * This class is used to support _this.
+ */
+ class delegator
+ extends gnuServantObject
+ implements ServantActivator
+ {
+ delegator(Servant s)
+ {
+ super(s, new byte[ 0 ], null, null);
+ }
+
+ public Servant incarnate(byte[] key, POA poa)
+ throws org.omg.PortableServer.ForwardRequest
+ {
+ return THIS.incarnate(key, poa);
+ }
+
+ public void etherealize(byte[] key, POA poa, Servant servant,
+ boolean cleanup, boolean remains
+ )
+ {
+ THIS.etherealize(key, poa, servant, cleanup, remains);
+ }
+ }
+
+ /**
+ * It is your responsibility to handle the incarnation event and
+ * supply the servant.
+ * The default method instructs POA that the servant cannot be
+ * provided by activator. The OBJ_ADAPTER exception will be
+ * thrown by POA, unless the servant is provided as one of the
+ * parameters in the activation method, or the default servant is set.
+ *
+ * @see ServantActivatorOperations#incarnate
+ *
+ * @specnote in GNU Classpath, returning null means that the
+ * activator does not supply the servant. The servant can still be supplied
+ * as one of parameters in some POA activation methods or as a default
+ * servant.
+ *
+ * @throws ForwardRequest
+ */
+ public Servant incarnate(byte[] Object_Id, POA poa)
+ throws ForwardRequest
+ {
+ return null;
+ }
+
+ /**
+ * It is your responsibility to handle the etherialization event.
+ * Override this method if using the class. The default method
+ * does nothing.
+ *
+ * @see ServantActivatorOperations#incarnate
+ */
+ public void etherealize(byte[] Object_Id, POA poa, Servant servant,
+ boolean cleanup, boolean remains
+ )
+ {
+ }
+
+ /**
+ * Our implementation will not call this method. After setting your
+ * manager to POA, it will call incarnate and etherialize directly.
+ */
+ public OutputStream _invoke(String method, InputStream input,
+ ResponseHandler handler
+ )
+ throws SystemException
+ {
+ throw new NO_IMPLEMENT();
+ }
+
+ /**
+ * Returns an array of interfaces, supported by the servant activator.
+ */
+ public String[] _all_interfaces(POA poa, byte[] Object_Id)
+ {
+ return new _ServantActivatorStub()._ids();
+ }
+
+ /**
+ * Return the complete instance of the servant activator, based on
+ * the current class (ServantActivatorPOA or derived).
+ */
+ public ServantActivator _this()
+ {
+ return new delegator(this);
+ }
+
+ /**
+ * Return the complete instance of the servant activator, based on
+ * the current class (ServantActivatorPOA or derived).
+ */
+ public ServantActivator _this(ORB orb)
+ {
+ return new delegator(this);
+ }
+}
\ No newline at end of file
--- /dev/null
+/* ServantLocator.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., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 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.PortableServer;
+
+import org.omg.CORBA.portable.IDLEntity;
+
+/**
+ * When the POA has the NON_RETAIN policy it uses servant managers that are
+ * ServantLoacators. The operations, that must be supported by these managers,
+ * are defined separately in {@link ServantLocatorOperations}.
+ *
+ * @author Audrius Meskauskas, Lithuania (AudriusA@Bioinformatics.org)
+ *
+ * @see ServantActivator
+ * @see ServantRetentionPolicyValue
+ * @see ServantManager
+ * @see POAOperations#set_servant_manager
+ */
+public interface ServantLocator
+ extends ServantManager, ServantLocatorOperations, IDLEntity,
+ org.omg.CORBA.Object
+{
+}
\ No newline at end of file
--- /dev/null
+/* ServantLocatorHelper.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., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 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.PortableServer;
+
+import org.omg.CORBA.Any;
+import org.omg.CORBA.BAD_OPERATION;
+import org.omg.CORBA.MARSHAL;
+import org.omg.CORBA.ORB;
+import org.omg.CORBA.TypeCode;
+import org.omg.CORBA.portable.InputStream;
+import org.omg.CORBA.portable.OutputStream;
+
+/**
+* The helper operations for the CORBA object {@link ServantLocator}.
+*
+* @author Audrius Meskauskas, Lithuania (AudriusA@Bioinformatics.org)
+*/
+public abstract class ServantLocatorHelper
+{
+ /**
+ * Get the type code of the {@link ServantLocator}.
+ */
+ public static TypeCode type()
+ {
+ return ORB.init().create_interface_tc(id(), "ServantLocator");
+ }
+
+ /**
+ * Insert the ServantLocator into the given Any.
+ *
+ * @param any the Any to insert into.
+ * @param that the ServantLocator to insert.
+ */
+ public static void insert(Any any, ServantLocator that)
+ {
+ any.insert_Object(that);
+ }
+
+ /**
+ * Extract the ServantLocator from given Any.
+ *
+ * @throws BAD_OPERATION if the passed Any does not contain ServantLocator.
+ */
+ public static ServantLocator extract(Any any)
+ {
+ return narrow(any.extract_Object());
+ }
+
+ /**
+ * Get the ServantLocator repository id.
+ *
+ * @return "org.omg.PortableServer.ServantLocatorOperations", always.
+ */
+ public static String id()
+ {
+ return "org.omg.PortableServer.ServantLocatorOperations";
+ }
+
+ /**
+ * Cast the passed object into the ServantLocator.
+ *
+ * @param obj the object to narrow.
+ * @return narrowed instance.
+ * @throws BAD_PARAM if the passed object is not a ServantLocator.
+ */
+ public static ServantLocator narrow(org.omg.CORBA.Object obj)
+ {
+ try
+ {
+ return (ServantLocator) obj;
+ }
+ catch (ClassCastException ex)
+ {
+ BAD_OPERATION bad = new BAD_OPERATION();
+ bad.initCause(ex);
+ throw bad;
+ }
+ }
+
+ /**
+ * This should read the servant locator, but it cannot be transferred
+ * this way as its operations cannot be remote. The operations cannot
+ * be remote because one of the method parameters, POA, is required to be
+ * always a local object (both by 1.5 API and 3.0.3 OMG).
+ *
+ * @throws MARSHAL, always.
+ *
+ * @specnote Same as Sun.
+ */
+ public static ServantLocator read(InputStream input)
+ {
+ throw new MARSHAL();
+ }
+
+ /**
+ * This should write the servant activator, but it cannot be transferred
+ * this way as its operations cannot be remote. The operations cannot
+ * be remote because one of the method parameters, POA, is required to be
+ * always a local object (both by 1.5 API and 3.0.3 OMG).
+ *
+ * @throws MARSHAL, always.
+ *
+ * @specnote Same as Sun.
+ */
+ public static void write(OutputStream output, ServantLocator value)
+ {
+ throw new MARSHAL();
+ }
+}
\ No newline at end of file
--- /dev/null
+/* ServantLocatorOperations.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., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 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.PortableServer;
+
+import org.omg.PortableServer.ServantLocatorPackage.CookieHolder;
+
+/**
+ * Defines the operations, applicable to the {@link ServantLocator}.
+ *
+ * @author Audrius Meskauskas, Lithuania (AudriusA@Bioinformatics.org)
+ */
+public interface ServantLocatorOperations
+ extends ServantManagerOperations
+{
+ /**
+ * If the POA has the USE_SERVANT_MANAGER and NON_RETAIN policies, it
+ * invokes this method whenever the object being requested that is not
+ * inactive. This method has access to all details of the received
+ * request and can use them to choose between servaral alternative servants.
+ * It can also forward the request to another server.
+ *
+ * @param Object_Id the id of the object, on which the request was called.
+ * @param poa the POA in those scope the object is active.
+ * @param operation the name of the method or operation being invoked.
+ * @param cookie_holder the holder where the servant manager can store
+ * an arbitrary java.lang.Object. This object will be later passed as a
+ * <code>cookie</code> parameter for {@link postinvoke}, to create tie
+ * between preinvoke and postinvoke. The application should <i>not</i>
+ * suppose that each call of preinvoke is followed by the subsequent
+ * postinvoke for the same invocation; under multi threaded policy these
+ * calls may be intermixed.
+ *
+ * @return a servant that will serve the incoming request.
+ *
+ * @throws ForwardRequest if the locator decides to forward the request
+ * to another object. The exception contains the object that should
+ * handle this request. This object is usually remote, but can also
+ * be local. As <code>preinvoke</code> is called on each method
+ * invocation, the thrown exception will forward only this current request.
+ */
+ Servant preinvoke(byte[] Object_Id, POA poa, String operation,
+ CookieHolder cookie_holder
+ )
+ throws ForwardRequest;
+
+ /**
+ * If the POA has the USE_SERVANT_MANAGER and NON_RETAIN policies, it
+ * invokes this method whenever a servant completes a request.
+ *
+ * @param Object_Id the id of the object, on which the request was called.
+ * @param poa the POA in those scope the object is active.
+ * @param operation the name of the method or operation that was invoked.
+ * @param cookie the object that has been previously set by preinvoke in
+ * the <code>cookie_holder</code> parameter.
+ * @param servant the servant, associated with the object.
+ */
+ void postinvoke(byte[] Object_Id, POA poa, String operation,
+ java.lang.Object cookie, Servant servant
+ );
+}
\ No newline at end of file
--- /dev/null
+/* ServantLocatorPOA.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., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 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.PortableServer;
+
+import gnu.CORBA.Poa.gnuServantObject;
+
+import org.omg.CORBA.NO_IMPLEMENT;
+import org.omg.CORBA.ORB;
+import org.omg.CORBA.SystemException;
+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.PortableServer.ServantLocatorPackage.CookieHolder;
+
+/**
+ * <p>The ServantLocator stub is an optional base for the
+ * servant locators. It cannot serve remote invocations, as
+ * methods in {@link ServantLocatorOperations} take POA as one of parameters.
+ * Both JDK 1.5 API and OMG specifies that POA is a local object that must not
+ * be transferred to the remote invocation target.
+ * </p><p>
+ * You do not need to derive your servant locator from this stub,
+ * it is enough to implement the {@link ServantLocator} interface.
+ * But you may choose to do this if you need its functional
+ * {@link #_ids()} method or want to keep default behavior during per-
+ * or post- invokcations.
+ * </p>
+ * @author Audrius Meskauskas, Lithuania (AudriusA@Bioinformatics.org)
+ */
+public class ServantLocatorPOA
+ extends Servant
+ implements ServantLocatorOperations, InvokeHandler
+{
+ /**
+ * Used to access the outer class in the nested classes.
+ */
+ final ServantLocatorPOA THIS = this;
+
+ /**
+ * It is your responsibility to take the preinvoke actions, if any,
+ * and also supply an appropriate servant for the current invocation.
+ *
+ * The default method instructs POA that the servant cannot be
+ * provided by locator. The OBJ_ADAPTER exception will be
+ * thrown by POA, unless it uses the available default servant for all
+ * invocations.
+ *
+ * @specnote in GNU Classpath, returning null means that the
+ * locator does not supply the servant.
+ *
+ * @see ServantLocatorOperations#preinvoke
+ */
+ public Servant preinvoke(byte[] Object_Id, POA poa, String method,
+ CookieHolder cookie_holder
+ )
+ throws org.omg.PortableServer.ForwardRequest
+ {
+ return null;
+ }
+
+ /**
+ * It is your responsibility to take the postinvoke actions, if any,
+ * by overriding this method. The default method does nothing.
+ *
+ * @see ServantLocatorOperations#postinvoke
+ */
+ public void postinvoke(byte[] Object_Id, POA poa, String method,
+ java.lang.Object cookie, Servant servant
+ )
+ {
+ }
+
+ /**
+ * Our implementation will not call this method. After setting your
+ * manager to POA, it will call incarnate and etherialize directly.
+ */
+ public OutputStream _invoke(String method, InputStream input,
+ ResponseHandler handler
+ )
+ throws SystemException
+ {
+ throw new NO_IMPLEMENT();
+ }
+
+ /**
+ * Returns an array of interfaces, supported by the servant locator.
+ */
+ public String[] _all_interfaces(POA poa, byte[] Object_Id)
+ {
+ return new _ServantLocatorStub()._ids();
+ }
+
+ /**
+ * Return the complete instance of the servant activator, based on
+ * the current class (ServantActivatorPOA or derived).
+ */
+ public ServantLocator _this()
+ {
+ return new delegator(this);
+ }
+
+ /**
+ * Return the complete instance of the servant activator, based on
+ * the current class (ServantActivatorPOA or derived).
+ */
+ public ServantLocator _this(ORB orb)
+ {
+ return new delegator(this);
+ }
+
+ /**
+ * This class is used to support _this.
+ */
+ class delegator
+ extends gnuServantObject
+ implements ServantLocator
+ {
+ delegator(Servant s)
+ {
+ super(s, new byte[ 0 ], null, null);
+ }
+
+ public Servant preinvoke(byte[] Object_Id, POA poa, String method,
+ CookieHolder cookie_holder
+ )
+ throws org.omg.PortableServer.ForwardRequest
+ {
+ return THIS.preinvoke(Object_Id, poa, method, cookie_holder);
+ }
+
+ public void postinvoke(byte[] Object_Id, POA poa, String method,
+ java.lang.Object cookie, Servant servant
+ )
+ {
+ THIS.postinvoke(Object_Id, poa, method, cookie, servant);
+ }
+
+ public String[] _ids()
+ {
+ return THIS._all_interfaces(null, null);
+ }
+ }
+}
\ No newline at end of file
--- /dev/null
+/* ServantManager.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., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 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.PortableServer;
+
+import org.omg.CORBA.portable.IDLEntity;
+
+/**
+ * A servant manager is associated with POA and provide possibility
+ * to activate objects on demand. A servant manager interface itself
+ * is empty, but it is inherited by other two interfaces,
+ * {@link ServantActivator} and {@link ServantLocator}.
+ *
+ * @see POAOperations#set_servant_manager
+ *
+ * @author Audrius Meskauskas, Lithuania (AudriusA@Bioinformatics.org)
+ */
+public interface ServantManager
+ extends ServantManagerOperations, IDLEntity, org.omg.CORBA.Object
+{
+}
\ No newline at end of file
--- /dev/null
+/* ServantManagerOperations.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., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 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.PortableServer;
+
+/**
+ * This interface would define the operations, applicable to
+ * the ServantManager. A servant manager interface itself
+ * is empty, but it is inherited by other two interfaces,
+ * {@link ServantActivator} and {@link ServantLocator}.
+ *
+ * @see ServantActivatorOperations
+ * @see ServantLocatorOperations
+ *
+ * @author Audrius Meskauskas, Lithuania (AudriusA@Bioinformatics.org)
+ */
+public interface ServantManagerOperations
+{
+}
\ No newline at end of file
--- /dev/null
+/* ServantRetentionPolicy.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., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 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.PortableServer;
+
+import org.omg.CORBA.Policy;
+import org.omg.CORBA.portable.IDLEntity;
+
+/**
+ * Specifies if the active servants should be retained in the
+ * Active Object Map.
+ *
+ * The policy can return its current value, as defined.
+ * in {@link ServantRetentionPolicyOperations}.
+ *
+ * @see ServantRetentionPolicyValue for the possible values of this policy.
+ *
+ * @author Audrius Meskauskas, Lithuania (AudriusA@Bioinformatics.org)
+ */
+public interface ServantRetentionPolicy
+ extends Policy, ServantRetentionPolicyOperations, IDLEntity
+{
+}
\ No newline at end of file
--- /dev/null
+/* ServantRetentionPolicyOperations.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., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 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.PortableServer;
+
+import org.omg.CORBA.PolicyOperations;
+
+/**
+ * Defines the operations, applicable to the ServantRetentionPolicy.
+ *
+ * @author Audrius Meskauskas, Lithuania (AudriusA@Bioinformatics.org)
+ */
+public interface ServantRetentionPolicyOperations
+ extends PolicyOperations
+{
+ /**
+ * Return the value of this policy type, stated by the current instance.
+ */
+ ServantRetentionPolicyValue value();
+}
\ No newline at end of file
--- /dev/null
+/* ThreadPolicy.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., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 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.PortableServer;
+
+import org.omg.CORBA.Policy;
+import org.omg.CORBA.portable.IDLEntity;
+
+/**
+ * Defines the POA thread policy.
+ *
+ * The policy can return its current value, as defined.
+ * in {@link ThreadPolicyOperations}.
+ *
+ * @see ThreadPolicyValue for the possible values of this policy.
+ *
+ * @author Audrius Meskauskas, Lithuania (AudriusA@Bioinformatics.org)
+ */
+public interface ThreadPolicy
+ extends Policy, ThreadPolicyOperations, IDLEntity
+{
+}
\ No newline at end of file
--- /dev/null
+/* ThreadPolicyOperations.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., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 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.PortableServer;
+
+import org.omg.CORBA.PolicyOperations;
+
+/**
+ * Defines the operations, applicable to the ThreadPolicy.
+ *
+ * @author Audrius Meskauskas, Lithuania (AudriusA@Bioinformatics.org)
+ */
+public interface ThreadPolicyOperations
+ extends PolicyOperations
+{
+ /**
+ * Return the value of this policy type, stated by the current instance.
+ */
+ ThreadPolicyValue value();
+}
\ No newline at end of file
--- /dev/null
+/* ThreadPolicyValue.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., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 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.PortableServer;
+
+import org.omg.CORBA.BAD_OPERATION;
+import org.omg.CORBA.portable.IDLEntity;
+
+import java.io.Serializable;
+
+/**
+ * Defines the possible values for the POA thread policy.
+ *
+ * This enumeration can obtain the following values:
+ * <ul>
+ * <li>ORB_CTRL_MODEL Each object in POA has a separate serving thread
+ * and a separate server socket, listening on the objects individual
+ * port. Additionally, when the request is accepted, it is also
+ * served in a separate thread, so several requests to the same
+ * object can be processed in parallel. The servant can always get
+ * the Id and POA of the object it is currently serving by
+ * invoking {@link Servant#_object_id()} and {@link Servant#_poa}.
+ * These two methods use thread to data map and must work correctly
+ * even then the servant code is executed in several parallel threads.
+ * </li>
+ * <li>SINGLE_THREAD_MODEL All objects in POA share the same server
+ * socket and are served in the same thread. This model is applicable
+ * when the number of objects is greater than the number of threads
+ * and (or) ports, supported by the system.</li>
+ * </ul>
+ * OMG also defines a MAIN_THREAD_MODEL, currently not supported by
+ * the java API.
+ *
+ * @author Audrius Meskauskas, Lithuania (AudriusA@Bioinformatics.org)
+ */
+public class ThreadPolicyValue
+ implements Serializable, IDLEntity
+{
+ /**
+ * Use serialVersionUID (v1.4) for interoperability.
+ */
+ private static final long serialVersionUID = -8874988828297141512L;
+
+ /**
+ * The value field for the current instance.
+ */
+ private final int _value;
+
+ /**
+ * The possible value of this enumeration (ORB_CTRL_MODEL).
+ */
+ public static final int _ORB_CTRL_MODEL = 0;
+
+ /**
+ * An instance of ThreadPolicyValue, initialized to ORB_CTRL_MODEL.
+ */
+ public static final ThreadPolicyValue ORB_CTRL_MODEL =
+ new ThreadPolicyValue(_ORB_CTRL_MODEL);
+
+ /**
+ * The possible value of this enumeration (SINGLE_THREAD_MODEL).
+ */
+ public static final int _SINGLE_THREAD_MODEL = 1;
+
+ /**
+ * An instance of ThreadPolicyValue, initialized to SINGLE_THREAD_MODEL.
+ */
+ public static final ThreadPolicyValue SINGLE_THREAD_MODEL =
+ new ThreadPolicyValue(_SINGLE_THREAD_MODEL);
+
+ /**
+ * The private array that maps integer codes to the enumeration
+ * values.
+ */
+ private static final ThreadPolicyValue[] enume =
+ new ThreadPolicyValue[] { ORB_CTRL_MODEL, SINGLE_THREAD_MODEL };
+
+ /**
+ * The private array of state names.
+ */
+ private static final String[] state_names =
+ new String[] { "ORB_CTRL_MODEL", "SINGLE_THREAD_MODEL" };
+
+ /**
+ * Normally, no new instances are required, so the constructor is protected.
+ */
+ protected ThreadPolicyValue(int a_value)
+ {
+ _value = a_value;
+ }
+
+ /**
+ * Returns the ThreadPolicyValue, matching the given integer constant.
+ *
+ * @param code one of _ORB_CTRL_MODEL, _SINGLE_THREAD_MODEL.
+ * @return one of ORB_CTRL_MODEL, SINGLE_THREAD_MODEL.
+ * @throws BAD_PARAM if the parameter is not one of the valid values.
+ */
+ public static ThreadPolicyValue from_int(int code)
+ {
+ try
+ {
+ return enume [ code ];
+ }
+ catch (ArrayIndexOutOfBoundsException ex)
+ {
+ throw new BAD_OPERATION("Invalid enumeration code " + code);
+ }
+ }
+
+ /**
+ * Returns a short string representation.
+ * @return the name of the current enumeration value.
+ */
+ public String toString()
+ {
+ return state_names [ _value ];
+ }
+
+ /**
+ * Returns the integer code of the enumeration value.
+ * @return one of ORB_CTRL_MODEL, SINGLE_THREAD_MODEL.
+ */
+ public int value()
+ {
+ return _value;
+ }
+}
\ No newline at end of file
--- /dev/null
+/* _ServantActivatorStub.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., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 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.PortableServer;
+
+import org.omg.CORBA.MARSHAL;
+import org.omg.CORBA.ORB;
+import org.omg.CORBA.ObjectHelper;
+import org.omg.CORBA.portable.ApplicationException;
+import org.omg.CORBA.portable.Delegate;
+import org.omg.CORBA.portable.InputStream;
+import org.omg.CORBA.portable.ObjectImpl;
+import org.omg.CORBA.portable.OutputStream;
+import org.omg.CORBA.portable.RemarshalException;
+
+import java.io.Serializable;
+
+/**
+ * <p>This ServantActivator stub is an optional base for the
+ * servant activators. This stub cannot accept remote invocations, as
+ * methods in {@link ServantActivatorOperations} take POA as one of parameters.
+ * Both JDK 1.5 API and OMG specifies that POA is a local object that must not
+ * be transferred to the remote invocation target.
+ * </p><p>
+ * You do not need to derive your servant activator from this stub,
+ * it is enough to implement the {@link ServantActivator} interface.
+ * But you may choose to do this if you need the functional
+ * {@link #_ids()} method or want to keep default behavior during
+ * the incarnation or etherialization.
+ * </p>
+ * @author Audrius Meskauskas, Lithuania (AudriusA@Bioinformatics.org)
+ */
+public class _ServantActivatorStub
+ extends ObjectImpl
+ implements ServantActivator, Serializable
+{
+ /**
+ * Use serialVersionUID (v1.4) for interoperability.
+ */
+ private static final long serialVersionUID = -685959979577281419L;
+
+ /**
+ * This the purpose of this field is undocumented up till 1.5 java API
+ * inclusive.
+ */
+ public static final Class _opsClass = ServantActivatorOperations.class;
+
+ /**
+ * Return the array of repository ids for this object.
+ *
+ * @return { "IDL:omg.org/PortableServer/ServantActivator:2.3",
+ * "IDL:omg.org/PortableServer/ServantManager:1.0" }, always.
+ */
+ public String[] _ids()
+ {
+ return new String[]
+ {
+ "IDL:omg.org/PortableServer/ServantActivator:2.3",
+ "IDL:omg.org/PortableServer/ServantManager:1.0"
+ };
+ }
+
+ /**
+ * It is your responsibility to handle the incarnation event and
+ * supply the servant. Override this method if using the class.
+ * The default method instructs POA that the servant cannot be
+ * provided by activator. The OBJ_ADAPTER exception will be
+ * thrown by POA, unless the servant is provided as one of the
+ * parameters in the activation method.
+ *
+ * @see ServantActivatorOperations#incarnate
+ *
+ * @specnote in GNU Classpath, returning null means that the
+ * activator does not supply the servant.
+ *
+ * @throws ForwardRequest
+ */
+ public Servant incarnate(byte[] Object_id, POA poa)
+ throws ForwardRequest
+ {
+ return null;
+ }
+
+ /**
+ * It is your responsibility to handle the etherialization event.
+ * Override this method if using the class. The default method
+ * does nothing.
+ *
+ * @see ServantActivatorOperations#incarnate
+ */
+ public void etherealize(byte[] Object_id, POA poa, Servant servant,
+ boolean cleanup, boolean remaining
+ )
+ {
+ }
+}
\ No newline at end of file
--- /dev/null
+/* _ServantLocatorStub.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., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 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.PortableServer;
+
+import org.omg.CORBA.portable.ObjectImpl;
+import org.omg.PortableServer.ServantLocatorPackage.CookieHolder;
+
+import java.io.Serializable;
+
+/**
+ * <p>The ServantLocator stub is an optional base for the
+ * servant locators. This stub cannot accept remote invocations, as
+ * methods in {@link ServantLocatorOperations} take POA as one of parameters.
+ * Both JDK 1.5 API and OMG specifies that POA is a local object that must not
+ * be transferred to the remote invocation target.
+ * </p><p>
+ * You do not need to derive your servant locator from this stub,
+ * it is enough to implement the {@link ServantLocator} interface.
+ * But you may choose to do this if you need its functional
+ * {@link #_ids()} method or want to keep default behavior during per-
+ * or post- invokcations.
+ * </p>
+ * @author Audrius Meskauskas, Lithuania (AudriusA@Bioinformatics.org)
+ */
+public class _ServantLocatorStub
+ extends ObjectImpl
+ implements ServantLocator, Serializable
+{
+ /**
+ * Use serialVersionUID (v1.4) for interoperability.
+ */
+ private static final long serialVersionUID = -2374963516905770111L;
+
+ /**
+ * This the purpose of this field is undocumented up till 1.5 java API
+ * inclusive.
+ */
+ public static final Class _opsClass = ServantLocatorOperations.class;
+
+ /**
+ * The package private string, used as a parameter for
+ * the throws NullPointerExceptions in both servant locator and activator
+ * stubs.
+ */
+ static final String OVERRIDE = "Override this method to get functionality.";
+
+ /**
+ * Return the array of repository ids for this object, stating that it is
+ * both Servant locator and Servant manager.
+ *
+ * @return { "IDL:omg.org/PortableServer/ServantLocator:1.0",
+ * "IDL:omg.org/PortableServer/ServantManager:1.0" }, always.
+ */
+ public String[] _ids()
+ {
+ return new String[]
+ {
+ "IDL:omg.org/PortableServer/ServantLocator:1.0",
+ "IDL:omg.org/PortableServer/ServantManager:1.0"
+ };
+ }
+
+ /**
+ * It is your responsibility to take the preinvoke actions, if any,
+ * and also supply an appropriate servant for the current invocation.
+ *
+ * The default method instructs POA that the servant cannot be
+ * provided by locator. The OBJ_ADAPTER exception will be
+ * thrown by POA, unless it uses the available default servant for all
+ * invocations.
+ *
+ * @specnote in GNU Classpath, returning null means that the
+ * locator does not supply the servant.
+ *
+ * @see ServantLocatorOperations#preinvoke
+ */
+ public Servant preinvoke(byte[] Object_id, POA poa, String method,
+ CookieHolder cookie
+ )
+ throws ForwardRequest
+ {
+ return null;
+ }
+
+ /**
+ * It is your responsibility to take the postinvoke actions, if any,
+ * by overriding this method. The default method does nothing.
+ *
+ * @see ServantLocatorOperations#postinvoke
+ */
+ public void postinvoke(byte[] Object_id, POA poa, String method,
+ Object cookie, Servant servant
+ )
+ {
+ }
+}
\ No newline at end of file
--- /dev/null
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
+<!-- package.html - describes classes in org.omg.PortableServer package
+ 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., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 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 - The Portable Object Adapter package</title></head>
+<body>
+<p>
+The Portable Object Adapter (POA) provides more control on the request
+processing than it is possible when connecting objects directly to the
+ORB. The POA model defines a tree structure of POAs, the root POA being
+connected directly to the ORB. Any branch of this tree can be temporary or
+permanently inactivated using {@link org.omg.PortableServer.POAManager}.
+The same manager can control several branches in the POA tree. Also,
+any branch in this tree can have different processing options (policies).
+</p><p>
+The newly created POA is in holding state, just queuing requests. To start
+processing requests, it must be turned into the active state by its
+{@link org.omg.PortableServer.POAManagerOperations#activate}.
+</p><p>
+The previously monolite object implementation is now divided into object
+(that implements {@link org.omg.CORBA.Object})
+and servant (that implements either {@link org.omg.CORBA.portable.InvokeHandler}
+or {@link org.omg.PortableServer.DynamicImplementation}).
+Frequently each object has its own servant, but it can also be a single servant
+per multiple objects and also default servant for POA
+(see {@link org.omg.PortableServer.POAOperations#set_servant}). Each object
+has its own Object Id, unique in the scope of the POA, where the object is
+connected. These Ids need not be different for objects belonging
+to different POAs, even if these POAs are connected to the same ORB.
+Under the USER_ID is assignment policy this Id can be a specified by user in
+{@link org.omg.PortableServer.POAOperations#activate_object_with_id},
+encapsulating some meaningful information about the object. The Id of the
+object being currently served can be identified with
+{@link org.omg.PortableServer.Servant#_object_id}. This approach is used in cases
+when it is possible to encapsulate all object-related data into the
+Object Id. Such system only needs one servant, one server socket and one
+socket port per POA that can handle thounsands of objects.
+</p><p>
+Instead of being connected directly to the ORB, objects are now connected
+to one of the ORBs POAs. Since JDK 1.4 the application specific implementation
+base is derived from the {@link org.omg.PortableServer.Servant}, having a
+different name pattern (<code>*POA.java</code> instead of the previous
+<code>_*ImplBase.java</code>). This <code>*POA</code> suffix does <i>not</i>
+mean that these servants implement or are derived from POA. They are different
+classes that can be connected to one of the POAs, by instance, using
+{@link org.omg.PortableServer.POAOperations#servant_to_reference}.
+The implementation base also inherits an *Operations interface, containing
+definitions of the application specific methods. The application programmer
+writes a descendent of the implementation base, implementing these methods
+for the application - specific functionality.
+</p><p>
+The POA objects support the method invocation by name, using
+{@link org.omg.CORBA.Request}. This alternative method works without the
+service-specific classes that may not be available at run time.
+</p><p>
+The objects in POA can also be activated and inactivated independently. It
+is possible to set a listener ({@link org.omg.PortableServer.ServantActivator})
+that would register the object activations ("incarnations") and deactivations
+("etherializations"). The servant need not be specifyed when creating an
+object. Under the IMPLICIT_ACTIVATION
+{@link org.omg.PortableServer.ImplicitActivationPolicy}
+the {@link org.omg.PortableServer.ServantActivator} can provide the servant
+in response to the first (local or remote) call of any method on the
+previously incative object.
+</p><p>
+The root POA is obtained by resolving the initial reference "RootPOA"
+for the orb. In the simpliest case the objects can be connected directly
+to that root POA without creating the POA tree. The policies, used by
+the root POA, are defined by OMG as following:
+<table border="1">
+<tr><th>Policy type</th><th>Accepted policy</th></tr>
+<tr><td>{@link org.omg.PortableServer.IdAssignmentPolicy} </td><td>SYSTEM_ID
+(Ids are created by POA)</td></tr>
+<tr><td>{@link org.omg.PortableServer.IdUniquenessPolicy}</td><td>UNIQUE_ID
+ (single object (and Id) per servant)
+</td></tr>
+<tr><td>{@link org.omg.PortableServer.ImplicitActivationPolicy} </td><td>
+IMPLICIT_ACTIVATION (if inactive, activate)</td></tr>
+<tr><td>{@link org.omg.PortableServer.LifespanPolicy} </td><td>TRANSIENT
+(the POA objects cannot outlive POA)</td></tr>
+<tr><td>{@link org.omg.PortableServer.RequestProcessingPolicy} </td><td>
+USE_ACTIVE_OBJECT_MAP_ONLY (the servant is provided during activation)</td></tr>
+<tr><td>{@link org.omg.PortableServer.ServantRetentionPolicy} </td><td>
+RETAIN (retain servants for subsequent invocations)</td></tr>
+<tr><td>{@link org.omg.PortableServer.ThreadPolicy} </td><td>ORB_CTRL_MODEL
+(single thread per request and single server socket per object)</td></tr>
+</table>
+These values are also default for the child POAs The policies are
+<i>never</i> inherited from the parent POA.
+</p><p>
+This set of policies means that each object will have a separate serving
+thread, separate network socket port and usually a separate servant. It
+is appropriate when the expected number of objects is not too large.
+If the expected number of objects is larger than the supportable number
+of threads and socket ports, the SINGLE_THREAD_MODEL
+{@link org.omg.PortableServer.ThreadPolicy} is
+used. Then all objects in POA with this policy are served in a single
+thread, using the same server socket, connected to a single port. If the
+request processing policy is additionally set to USE_DEFAULT_SERVANT,
+all objects of this POA share the same (default) servant.
+</p><p>
+The operations, supported by POA are defined
+separately in {@link org.omg.PortableServer.POAOperations}.
+</p><p>
+<h3>The typical POA usage scenarios</h3>
+<h4>POA converts servant to the object reference</h4>
+In the simpliest case, the servant implementation is connected to POA by
+{@link org.omg.PortableServer.POAOperations#servant_to_reference}, the
+returned object being a target of remote and local invocations.
+It may be converted into the stringified reference, registered with
+the naming service, used locally or, when serving or invoking local or remote
+method, passed as a parameter or return value having the CORBA Object type.
+The object obtains Id from POA and is activated due default implicit
+activation policy. This scenario is supported by the default policy set
+and is used in the most of the "hello world" examples.
+<h4>Servant provides to the object reference</h4>
+The servant can be connected to an ORB by
+{@link org.omg.PortableServer.Servant#_this_object(org.omg.CORBA.ORB)},
+obtaining the object reference. The overridable
+{@link org.omg.PortableServer.Servant#_default_POA()}
+specifies POA to that the servant will be connected. The default method
+connects to the root poa. IDL compilers frequently generate the
+<code>_this(ORB)</code> metod for servants for getting the object reference
+that is already narrowed to the exact object type.
+<h4>Explicit activation with POA assigned ids</h4>
+The objects are activated by calling the
+{@link org.omg.PortableServer.POAOperations#activate_object} on the
+POA with the object in question. The POA allocates, assigns, and
+returns a unique identity value for the object. This scenario requires the
+SYSTEM_ID {@link org.omg.PortableServer.IdAssignmentPolicy}.
+<h4>Explicit Activation with User-assigned Ids</h4>
+The POA supports an explicit activation operation,
+{@link org.omg.PortableServer.POAOperations#activate_object_with_id},
+that associates a servant with the user-defined Object Id.
+This scenario requires the USER_ID
+{@link org.omg.PortableServer.IdAssignmentPolicy}. The servant manager
+may be or may not be used.
+<h4>References before activation</h4>
+It may be useful to create references for objects before activating them.
+Such reference can be created using
+{@link org.omg.PortableServer.POAOperations#create_reference} or
+{@link org.omg.PortableServer.POAOperations#create_reference_with_id}, both
+methods also requiring to give the object repository id. Such object may
+be later activated either by
+{@link org.omg.PortableServer.POAOperations#activate_object_with_id} or
+automatically, if the IMPLICIT_ACTIVATION policy applies.
+<h4>Multiple Ids per servant</h4>
+If the MULTIPLE_ID policy applies, the servant may be activated many times.
+Under this policy,
+{@link org.omg.PortableServer.POAOperations#servant_to_reference}
+and {@link org.omg.PortableServer.POAOperations#servant_to_id}
+during each call create a new object and object reference for the
+used servant.
+<h4>One servant for all objects</h4>
+If the USE_DEFAULT_SERVANT policy applies, that default servant serves all
+objects, belonging this POA. This approach is used when there is
+very little data associated with each object, so little that the data can be
+encoded in the Object Id. Also, it may be needed when a very large
+number of objects is expected. If the RETAIN applies, it is possible to
+activate an object explicitly setting the servant other than default.
+If NO_RETAIN applies, the default servant will serve all known an
+unknown objects for that POA.
+<h4>Single Servant, Many Objects and Types</h4>
+Combining USER_ID, USE_DEFAULT_SERVANT and RETAIN, it is possible to
+create and serve objects "on the fly". The servant must determine the
+object type (for instance, from the value of the agreed attribute,
+shared by all supported types, or from the Object Id) and be able to
+handle the method, named in request. If the names and parameter lists
+of the object methods are also created "on the fly", the requests
+to such object can still be submitted using {@link org.omg.CORBA.Request}.
+This method is used when the created object represents some
+entity in the complex database.
+<h4>The ServantLocator finds a servant for each call</h4>
+The {@link org.omg.PortableServer.ServantLocator} is used by POAs that
+combinine NON_RETAIN and USE_SERVANT_MANAGER policies. It provides
+a new or reused servant every time the invocation is made. The servant
+locator must provide a servant in response of calling
+{@link org.omg.PortableServer.ServantLocatorOperations#preinvoke}.
+This method has access the the Id of the object being served and
+the name of the method being called. It must return the appropriate
+instance of the servant or throw an exception, forwarding the request
+to another object (usually in another server). After the invocation,
+a {@link org.omg.PortableServer.ServantLocatorOperations#postinvoke}
+is called. It should be not assumed that the call of <code>preinvoke</code>
+will be followed by the call of the <code>postinvoke</code>; in
+multithreaded environment these calls are not serialized in this way. If
+the <code>preinvoke</code> has to tell something this-call-specific to
+the <code>postinvoke</code>, it must use the provided cookie holder.
+The <code>preinvoke/postinoke</code> are also called to provide a servant
+during each local invocation on the objects, belonging to the described POA.
+</p><p>
+All these scenarios must work with the current GNU Classpath release.
+
+@author Audrius Meskauskas, Lithuania (AudriusA@Bioinformatics.org)
+</body>
+</html>
--- /dev/null
+/* DelegateOperations.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., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 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.PortableServer.portable;
+
+import org.omg.CORBA.ORB;
+import org.omg.PortableServer.POA;
+import org.omg.PortableServer.Servant;
+
+/**
+ * Each {@link Servant} has an associated delegate, where the most of the calls
+ * are forwarded. The delegate is responsible for providing the actual
+ * functionality. This class is required to supports a conceptions of
+ * the CORBA 2.3.1 Servant.
+ *
+ * @author Audrius Meskauskas, Lithuania (AudriusA@Bioinformatics.org)
+ */
+public interface Delegate
+{
+ /**
+ * Returns the root POA of the ORB instance, associated with this servant.
+ * It is the same POA that would be returned by resolving the initial
+ * reference "RootPOA" for that orb. The default {@link Servant#default_POA}
+ * method forwards call to the delegate can be overridden to
+ * obtain the alternative default POA.
+ *
+ * @see ORB.resolve_initial_references
+ */
+ POA default_POA(Servant a_servant);
+
+ /**
+ * Get the interface repository defintion
+ * <code>InterfaceDef</code> for this Object.
+ */
+ org.omg.CORBA.Object get_interface_def(Servant a_servant);
+
+ /**
+ * Checks if the passed servant is an instance of the given CORBA IDL type.
+ *
+ * @param a_servant a servant to check.
+ * @param an_id a repository ID, representing an IDL type for that the
+ * servant must be checked.
+ *
+ * @return true if the servant is an instance of the given type, false
+ * otherwise.
+ */
+ boolean is_a(Servant a_servant, String an_id);
+
+ /**
+ * Determines if the server object for this reference has already
+ * been destroyed.
+ *
+ * @return true if the object has been destroyed, false otherwise.
+ */
+ boolean non_existent(Servant a_servant);
+
+ /**
+ * Return the invocation target object identifier as a byte array.
+ */
+ byte[] object_id(Servant a_servant);
+
+ /**
+ * Returns the ORB that is directly associated with the given servant.
+ */
+ ORB orb(Servant a_servant);
+
+ /**
+ * Get POA that is directly associated with the given servant.
+ */
+ POA poa(Servant a_servant);
+
+ /**
+ * Obtains the CORBA object reference that is an invocation target for the
+ * given servant.
+ */
+ org.omg.CORBA.Object this_object(Servant a_servant);
+}
\ No newline at end of file
--- /dev/null
+/* VMFrame.java -- Reference implementation of VM hooks for JDWP Frame access.
+ Copyright (C) 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., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 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
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package gnu.classpath.jdwp;
+
+import gnu.classpath.jdwp.util.Location;
+
+/**
+ * Reference implementation of VM hooks for JDWP Frame access.
+ *
+ * @author aluchko
+ */
+
+public class VMFrame
+{
+ // The object this frame resides in
+ private Object obj;
+
+ // The current location of this frame
+ private Location loc;
+
+ // id of this frame
+ private long id;
+
+ /**
+ * Gets the current location of the frame.
+ */
+ public Location getLocation()
+ {
+ return loc;
+ }
+
+ /**
+ * Returns the value of the variable in the given slot.
+ *
+ * @param slot the slot containing the variable
+ */
+ public native Object getValue(int slot);
+
+ /**
+ * Assigns the given variable to the given value.
+ * @param slot The slot which contains the variable
+ * @param value The value to assign the variable to
+ */
+ public native void setValue(int slot, Object value);
+
+ /**
+ * Get the object which is represented by 'this' in the context of the frame,
+ * returns null if the method is native or static.
+ */
+ public Object getObject()
+ {
+ return obj;
+ }
+
+ /**
+ * Get the frameID
+ * @return an id which is unique within the scope of the VM
+ */
+ public long getId()
+ {
+ return id;
+ }
+
+}
--- /dev/null
+/* VMIdManager.java -- A reference/example implementation of a manager for
+ JDWP object/reference type IDs
+
+ Copyright (C) 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., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 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
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package gnu.classpath.jdwp;
+
+import gnu.classpath.jdwp.exception.InvalidClassException;
+import gnu.classpath.jdwp.exception.InvalidObjectException;
+import gnu.classpath.jdwp.id.*;
+
+import java.lang.ref.Reference;
+import java.lang.ref.ReferenceQueue;
+import java.lang.ref.SoftReference;
+import java.io.IOException;
+import java.nio.ByteBuffer;
+import java.util.HashMap;
+import java.util.Hashtable;
+import java.util.Iterator;
+
+/**
+ * This class manages objects and referencetypes that are reported
+ * to the debugger. All objects and referencetypes reported to the
+ * debugger should go through this manager.
+ *
+ * A brief summary of what an <code>IdManager</code> must provide:
+ *
+ * <code>
+ * public ObjectId getObjectId (Object theObject);
+ * public ObjectId get (long id);
+ * public ObjectId readObjectId (ByteBuffer bb);
+ * public ReferenceTypeId getReferenceTypeId (Class clazz);
+ * public ReferenceTypeId getReferenceType (long id);
+ * public ReferenceTypeId readReferenceTypeId (ByteBuffer bb);
+ * </code>
+ *
+ * See the javadoc on these methods later in this file for more
+ * information on these functions.
+ *
+ * <b>NOTE:</b> All IDs handled by the ID manager (all object and reference
+ * type IDs) are assumed to be of type <code>long</code>.
+ *
+ * @author Keith Seitz (keiths@redhat.com)
+ */
+public class VMIdManager
+{
+ // This factory generates ids for objects and types that may
+ // be sent to a debugger.
+ private static class IdFactory
+ {
+ // ID of last object / referencetype
+ private static Object _idLock = new Object ();
+ private static Object _ridLock = new Object ();
+ private static long _lastId = 0;
+ private static long _lastRid = 0;
+
+ // A list of all ID types
+ private static HashMap _idList = new HashMap ();
+
+ // Initialize the id list with known types
+ static
+ {
+ // ObjectId and ArrayId are special cases. See newObjectId.
+ _idList.put (ClassLoaderId.typeClass, ClassLoaderId.class);
+ _idList.put (ClassObjectId.typeClass, ClassObjectId.class);
+ //_idList.put (FieldId.typeClass, FieldId.class);
+ //_idList.put (FrameId.typeClass, FrameId.class);
+ //_idList.put (MethodId.typeClass, MethodId.class);
+ _idList.put (StringId.typeClass, StringId.class);
+ _idList.put (ThreadId.typeClass, ThreadId.class);
+ _idList.put (ThreadGroupId.typeClass, ThreadGroupId.class);
+ }
+
+ /**
+ * Returns a new id for the given object
+ *
+ * @param object the object for which an id is desired
+ * @returns a suitable object id
+ */
+ public static ObjectId newObjectId (SoftReference obj)
+ {
+ ObjectId id = null;
+ Object object = obj.get ();
+
+ // Special case: arrays
+ if (object.getClass ().isArray ())
+ id = new ArrayId ();
+ else
+ {
+ // Loop through all classes until we hit baseclass
+ Class myClass;
+ for (myClass = object.getClass (); myClass != null;
+ myClass = myClass.getSuperclass ())
+ {
+ Class clz = (Class) _idList.get (myClass);
+ if (clz != null)
+ {
+ try
+ {
+ id = (ObjectId) clz.newInstance ();
+ synchronized (_idLock)
+ {
+ id.setId (++_lastId);
+ }
+ return id;
+ }
+ catch (InstantiationException ie)
+ {
+ // This really should not happen
+ throw new RuntimeException ("cannot create new ID", ie);
+ }
+ catch (IllegalAccessException iae)
+ {
+ // This really should not happen
+ throw new RuntimeException ("illegal access of ID", iae);
+ }
+ }
+ }
+
+ /* getSuperclass returned null and no matching ID type found.
+ So it must derive from Object. */
+ id = new ObjectId ();
+ }
+
+ synchronized (_idLock)
+ {
+ id.setId (++_lastId);
+ }
+
+ return id;
+ }
+
+ /**
+ * Returns a new reference type id for the given class
+ *
+ * @param clazz the <code>Class</code> for which an id is desired
+ * @returns a suitable reference type id or null when the
+ * reference is cleared.
+ */
+ public static ReferenceTypeId newReferenceTypeId (SoftReference ref)
+ {
+ ReferenceTypeId id;
+ Class clazz = (Class) ref.get ();
+ if (clazz == null)
+ return null;
+
+ if (clazz.isArray ())
+ id = new ArrayReferenceTypeId ();
+ else if (clazz.isInterface ())
+ id = new InterfaceReferenceTypeId ();
+ else
+ id = new ClassReferenceTypeId ();
+ synchronized (_ridLock)
+ {
+ id.setId (++_lastRid);
+ }
+ return id;
+ }
+ }
+
+ /**
+ * This class is a SoftReferenceIdentity type that is used by
+ * the ID manager.
+ */
+ class ReferenceKey extends SoftReference
+ {
+ // Hash code of referent
+ private int _hash;
+
+ /**
+ * Constructs a new <code>ReferenceKey</code> object
+ * with the given referent.
+ *
+ * <p>This constructor should only be used for object lookups
+ * by the backend.
+ *
+ * @param referent the object to reference
+ */
+ public ReferenceKey (Object referent)
+ {
+ super (referent);
+ _hash = referent.hashCode ();
+ }
+
+ /**
+ * Constructs a new <code>ReferenceKey</code> object
+ * with the given referent and reference queue.
+ *
+ * <p>The JDWP back-end stores a <code>ReferenceKey</code>
+ * with its corresponding <code>JdwpId</code>. This constructor
+ * is used by the back-end when adding new IDs to be managed.
+ *
+ * @param referent the object to reference
+ * @param queue the queue to which to report garbage collections
+ */
+ public ReferenceKey (Object referent, ReferenceQueue queue)
+ {
+ super (referent, queue);
+ _hash = referent.hashCode ();
+ }
+
+ /**
+ * Returns the hash code of the referent.
+ * This seems hacky, but is required in order to use this class
+ * as a hash table key.
+ *
+ * @returns the hash code of the referent
+ */
+ public int hashCode ()
+ {
+ return _hash;
+ }
+
+ /**
+ * Comparator for keys
+ *
+ * This method can be used in two ways:
+ *
+ * <ol>
+ * <li>For table lookups, where we want to compare referents</li>
+ * <li>For clearing GCd objects, where we want to compare the actual
+ * key object (not the referent)</li>
+ * </ol>
+ */
+ public boolean equals (Object obj)
+ {
+ if (obj instanceof ReferenceKey)
+ {
+ ReferenceKey ref = (ReferenceKey) obj;
+
+ /* First check if the two references are the same.
+ If they are, that means we must be clearing GCd objects. */
+ if (this == obj)
+ return true;
+
+ return (ref.get () == get ());
+ }
+
+ return false;
+ }
+ }
+
+ // instance of VMIdManager
+ private static VMIdManager _idm = new VMIdManager ();
+
+ // A reference queue for our objects
+ private ReferenceQueue _refQueue;
+
+ // Mapping of objects (ReferenceKey) to IDs (ObjectId)
+ private Hashtable _oidTable;
+
+ // Mapping of ID numbers (Long) to IDs (ObjectId)
+ private Hashtable _idTable;
+
+ /* Mapping of class (ReferenceKey) to IDs (ReferenceTypeId) for reference
+ types. Unlike other types, reference id types are NEVER released. */
+ private Hashtable _classTable;
+
+ // Mapping of ID numbers (Long) to reference type IDs (ReferenceTypeId)
+ private Hashtable _ridTable;
+
+ /**
+ * Gets the instance of VMIdManager, constructing a new one
+ * if none currently exists.
+ */
+ public static VMIdManager getDefault ()
+ {
+ return _idm;
+ }
+
+ // Constructs a new <code>IdManager</code>
+ private VMIdManager ()
+ {
+ _refQueue = new ReferenceQueue ();
+ _oidTable = new Hashtable (50);
+ _idTable = new Hashtable (50);
+ _classTable = new Hashtable (20);
+ _ridTable = new Hashtable (20);
+ }
+
+ // Updates the object ID table, removing IDs whose objects have
+ // been garbage collected.
+ private void _update ()
+ {
+ Reference ref;
+ while ((ref = _refQueue.poll ()) != null)
+ {
+ ObjectId id = (ObjectId) _oidTable.get (ref);
+ _oidTable.remove (ref);
+ _idTable.remove (new Long (id.getId ()));
+ }
+ }
+
+ /**
+ * Returns an id for the given object, adding it
+ * if it does not have an id.
+ *
+ * @param theObject the object to get an ID/add
+ * @returns the ID of the object
+ */
+ public ObjectId getObjectId (Object theObject)
+ {
+ ReferenceKey ref = new ReferenceKey (theObject, _refQueue);
+ ObjectId id = (ObjectId) _oidTable.get (ref);
+ if (id == null)
+ {
+ // update the tables -- this is an arbitrary place to put this
+ _update ();
+
+ // Object not found. Make new id for it
+ id = IdFactory.newObjectId (ref);
+ _oidTable.put (ref, id);
+ _idTable.put (new Long (id.getId ()), id);
+ }
+
+ return id;
+ }
+
+ /**
+ * Returns the <code>JdwpId</code> for a given ID. Unlike
+ * <code>getId</code>, it throws an exception if the ID is not
+ * known.
+ *
+ * @param id the numerical ID of the desired <code>JdwpId</code>
+ * @throws InvalidObjectException if the ID is not found
+ */
+ public ObjectId get (long id)
+ throws InvalidObjectException
+ {
+ ObjectId oid = (ObjectId) _idTable.get (new Long (id));
+ if (oid == null)
+ throw new InvalidObjectException (id);
+
+ return oid;
+ }
+
+ public ObjectId readObjectId (ByteBuffer bb)
+ throws InvalidObjectException
+ {
+ long id = bb.getLong ();
+ return get (id);
+ }
+
+ /**
+ * Gets the reference type id for the given class, creating
+ * a new one if it does not already have an id
+ *
+ * @param clazz the class for which to get an ID
+ * @returns the ID of the class
+ */
+ public ReferenceTypeId getReferenceTypeId (Class clazz)
+ {
+ ReferenceKey ref = new ReferenceKey (clazz);
+ ReferenceTypeId id = (ReferenceTypeId)_classTable.get (ref);
+ if (id == null)
+ {
+ // Object not found. Make new id for it
+ id = IdFactory.newReferenceTypeId (ref);
+ _classTable.put (ref, id);
+ _ridTable.put (new Long (id.getId ()), id);
+ }
+
+ return id;
+ }
+
+ /**
+ * Returns the <code>ReferenceTypeId</code> for a given ID. Unlike
+ * <code>getReferenceTypeId</code>, it throws an exception if the ID is not
+ * known.
+ *
+ * @param id the numerical ID of the desired reference type
+ * @throws InvalidClassException if the ID is not found
+ */
+ public ReferenceTypeId getReferenceType (long id)
+ throws InvalidClassException
+ {
+ ReferenceTypeId rid = (ReferenceTypeId) _ridTable.get (new Long (id));
+ if (rid == null)
+ throw new InvalidClassException (id);
+
+ return rid;
+ }
+
+ public ReferenceTypeId readReferenceTypeId (ByteBuffer bb)
+ throws InvalidClassException
+ {
+ long id = bb.getLong ();
+ return getReferenceType (id);
+ }
+}
--- /dev/null
+/* VMVirtualMachine.java -- A reference implementation of a JDWP virtual
+ machine
+
+ Copyright (C) 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., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 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
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package gnu.classpath.jdwp;
+
+import gnu.classpath.jdwp.event.EventRequest;
+import gnu.classpath.jdwp.exception.InvalidClassException;
+import gnu.classpath.jdwp.exception.InvalidObjectException;
+import gnu.classpath.jdwp.id.ObjectId;
+import gnu.classpath.jdwp.id.ReferenceTypeId;
+import gnu.classpath.jdwp.util.LineTable;
+import gnu.classpath.jdwp.util.MethodResult;
+import gnu.classpath.jdwp.util.VariableTable;
+
+import java.io.IOException;
+import java.lang.reflect.Method;
+import java.nio.ByteBuffer;
+import java.util.ArrayList;
+import java.util.Iterator;
+
+/**
+ * A virtual machine according to JDWP.
+ *
+ * @author Keith Seitz <keiths@redhat.com>
+ */
+public class VMVirtualMachine
+{
+ /**
+ * Suspend a thread
+ *
+ * @param thread the thread to suspend
+ */
+ public static native void suspendThread (Thread thread);
+
+ /**
+ * Suspend all threads
+ */
+ public static void suspendAllThreads ()
+ {
+ // Our JDWP thread group -- don't suspend any of those threads
+ Thread current = Thread.currentThread ();
+ ThreadGroup jdwpGroup = current.getThreadGroup ();
+
+ // Find the root ThreadGroup
+ ThreadGroup group = jdwpGroup;
+ ThreadGroup parent = group.getParent ();
+ while (parent != null)
+ {
+ group = parent;
+ parent = group.getParent ();
+ }
+
+ // Get all the threads in the system
+ int num = group.activeCount ();
+ Thread[] threads = new Thread[num];
+ group.enumerate (threads);
+
+ for (int i = 0; i < num; ++i)
+ {
+ Thread t = threads[i];
+ if (t != null)
+ {
+ if (t.getThreadGroup () == jdwpGroup || t == current)
+ {
+ // Don't suspend the current thread or any JDWP thread
+ continue;
+ }
+ else
+ suspendThread (t);
+ }
+ }
+
+ // Now suspend the current thread
+ suspendThread (current);
+ }
+
+ /**
+ * Resume a thread. A thread must be resumed as many times
+ * as it has been suspended.
+ *
+ * @param thread the thread to resume
+ */
+ public static native void resumeThread (Thread thread);
+
+ /**
+ * Resume all threads. This simply decrements the thread's
+ * suspend count. It can not be used to force the application
+ * to run.
+ */
+ public static void resumeAllThreads ()
+ {
+ // Our JDWP thread group -- don't resume
+ Thread current = Thread.currentThread ();
+ ThreadGroup jdwpGroup = current.getThreadGroup ();
+
+ // Find the root ThreadGroup
+ ThreadGroup group = jdwpGroup;
+ ThreadGroup parent = group.getParent ();
+ while (parent != null)
+ {
+ group = parent;
+ parent = group.getParent ();
+ }
+
+ // Get all the threads in the system
+ int num = group.activeCount ();
+ Thread[] threads = new Thread[num];
+ group.enumerate (threads);
+
+ for (int i = 0; i < num; ++i)
+ {
+ Thread t = threads[i];
+ if (t != null)
+ {
+ if (t.getThreadGroup () == jdwpGroup || t == current)
+ {
+ // Don't resume the current thread or any JDWP thread
+ continue;
+ }
+ else
+ resumeThread (t);
+ }
+ }
+ }
+
+ /**
+ * Get the suspend count for a give thread
+ *
+ * @param thread the thread whose suspend count is desired
+ * @return the number of times the thread has been suspended
+ */
+ public static native int getSuspendCount (Thread thread);
+
+ /**
+ * Returns a count of the number of loaded classes in the VM
+ */
+ public static native int getAllLoadedClassesCount ();
+
+ /**
+ * Returns an iterator over all the loaded classes in the VM
+ */
+ public static native Iterator getAllLoadedClasses ();
+
+ /**
+ * Returns the status of the given class
+ *
+ * @param clazz the class whose status is desired
+ * @return a flag containing the class's status
+ * @see JdwpConstants.ClassStatus
+ */
+ public static native int getClassStatus (Class clazz);
+
+
+ /**
+ * Returns the thread's call stack
+ *
+ * @param thread thread for which to get call stack
+ * @param start index of first frame to return
+ * @param length number of frames to return (-1 for all frames)
+ * @return a list of frames
+ */
+ public static native ArrayList getFrames (Thread thread, int strart,
+ int length);
+
+ /**
+ * Returns the frame for a given thread with the frame ID in
+ * the buffer
+ *
+ * I don't like this.
+ *
+ * @param thread the frame's thread
+ * @param bb buffer containing the frame's ID
+ * @return the desired frame
+ */
+ public static native VMFrame getFrame (Thread thread, ByteBuffer bb);
+
+ /**
+ * Returns the number of frames in the thread's stack
+ *
+ * @param thread the thread for which to get a frame count
+ * @return the number of frames in the thread's stack
+ */
+ public static native int getFrameCount (Thread thread);
+
+
+ /**
+ * Returns the status of a thread
+ *
+ * @param thread the thread for which to get status
+ * @return integer status of the thread
+ * @see JdwpConstants.ThreadStatus
+ */
+ public static native int getThreadStatus (Thread thread);
+
+ /**
+ * Returns a list of all classes which this class loader has been
+ * requested to load
+ *
+ * @param cl the class loader
+ * @return a list of all visible classes
+ */
+ public static native ArrayList getLoadRequests (ClassLoader cl);
+
+ /**
+ * Executes a method in the virtual machine
+ *
+ * @param obj instance in which to invoke method (null for static)
+ * @param thread the thread in which to invoke the method
+ * @param clazz the class in which the method is defined
+ * @param method the method to invoke
+ * @param values arguments to pass to method
+ * @param nonVirtual "otherwise, normal virtual invoke
+ * (instance methods only) "
+ * @return a result object containing the results of the invocation
+ */
+ public static native MethodResult executeMethod (Object obj, Thread thread,
+ Class clazz, Method method,
+ Object[] values,
+ boolean nonVirtual);
+
+ /**
+ * "Returns variable information for the method. The variable table
+ * includes arguments and locals declared within the method. For instance
+ * methods, the "this" reference is included in the table. Also, synthetic
+ * variables may be present."
+ *
+ * @param clazz the class in which the method is defined
+ * @param method the method for which variable information is desired
+ * @return a result object containing the information
+ */
+ public static native VariableTable getVarTable (Class clazz, Method method);
+
+ /**
+ * "Returns line number information for the method, if present. The line
+ * table maps source line numbers to the initial code index of the line.
+ * The line table is ordered by code index (from lowest to highest). The
+ * line number information is constant unless a new class definition is
+ * installed using RedefineClasses."
+ *
+ * @param clazz the class in which the method is defined
+ * @param method the method whose line table is desired
+ * @return a result object containing the line table
+ */
+ public static native LineTable getLineTable (Class clazz, Method method);
+
+ /**
+ * "Returns the name of source file in which a reference type was declared"
+ *
+ * @param clazz the class for which to return a source file
+ * @return a string containing the source file name; "no path information
+ * for the file is included"
+ */
+ public static native String getSourceFile (Class clazz);
+
+ /**
+ * Register a request from the debugger
+ *
+ * Virtual machines have two options. Either do nothing and allow
+ * the event manager to take care of the request (useful for broadcast-type
+ * events like class prepare/load/unload, thread start/end, etc.)
+ * or do some internal work to set up the event notification (useful for
+ * execution-related events like breakpoints, single-stepping, etc.).
+ */
+ public static native void registerEvent (EventRequest request);
+
+ /**
+ * Unregisters the given request
+ *
+ * @param request the request to unregister
+ */
+ public static native void unregisterEvent (EventRequest request);
+
+
+ /**
+ * Clear all events of the given kind
+ *
+ * @param kind the type of events to clear
+ */
+ public static native void clearEvents (byte kind);
+}
--- /dev/null
+/* VMProxy.java -- VM interface for proxy class
+ 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., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 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 java.lang.reflect;
+
+final class VMProxy
+{
+ /**
+ * Set to true if the VM provides a native method to implement
+ * Proxy.getProxyClass completely, including argument verification.
+ * If this is true, HAVE_NATIVE_GET_PROXY_DATA and
+ * HAVE_NATIVE_GENERATE_PROXY_CLASS should be false.
+ * @see java.lang.reflect.Proxy
+ */
+ static boolean HAVE_NATIVE_GET_PROXY_CLASS = false;
+
+ /**
+ * Set to true if the VM provides a native method to implement
+ * the first part of Proxy.getProxyClass: generation of the array
+ * of methods to convert, and verification of the arguments.
+ * If this is true, HAVE_NATIVE_GET_PROXY_CLASS should be false.
+ * @see java.lang.reflect.Proxy
+ */
+ static boolean HAVE_NATIVE_GET_PROXY_DATA = false;
+
+ /**
+ * Set to true if the VM provides a native method to implement
+ * the second part of Proxy.getProxyClass: conversion of an array of
+ * methods into an actual proxy class.
+ * If this is true, HAVE_NATIVE_GET_PROXY_CLASS should be false.
+ * @see java.lang.reflect.Proxy
+ */
+ static boolean HAVE_NATIVE_GENERATE_PROXY_CLASS = false;
+
+ /**
+ * Optional native method to replace (and speed up) the pure Java
+ * implementation of getProxyClass. Only needed if
+ * VMProxy.HAVE_NATIVE_GET_PROXY_CLASS is true, this does the
+ * work of both getProxyData and generateProxyClass with no
+ * intermediate form in Java. The native code may safely assume that
+ * this class must be created, and does not already exist.
+ *
+ * @param loader the class loader to define the proxy class in; null
+ * implies the bootstrap class loader
+ * @param interfaces the interfaces the class will extend
+ * @return the generated proxy class
+ * @throws IllegalArgumentException if the constraints for getProxyClass
+ * were violated, except for problems with null
+ * @throws NullPointerException if `interfaces' is null or contains
+ * a null entry, or if handler is null
+ * @see Configuration#HAVE_NATIVE_GET_PROXY_CLASS
+ * @see #getProxyClass(ClassLoader, Class[])
+ * @see #getProxyData(ClassLoader, Class[])
+ * @see #generateProxyClass(ProxyData)
+ */
+ static native Class getProxyClass(ClassLoader loader, Class[] interfaces);
+
+ /**
+ * Optional native method to replace (and speed up) the pure Java
+ * implementation of getProxyData. Only needed if
+ * Configuration.HAVE_NATIVE_GET_PROXY_DATA is true. The native code
+ * may safely assume that a new ProxyData object must be created which
+ * does not duplicate any existing ones.
+ *
+ * @param loader the class loader to define the proxy class in; null
+ * implies the bootstrap class loader
+ * @param interfaces the interfaces the class will extend
+ * @return all data that is required to make this proxy class
+ * @throws IllegalArgumentException if the constraints for getProxyClass
+ * were violated, except for problems with null
+ * @throws NullPointerException if `interfaces' is null or contains
+ * a null entry, or if handler is null
+ * @see Configuration.HAVE_NATIVE_GET_PROXY_DATA
+ * @see #getProxyClass(ClassLoader, Class[])
+ * @see #getProxyClass(ClassLoader, Class[])
+ * @see ProxyType#getProxyData()
+ */
+ static native Proxy.ProxyData getProxyData(ClassLoader loader,
+ Class[] interfaces);
+
+ /**
+ * Optional native method to replace (and speed up) the pure Java
+ * implementation of generateProxyClass. Only needed if
+ * Configuration.HAVE_NATIVE_GENERATE_PROXY_CLASS is true. The native
+ * code may safely assume that a new Class must be created, and that
+ * the ProxyData object does not describe any existing class.
+ *
+ * @param loader the class loader to define the proxy class in; null
+ * implies the bootstrap class loader
+ * @param data the struct of information to convert to a Class. This
+ * has already been verified for all problems except exceeding
+ * VM limitations
+ * @return the newly generated class
+ * @throws IllegalArgumentException if VM limitations are exceeded
+ * @see #getProxyClass(ClassLoader, Class[])
+ * @see #getProxyClass(ClassLoader, Class[])
+ * @see ProxyData#generateProxyClass(ClassLoader)
+ */
+ static native Class generateProxyClass(ClassLoader loader,
+ Proxy.ProxyData data);
+}
--- /dev/null
+gnu/classpath/jdwp