summaryrefslogtreecommitdiff
path: root/libjava/classpath/gnu/java/beans
diff options
context:
space:
mode:
authortromey <tromey@138bc75d-0d04-0410-961f-82ee72b054a4>2005-07-16 00:30:23 +0000
committertromey <tromey@138bc75d-0d04-0410-961f-82ee72b054a4>2005-07-16 00:30:23 +0000
commitc8875fb97fc03779a5bba09872227b1d08e5d52a (patch)
treea0b991cf5866ae1d616639b906ac001811d74508 /libjava/classpath/gnu/java/beans
parentc40c1730800ed292b6db39a83d592476fa59623c (diff)
downloadgcc-c8875fb97fc03779a5bba09872227b1d08e5d52a.tar.gz
Initial revision
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@102074 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'libjava/classpath/gnu/java/beans')
-rw-r--r--libjava/classpath/gnu/java/beans/BeanInfoEmbryo.java171
-rw-r--r--libjava/classpath/gnu/java/beans/DummyAppletContext.java200
-rw-r--r--libjava/classpath/gnu/java/beans/DummyAppletStub.java115
-rw-r--r--libjava/classpath/gnu/java/beans/ExplicitBeanInfo.java149
-rw-r--r--libjava/classpath/gnu/java/beans/IntrospectionIncubator.java441
-rw-r--r--libjava/classpath/gnu/java/beans/TODO1
-rw-r--r--libjava/classpath/gnu/java/beans/decoder/AbstractContext.java70
-rw-r--r--libjava/classpath/gnu/java/beans/decoder/AbstractCreatableObjectContext.java113
-rw-r--r--libjava/classpath/gnu/java/beans/decoder/AbstractElementHandler.java316
-rw-r--r--libjava/classpath/gnu/java/beans/decoder/AbstractObjectContext.java127
-rw-r--r--libjava/classpath/gnu/java/beans/decoder/ArrayContext.java122
-rw-r--r--libjava/classpath/gnu/java/beans/decoder/ArrayHandler.java118
-rw-r--r--libjava/classpath/gnu/java/beans/decoder/AssemblyException.java57
-rw-r--r--libjava/classpath/gnu/java/beans/decoder/BooleanHandler.java67
-rw-r--r--libjava/classpath/gnu/java/beans/decoder/ByteHandler.java59
-rw-r--r--libjava/classpath/gnu/java/beans/decoder/CharHandler.java62
-rw-r--r--libjava/classpath/gnu/java/beans/decoder/ClassHandler.java66
-rw-r--r--libjava/classpath/gnu/java/beans/decoder/ConstructorContext.java102
-rw-r--r--libjava/classpath/gnu/java/beans/decoder/Context.java137
-rw-r--r--libjava/classpath/gnu/java/beans/decoder/DecoderContext.java124
-rw-r--r--libjava/classpath/gnu/java/beans/decoder/DefaultExceptionListener.java57
-rw-r--r--libjava/classpath/gnu/java/beans/decoder/DoubleHandler.java59
-rw-r--r--libjava/classpath/gnu/java/beans/decoder/DummyContext.java116
-rw-r--r--libjava/classpath/gnu/java/beans/decoder/DummyHandler.java156
-rw-r--r--libjava/classpath/gnu/java/beans/decoder/ElementHandler.java130
-rw-r--r--libjava/classpath/gnu/java/beans/decoder/FloatHandler.java59
-rw-r--r--libjava/classpath/gnu/java/beans/decoder/GrowableArrayContext.java138
-rw-r--r--libjava/classpath/gnu/java/beans/decoder/IndexContext.java130
-rw-r--r--libjava/classpath/gnu/java/beans/decoder/IntHandler.java59
-rw-r--r--libjava/classpath/gnu/java/beans/decoder/JavaHandler.java93
-rw-r--r--libjava/classpath/gnu/java/beans/decoder/LongHandler.java59
-rw-r--r--libjava/classpath/gnu/java/beans/decoder/MethodContext.java107
-rw-r--r--libjava/classpath/gnu/java/beans/decoder/MethodFinder.java177
-rw-r--r--libjava/classpath/gnu/java/beans/decoder/NullHandler.java62
-rw-r--r--libjava/classpath/gnu/java/beans/decoder/ObjectContext.java100
-rw-r--r--libjava/classpath/gnu/java/beans/decoder/ObjectHandler.java169
-rw-r--r--libjava/classpath/gnu/java/beans/decoder/PersistenceParser.java485
-rw-r--r--libjava/classpath/gnu/java/beans/decoder/PropertyContext.java137
-rw-r--r--libjava/classpath/gnu/java/beans/decoder/ShortHandler.java58
-rw-r--r--libjava/classpath/gnu/java/beans/decoder/SimpleHandler.java111
-rw-r--r--libjava/classpath/gnu/java/beans/decoder/StaticMethodContext.java95
-rw-r--r--libjava/classpath/gnu/java/beans/decoder/StringHandler.java54
-rw-r--r--libjava/classpath/gnu/java/beans/decoder/VoidHandler.java140
-rw-r--r--libjava/classpath/gnu/java/beans/decoder/package.html46
-rw-r--r--libjava/classpath/gnu/java/beans/editors/ColorEditor.java100
-rw-r--r--libjava/classpath/gnu/java/beans/editors/FontEditor.java77
-rw-r--r--libjava/classpath/gnu/java/beans/editors/NativeBooleanEditor.java76
-rw-r--r--libjava/classpath/gnu/java/beans/editors/NativeByteEditor.java61
-rw-r--r--libjava/classpath/gnu/java/beans/editors/NativeDoubleEditor.java61
-rw-r--r--libjava/classpath/gnu/java/beans/editors/NativeFloatEditor.java61
-rw-r--r--libjava/classpath/gnu/java/beans/editors/NativeIntEditor.java61
-rw-r--r--libjava/classpath/gnu/java/beans/editors/NativeLongEditor.java61
-rw-r--r--libjava/classpath/gnu/java/beans/editors/NativeShortEditor.java61
-rw-r--r--libjava/classpath/gnu/java/beans/editors/StringEditor.java61
-rw-r--r--libjava/classpath/gnu/java/beans/editors/TODO4
-rw-r--r--libjava/classpath/gnu/java/beans/editors/package.html46
-rw-r--r--libjava/classpath/gnu/java/beans/package.html46
57 files changed, 6190 insertions, 0 deletions
diff --git a/libjava/classpath/gnu/java/beans/BeanInfoEmbryo.java b/libjava/classpath/gnu/java/beans/BeanInfoEmbryo.java
new file mode 100644
index 00000000000..0cf73e5b9ae
--- /dev/null
+++ b/libjava/classpath/gnu/java/beans/BeanInfoEmbryo.java
@@ -0,0 +1,171 @@
+/* gnu.java.beans.BeanInfoEmbryo
+ Copyright (C) 1998, 2002 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, 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.beans;
+
+import java.beans.BeanDescriptor;
+import java.beans.BeanInfo;
+import java.beans.EventSetDescriptor;
+import java.beans.IndexedPropertyDescriptor;
+import java.beans.MethodDescriptor;
+import java.beans.PropertyDescriptor;
+import java.lang.reflect.Method;
+import java.util.Arrays;
+import java.util.Enumeration;
+import java.util.Hashtable;
+import java.util.Iterator;
+import java.util.Map;
+import java.util.TreeMap;
+import java.util.Vector;
+
+/**
+ ** A BeanInfoEmbryo accumulates information about a Bean
+ ** while it is in the process of being created, and then
+ ** when you are done accumulating the information, the
+ ** getBeanInfo() method may be called to create a BeanInfo
+ ** object based on the information.<P>
+ **
+ ** This class is not well-synchronized. (It can be, it
+ ** just isn't yet.)
+ **
+ ** @author John Keiser
+ ** @version 1.1.0, 30 Jul 1998
+ ** @see java.beans.BeanInfo
+ **/
+
+public class BeanInfoEmbryo {
+
+ // by using a TreeMap the properties will be sorted alphabetically by name
+ // which matches the (undocumented) behavior of jdk
+ TreeMap properties = new TreeMap();
+ Hashtable events = new Hashtable();
+ Vector methods = new Vector();
+
+ BeanDescriptor beanDescriptor;
+ BeanInfo[] additionalBeanInfo;
+ java.awt.Image[] im;
+ String defaultPropertyName;
+ String defaultEventName;
+
+ public BeanInfoEmbryo() {
+ }
+
+ public BeanInfo getBeanInfo() {
+ int defaultProperty = -1;
+ int defaultEvent = -1;
+
+ PropertyDescriptor[] Aproperties = new PropertyDescriptor[properties.size()];
+ int i = 0;
+ Iterator it = properties.entrySet().iterator();
+ while (it.hasNext()) {
+ Aproperties[i] = (PropertyDescriptor) (((Map.Entry)it.next()).getValue());
+ if(defaultPropertyName != null && Aproperties[i].getName().equals(defaultPropertyName)) {
+ defaultProperty = i;
+ }
+ i++;
+ }
+
+ EventSetDescriptor[] Aevents = new EventSetDescriptor[events.size()];
+ i = 0;
+ Enumeration e = events.elements();
+ while (e.hasMoreElements()) {
+ Aevents[i] = (EventSetDescriptor) e.nextElement();
+ if(defaultEventName != null && Aevents[i].getName().equals(defaultEventName)) {
+ defaultEvent = i;
+ }
+ i++;
+ }
+
+ MethodDescriptor[] Amethods = new MethodDescriptor[methods.size()];
+ methods.copyInto(Amethods);
+
+ return new ExplicitBeanInfo(beanDescriptor,additionalBeanInfo,Aproperties,defaultProperty,Aevents,defaultEvent,Amethods,im);
+ }
+
+ public void setBeanDescriptor(BeanDescriptor b) {
+ beanDescriptor = b;
+ }
+
+ public void setAdditionalBeanInfo(BeanInfo[] b) {
+ additionalBeanInfo = b;
+ }
+
+ public boolean hasProperty(PropertyDescriptor p) {
+ return properties.get(p.getName()) != null;
+ }
+ public void addProperty(PropertyDescriptor p) {
+ properties.put(p.getName(),p);
+ }
+ public void addIndexedProperty(IndexedPropertyDescriptor p) {
+ properties.put(p.getName(),p);
+ }
+
+ public boolean hasEvent(EventSetDescriptor e) {
+ return events.get(e.getName()) != null;
+ }
+ public void addEvent(EventSetDescriptor e) {
+ events.put(e.getName(),e);
+ }
+
+ public boolean hasMethod(MethodDescriptor m) {
+ for(int i=0;i<methods.size();i++) {
+ Method thisMethod = ((MethodDescriptor)methods.elementAt(i)).getMethod();
+ if(m.getMethod().getName().equals(thisMethod.getName())
+ && Arrays.equals(m.getMethod().getParameterTypes(),
+ thisMethod.getParameterTypes())) {
+ return true;
+ }
+ }
+ return false;
+ }
+ public void addMethod(MethodDescriptor m) {
+ methods.addElement(m);
+ }
+
+ public void setDefaultPropertyName(String defaultPropertyName) {
+ this.defaultPropertyName = defaultPropertyName;
+ }
+
+ public void setDefaultEventName(String defaultEventName) {
+ this.defaultEventName = defaultEventName;
+ }
+
+ public void setIcons(java.awt.Image[] im) {
+ this.im = im;
+ }
+}
diff --git a/libjava/classpath/gnu/java/beans/DummyAppletContext.java b/libjava/classpath/gnu/java/beans/DummyAppletContext.java
new file mode 100644
index 00000000000..4facb470d95
--- /dev/null
+++ b/libjava/classpath/gnu/java/beans/DummyAppletContext.java
@@ -0,0 +1,200 @@
+/* gnu.java.beans.DummyAppletContext
+ Copyright (C) 2004, 2005 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, 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.beans;
+
+import java.applet.Applet;
+import java.applet.AppletContext;
+import java.applet.AudioClip;
+import java.awt.Image;
+import java.awt.Toolkit;
+import java.io.IOException;
+import java.io.InputStream;
+import java.net.URL;
+import java.util.Collections;
+import java.util.Enumeration;
+import java.util.Iterator;
+
+/** A placeholder <code>AppletContext</code> implementation that does nothing.
+ *
+ * <p>This is the default implementation for GNU Classpath and is used for <code>Applet</code>
+ * beans being created with {@link java.beans.Beans.instantiate}.</p>
+ *
+ * <p>It has no functionality in order to allow it to be used without any dependencies
+ * (e.g. sound, network access, ...).</p>
+ *
+ * @author Robert Schuster
+ */
+class DummyAppletContext implements AppletContext
+{
+ private static final Enumeration EMPTY_ENUMERATION = Collections.enumeration(Collections.EMPTY_SET);
+ private static final AudioClip DUMMY_CLIP = new DummyAudioClip();
+
+ DummyAppletContext()
+ {
+ }
+
+ /** Implementation is VM neutral and returns a dummy {@link AudioClip} instance
+ * for every URL that returns a non-<code>null</code> object on
+ * <code>URL.openConnection()</code>.
+ *
+ * @see java.applet.AppletContext#getAudioClip(java.net.URL)
+ *
+ * FIXME: When Java Sound API (javax.sound) is included in Classpath or URL is able to handle
+ * sampled sound this should be adjusted.
+ */
+ public AudioClip getAudioClip(URL url)
+ {
+ try
+ {
+ return (url.openConnection() != null ? DUMMY_CLIP : null);
+ }
+ catch (IOException ioe)
+ {
+ return null;
+ }
+ }
+
+ /** Loads the <code>Image</code> instance by delegating to
+ * {@link java.awt.Toolkit.createImage(URL) }.
+ *
+ * @see java.applet.AppletContext#getImage(java.net.URL)
+ * @see java.awt.Toolkit#createImage(java.net.URL)
+ */
+ public Image getImage(URL url)
+ {
+ return Toolkit.getDefaultToolkit().createImage(url);
+ }
+
+ /** Returns <code>null</code> for every argument.
+ *
+ * @see java.applet.AppletContext#getApplet(java.lang.String)
+ */
+ public Applet getApplet(String name)
+ {
+ return null;
+ }
+
+ /** Returns always an empty <code>Enumeration</code>.
+ *
+ * @see java.applet.AppletContext#getApplets()
+ */
+ public Enumeration getApplets()
+ {
+ return EMPTY_ENUMERATION;
+ }
+
+ /** Does nothing.
+ *
+ * @see java.applet.AppletContext#showDocument(java.net.URL)
+ */
+ public void showDocument(URL url)
+ {
+ }
+
+ /** Does nothing.
+ *
+ * @see java.applet.AppletContext#showDocument(java.net.URL, java.lang.String)
+ */
+ public void showDocument(URL url, String target)
+ {
+ }
+
+ /** Does nothing.
+ *
+ * @see java.applet.AppletContext#showStatus(java.lang.String)
+ */
+ public void showStatus(String message)
+ {
+ }
+
+ /** Does nothing.
+ *
+ * @see java.applet.AppletContext#setStream(java.lang.String, java.io.InputStream)
+ */
+ public void setStream(String key, InputStream stream)
+ throws IOException
+ {
+ throw new IOException("Dummy implementation imposes zero InputStream associations.");
+ }
+
+ /** Returns <code>null</code> for every argument.
+ *
+ * @see java.applet.AppletContext#getStream(java.lang.String)
+ */
+ public InputStream getStream(String key)
+ {
+ return null;
+ }
+
+ /** Returns always an empty iterator.
+ *
+ * @see java.applet.AppletContext#getStreamKeys()
+ */
+ public Iterator getStreamKeys()
+ {
+ return Collections.EMPTY_SET.iterator();
+ }
+
+ /** Dummy <code>AudioClip</code> implementation that does nothing but
+ * preventing <code>NullPointerException</code>S being thrown in programs
+ * that expect a valid <code>AudioClip</code> instance to be returned by
+ * their Applet.
+ *
+ * @author Robert Schuster
+ */
+ static class DummyAudioClip implements AudioClip
+ {
+ public void play()
+ {
+ }
+
+ public void stop()
+ {
+ }
+
+ public void loop()
+ {
+ }
+
+ public String toString()
+ {
+ return "DummyAudioClip never plays anything - implement javax.sound and make us happy :)";
+ }
+ }
+}
diff --git a/libjava/classpath/gnu/java/beans/DummyAppletStub.java b/libjava/classpath/gnu/java/beans/DummyAppletStub.java
new file mode 100644
index 00000000000..3bcb43534cf
--- /dev/null
+++ b/libjava/classpath/gnu/java/beans/DummyAppletStub.java
@@ -0,0 +1,115 @@
+/* gnu.java.beans.DummyAppletStub
+ Copyright (C) 2004, 2005 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, 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.beans;
+
+import java.applet.AppletContext;
+import java.applet.AppletStub;
+import java.net.URL;
+
+/** Placeholder implementation of <code>AppletStub</code> providing no functionality.
+ * <p>This class is used for <code>Applet</code> being created with
+ * {@link java.beans.Bean.instantiate}.</p>
+ *
+ * @author Robert Schuster
+ */
+public class DummyAppletStub implements AppletStub
+{
+ private URL documentBase;
+ private URL codeBase;
+ private DummyAppletContext context;
+
+ public DummyAppletStub(URL newCodeBase, URL newDocumentBase)
+ {
+ codeBase = newCodeBase;
+ documentBase = newDocumentBase;
+
+ context = new DummyAppletContext();
+ }
+
+ /** Returns always <code>true</code>.
+ *
+ * @see java.applet.AppletStub#isActive()
+ */
+ public boolean isActive()
+ {
+ return true;
+ }
+
+ /**
+ * @see java.applet.AppletStub#getDocumentBase()
+ */
+ public URL getDocumentBase()
+ {
+ return documentBase;
+ }
+
+ /**
+ * @see java.applet.AppletStub#getCodeBase()
+ */
+ public URL getCodeBase()
+ {
+ return codeBase;
+ }
+
+ /** Implementation returns <code>null</code> for every parameter name.
+ *
+ * @see java.applet.AppletStub#getParameter(java.lang.String)
+ */
+ public String getParameter(String name)
+ {
+ return null;
+ }
+
+ /** Returns a non-functional context instance.
+ *
+ * @see java.applet.AppletStub#getAppletContext()
+ */
+ public AppletContext getAppletContext()
+ {
+ return context;
+ }
+
+ /** Does nothing.
+ *
+ * @see java.applet.AppletStub#appletResize(int, int)
+ */
+ public void appletResize(int width, int height)
+ {
+ }
+}
diff --git a/libjava/classpath/gnu/java/beans/ExplicitBeanInfo.java b/libjava/classpath/gnu/java/beans/ExplicitBeanInfo.java
new file mode 100644
index 00000000000..6da5e869695
--- /dev/null
+++ b/libjava/classpath/gnu/java/beans/ExplicitBeanInfo.java
@@ -0,0 +1,149 @@
+/* ExplicitBeanInfo.java --
+ Copyright (C) 1998, 2004 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, 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.beans;
+
+import java.awt.Image;
+import java.beans.BeanDescriptor;
+import java.beans.BeanInfo;
+import java.beans.EventSetDescriptor;
+import java.beans.MethodDescriptor;
+import java.beans.PropertyDescriptor;
+
+/**
+ ** ExplicitBeanInfo lets you specify in the constructor
+ ** all the various parts of the BeanInfo.
+ **
+ ** @author John Keiser
+ ** @version 1.1.0, 30 Jul 1998
+ ** @see java.beans.BeanInfo
+ **/
+
+public class ExplicitBeanInfo implements BeanInfo {
+ /** The BeanDescriptor returned by getBeanDescriptor. **/
+ protected BeanDescriptor beanDescriptor;
+
+ /** The EventSetDescriptor array returned by
+ ** getEventSetDescriptors().
+ **/
+ protected EventSetDescriptor[] eventSetDescriptors = new EventSetDescriptor[0];
+
+ /** The PropertyDescriptor array returned by
+ ** getPropertyDescriptors().
+ **/
+ protected PropertyDescriptor[] propertyDescriptors = new PropertyDescriptor[0];
+
+ /** The MethodDescriptor array returned by
+ ** getMethodDescriptors().
+ **/
+ protected MethodDescriptor[] methodDescriptors;
+
+ /** The default property index. **/
+ protected int defaultPropertyIndex;
+
+ /** The default event index. **/
+ protected int defaultEventIndex;
+
+ /** The BeanInfo array returned by
+ ** getAdditionalBeanInfo().
+ **/
+ protected BeanInfo[] additionalBeanInfo;
+
+ /** The set of icons. **/
+ protected Image[] icons;
+
+ public ExplicitBeanInfo(BeanDescriptor beanDescriptor,
+ BeanInfo[] additionalBeanInfo,
+ PropertyDescriptor[] propertyDescriptors,
+ int defaultPropertyIndex,
+ EventSetDescriptor[] eventSetDescriptors,
+ int defaultEventIndex,
+ MethodDescriptor[] methodDescriptors,
+ Image[] icons) {
+ this.beanDescriptor = beanDescriptor;
+ this.additionalBeanInfo = additionalBeanInfo;
+ this.propertyDescriptors = propertyDescriptors;
+ this.defaultPropertyIndex = defaultPropertyIndex;
+ this.eventSetDescriptors = eventSetDescriptors;
+ this.defaultEventIndex = defaultEventIndex;
+ this.methodDescriptors = methodDescriptors;
+ this.icons = icons;
+ }
+
+ /** Get Bean descriptor. **/
+ public BeanDescriptor getBeanDescriptor() {
+ return beanDescriptor;
+ }
+
+ /** Get Bean events. **/
+ public EventSetDescriptor[] getEventSetDescriptors() {
+ return eventSetDescriptors;
+ }
+
+ /** Get default event set. **/
+ public int getDefaultEventIndex() {
+ return defaultEventIndex;
+ }
+
+ /** Get Bean properties. **/
+ public PropertyDescriptor[] getPropertyDescriptors() {
+ return propertyDescriptors;
+ }
+
+ /** Get "default" property. **/
+ public int getDefaultPropertyIndex() {
+ return defaultPropertyIndex;
+ }
+
+ /** Get Bean methods. **/
+ public MethodDescriptor[] getMethodDescriptors() {
+ return methodDescriptors;
+ }
+
+ /** Get additional Bean info. **/
+ public BeanInfo[] getAdditionalBeanInfo() {
+ return additionalBeanInfo;
+ }
+
+ /** Get Bean icons.
+ ** @param iconType the type of icon
+ **/
+ public Image getIcon(int iconType) {
+ return icons != null ? icons[iconType - 1] : null;
+ }
+}
diff --git a/libjava/classpath/gnu/java/beans/IntrospectionIncubator.java b/libjava/classpath/gnu/java/beans/IntrospectionIncubator.java
new file mode 100644
index 00000000000..e0d9480e327
--- /dev/null
+++ b/libjava/classpath/gnu/java/beans/IntrospectionIncubator.java
@@ -0,0 +1,441 @@
+/* gnu.java.beans.IntrospectionIncubator
+ Copyright (C) 1998, 2004 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, 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.beans;
+
+import gnu.java.lang.ArrayHelper;
+import gnu.java.lang.ClassHelper;
+
+import java.beans.BeanInfo;
+import java.beans.EventSetDescriptor;
+import java.beans.IndexedPropertyDescriptor;
+import java.beans.IntrospectionException;
+import java.beans.Introspector;
+import java.beans.MethodDescriptor;
+import java.beans.PropertyDescriptor;
+import java.lang.reflect.Array;
+import java.lang.reflect.Method;
+import java.lang.reflect.Modifier;
+import java.util.Enumeration;
+import java.util.Hashtable;
+import java.util.Vector;
+
+/**
+ ** IntrospectionIncubator takes in a bunch of Methods, and
+ ** Introspects only those Methods you give it.<br/>
+ **
+ ** See {@link addMethod(Method)} for details which rules apply to
+ ** the methods.
+ **
+ ** @author John Keiser
+ ** @author Robert Schuster
+ ** @see gnu.java.beans.ExplicitBeanInfo
+ ** @see java.beans.BeanInfo
+ **/
+
+public class IntrospectionIncubator {
+ Hashtable propertyMethods = new Hashtable();
+ Hashtable listenerMethods = new Hashtable();
+ Vector otherMethods = new Vector();
+
+ Class propertyStopClass;
+ Class eventStopClass;
+ Class methodStopClass;
+
+ public IntrospectionIncubator() {
+ }
+
+ /** Examines the given method and files it in a suitable collection.
+ * It files the method as a property method if it finds:
+ * <ul>
+ * <li>boolean "is" getter</li>
+ * <li>"get" style getter</li>
+ * <li>single argument setter</li>
+ * <li>indiced setter and getter</li>
+ * </ul>
+ * It files the method as a listener method if all of these rules apply:
+ * <ul>
+ * <li>the method name starts with "add" or "remove"</li>
+ * <li>there is only a single argument</li>
+ * <li>the argument type is a subclass of <code>java.util.EventListener</code></li>
+ * </ul>
+ * All public methods are filed as such.
+ *
+ * @param method The method instance to examine.
+ */
+ public void addMethod(Method method) {
+ if(Modifier.isPublic(method.getModifiers())) {
+ String name = ClassHelper.getTruncatedName(method.getName());
+ Class retType = method.getReturnType();
+ Class[] params = method.getParameterTypes();
+ boolean isVoid = retType.equals(java.lang.Void.TYPE);
+ Class methodClass = method.getDeclaringClass();
+
+ /* Accepts the method for examination if no stop class is given or the method is declared in a subclass of the stop class.
+ * The rules for this are described in {@link java.beans.Introspector.getBeanInfo(Class, Class)}.
+ * This block finds out whether the method is a suitable getter or setter method (or read/write method).
+ */
+ if(isReachable(propertyStopClass, methodClass)) {
+ /* At this point a method may regarded as a property's read or write method if its name
+ * starts with "is", "get" or "set". However, if a method is static it cannot be part
+ * of a property.
+ */
+ if(Modifier.isStatic(method.getModifiers())) {
+ // files method as other because it is static
+ otherMethods.addElement(method);
+ } else if(name.startsWith("is")
+ && retType.equals(java.lang.Boolean.TYPE)
+ && params.length == 0) {
+ // files method as boolean "is" style getter
+ addToPropertyHash(name,method,IS);
+ } else if(name.startsWith("get") && !isVoid) {
+ if(params.length == 0) {
+ // files as legal non-argument getter
+ addToPropertyHash(name,method,GET);
+ } else if(params.length == 1 && params[0].equals(java.lang.Integer.TYPE)) {
+ // files as legal indiced getter
+ addToPropertyHash(name,method,GET_I);
+ } else {
+ // files as other because the method's signature is not Bean-like
+ otherMethods.addElement(method);
+ }
+ } else if(name.startsWith("set") && isVoid) {
+ if(params.length == 1) {
+ // files as legal single-argument setter method
+ addToPropertyHash(name,method,SET);
+ } else if(params.length == 2 && params[0].equals(java.lang.Integer.TYPE)) {
+ // files as legal indiced setter method
+ addToPropertyHash(name,method,SET_I);
+ } else {
+ // files as other because the method's signature is not Bean-like
+ otherMethods.addElement(method);
+ }
+ }
+ }
+
+ if(isReachable(eventStopClass, methodClass)) {
+ if(name.startsWith("add")
+ && isVoid
+ && params.length == 1
+ && java.util.EventListener.class.isAssignableFrom(params[0])) {
+ addToListenerHash(name,method,ADD);
+ } else if(name.startsWith("remove")
+ && isVoid
+ && params.length == 1
+ && java.util.EventListener.class.isAssignableFrom(params[0])) {
+ addToListenerHash(name,method,REMOVE);
+ }
+ }
+
+ if(isReachable(methodStopClass, methodClass)) {
+ // files as reachable public method
+ otherMethods.addElement(method);
+ }
+
+ }
+ }
+
+ public void addMethods(Method[] m) {
+ for(int i=0;i<m.length;i++) {
+ addMethod(m[i]);
+ }
+ }
+
+ public void setPropertyStopClass(Class c) {
+ propertyStopClass = c;
+ }
+
+ public void setEventStopClass(Class c) {
+ eventStopClass = c;
+ }
+
+ public void setMethodStopClass(Class c) {
+ methodStopClass = c;
+ }
+
+
+ public BeanInfoEmbryo getBeanInfoEmbryo() throws IntrospectionException {
+ BeanInfoEmbryo b = new BeanInfoEmbryo();
+ findXXX(b,IS);
+ findXXXInt(b,GET_I);
+ findXXXInt(b,SET_I);
+ findXXX(b,GET);
+ findXXX(b,SET);
+ findAddRemovePairs(b);
+ for(int i=0;i<otherMethods.size();i++) {
+ MethodDescriptor newMethod = new MethodDescriptor((Method)otherMethods.elementAt(i));
+ if(!b.hasMethod(newMethod)) {
+ b.addMethod(new MethodDescriptor((Method)otherMethods.elementAt(i)));
+ }
+ }
+ return b;
+ }
+
+ public BeanInfo getBeanInfo() throws IntrospectionException {
+ return getBeanInfoEmbryo().getBeanInfo();
+ }
+
+
+ void findAddRemovePairs(BeanInfoEmbryo b) throws IntrospectionException {
+ Enumeration listenerEnum = listenerMethods.keys();
+ while(listenerEnum.hasMoreElements()) {
+ DoubleKey k = (DoubleKey)listenerEnum.nextElement();
+ Method[] m = (Method[])listenerMethods.get(k);
+ if(m[ADD] != null && m[REMOVE] != null) {
+ EventSetDescriptor e = new EventSetDescriptor(Introspector.decapitalize(k.getName()),
+ k.getType(), k.getType().getMethods(),
+ m[ADD],m[REMOVE]);
+ e.setUnicast(ArrayHelper.contains(m[ADD].getExceptionTypes(),java.util.TooManyListenersException.class));
+ if(!b.hasEvent(e)) {
+ b.addEvent(e);
+ }
+ }
+ }
+ }
+
+ void findXXX(BeanInfoEmbryo b, int funcType) throws IntrospectionException {
+ Enumeration keys = propertyMethods.keys();
+ while(keys.hasMoreElements()) {
+ DoubleKey k = (DoubleKey)keys.nextElement();
+ Method[] m = (Method[])propertyMethods.get(k);
+ if(m[funcType] != null) {
+ PropertyDescriptor p = new PropertyDescriptor(Introspector.decapitalize(k.getName()),
+ m[IS] != null ? m[IS] : m[GET],
+ m[SET]);
+ if(m[SET] != null) {
+ p.setConstrained(ArrayHelper.contains(m[SET].getExceptionTypes(),java.beans.PropertyVetoException.class));
+ }
+ if(!b.hasProperty(p)) {
+ b.addProperty(p);
+ }
+ }
+ }
+ }
+
+ void findXXXInt(BeanInfoEmbryo b, int funcType) throws IntrospectionException {
+ Enumeration keys = propertyMethods.keys();
+ while(keys.hasMoreElements()) {
+ DoubleKey k = (DoubleKey)keys.nextElement();
+ Method[] m = (Method[])propertyMethods.get(k);
+ if(m[funcType] != null) {
+ boolean constrained;
+ if(m[SET_I] != null) {
+ constrained = ArrayHelper.contains(m[SET_I].getExceptionTypes(),java.beans.PropertyVetoException.class);
+ } else {
+ constrained = false;
+ }
+
+ /** Find out if there is an array type get or set **/
+ Class arrayType = Array.newInstance(k.getType(),0).getClass();
+ DoubleKey findSetArray = new DoubleKey(arrayType,k.getName());
+ Method[] m2 = (Method[])propertyMethods.get(findSetArray);
+ IndexedPropertyDescriptor p;
+ if(m2 == null) {
+ p = new IndexedPropertyDescriptor(Introspector.decapitalize(k.getName()),
+ null,null,
+ m[GET_I],m[SET_I]);
+ } else {
+ if(constrained && m2[SET] != null) {
+ constrained = ArrayHelper.contains(m2[SET].getExceptionTypes(),java.beans.PropertyVetoException.class);
+ }
+ p = new IndexedPropertyDescriptor(Introspector.decapitalize(k.getName()),
+ m2[GET],m2[SET],
+ m[GET_I],m[SET_I]);
+ }
+ p.setConstrained(constrained);
+ if(!b.hasProperty(p)) {
+ b.addProperty(p);
+ }
+ }
+ }
+ }
+
+ static final int IS=0;
+ static final int GET_I=1;
+ static final int SET_I=2;
+ static final int GET=3;
+ static final int SET=4;
+
+ static final int ADD=0;
+ static final int REMOVE=1;
+
+ void addToPropertyHash(String name, Method method, int funcType) {
+ String newName;
+ Class type;
+
+ switch(funcType) {
+ case IS:
+ type = java.lang.Boolean.TYPE;
+ newName = name.substring(2);
+ break;
+ case GET_I:
+ type = method.getReturnType();
+ newName = name.substring(3);
+ break;
+ case SET_I:
+ type = method.getParameterTypes()[1];
+ newName = name.substring(3);
+ break;
+ case GET:
+ type = method.getReturnType();
+ newName = name.substring(3);
+ break;
+ case SET:
+ type = method.getParameterTypes()[0];
+ newName = name.substring(3);
+ break;
+ default:
+ return;
+ }
+ newName = capitalize(newName);
+ if (newName.length() == 0)
+ return;
+
+ DoubleKey k = new DoubleKey(type,newName);
+ Method[] methods = (Method[])propertyMethods.get(k);
+ if(methods == null) {
+ methods = new Method[5];
+ propertyMethods.put(k,methods);
+ }
+ methods[funcType] = method;
+ }
+
+ void addToListenerHash(String name, Method method, int funcType) {
+ String newName;
+ Class type;
+
+ switch(funcType) {
+ case ADD:
+ type = method.getParameterTypes()[0];
+ newName = name.substring(3,name.length()-8);
+ break;
+ case REMOVE:
+ type = method.getParameterTypes()[0];
+ newName = name.substring(6,name.length()-8);
+ break;
+ default:
+ return;
+ }
+ newName = capitalize(newName);
+ if (newName.length() == 0)
+ return;
+
+ DoubleKey k = new DoubleKey(type,newName);
+ Method[] methods = (Method[])listenerMethods.get(k);
+ if(methods == null) {
+ methods = new Method[2];
+ listenerMethods.put(k,methods);
+ }
+ methods[funcType] = method;
+ }
+
+ /* Determines whether <code>stopClass</code> is <code>null</code>
+ * or <code>declaringClass<code> is a true subclass of <code>stopClass</code>.
+ * This expression is useful to detect whether a method should be introspected or not.
+ * The rules for this are described in {@link java.beans.Introspector.getBeanInfo(Class, Class)}.
+ */
+ static boolean isReachable(Class stopClass, Class declaringClass) {
+ return stopClass == null || (stopClass.isAssignableFrom(declaringClass) && !stopClass.equals(declaringClass));
+ }
+
+ /** Transforms a property name into a part of a method name.
+ * E.g. "value" becomes "Value" which can then concatenated with
+ * "set", "get" or "is" to form a valid method name.
+ *
+ * Implementation notes:
+ * If "" is the argument, it is returned without changes.
+ * If <code>null</code> is the argument, <code>null</code> is returned.
+ *
+ * @param name Name of a property.
+ * @return Part of a method name of a property.
+ */
+ static String capitalize(String name) {
+ try {
+ if(Character.isUpperCase(name.charAt(0))) {
+ return name;
+ } else {
+ char[] c = name.toCharArray();
+ c[0] = Character.toLowerCase(c[0]);
+ return new String(c);
+ }
+ } catch(StringIndexOutOfBoundsException E) {
+ return name;
+ } catch(NullPointerException E) {
+ return null;
+ }
+ }
+}
+
+/** This class is a hashmap key that consists of a <code>Class</code> and a
+ * <code>String</code> element.
+ *
+ * It is used for XXX: find out what this is used for
+ *
+ * @author John Keiser
+ * @author Robert Schuster
+ */
+class DoubleKey {
+ Class type;
+ String name;
+
+ DoubleKey(Class type, String name) {
+ this.type = type;
+ this.name = name;
+ }
+
+ Class getType() {
+ return type;
+ }
+
+ String getName() {
+ return name;
+ }
+
+ public boolean equals(Object o) {
+ if(o instanceof DoubleKey) {
+ DoubleKey d = (DoubleKey)o;
+ return d.type.equals(type) && d.name.equals(name);
+ } else {
+ return false;
+ }
+ }
+
+ public int hashCode() {
+ return type.hashCode() ^ name.hashCode();
+ }
+}
diff --git a/libjava/classpath/gnu/java/beans/TODO b/libjava/classpath/gnu/java/beans/TODO
new file mode 100644
index 00000000000..9112806ba70
--- /dev/null
+++ b/libjava/classpath/gnu/java/beans/TODO
@@ -0,0 +1 @@
+- overhaul efficiency
diff --git a/libjava/classpath/gnu/java/beans/decoder/AbstractContext.java b/libjava/classpath/gnu/java/beans/decoder/AbstractContext.java
new file mode 100644
index 00000000000..0e95d432986
--- /dev/null
+++ b/libjava/classpath/gnu/java/beans/decoder/AbstractContext.java
@@ -0,0 +1,70 @@
+/* gnu.java.beans.decoder.AbstractContext
+ Copyright (C) 2004 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, 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.beans.decoder;
+
+
+/** AbstractContext implements some basic functionality of the Context
+ * interface and is therefore the base of all Context implementations.
+ *
+ * @author Robert Schuster
+ */
+abstract class AbstractContext implements Context
+{
+ private boolean isStatement;
+ private String id;
+
+ public String getId()
+ {
+ return id;
+ }
+
+ public void setId(String newId)
+ {
+ id = newId;
+ }
+
+ public boolean isStatement()
+ {
+ return isStatement;
+ }
+
+ public void setStatement(boolean b)
+ {
+ isStatement = b;
+ }
+}
diff --git a/libjava/classpath/gnu/java/beans/decoder/AbstractCreatableObjectContext.java b/libjava/classpath/gnu/java/beans/decoder/AbstractCreatableObjectContext.java
new file mode 100644
index 00000000000..47f04fa1cbe
--- /dev/null
+++ b/libjava/classpath/gnu/java/beans/decoder/AbstractCreatableObjectContext.java
@@ -0,0 +1,113 @@
+/* gnu.java.beans.decoder.AbstractCreatableContext
+ Copyright (C) 2004 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, 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.beans.decoder;
+
+
+/** AbstractCreatableObjectContext is the base class for all Context implementations
+ * which create a result object in their lifetime. It provides means for preventing
+ * to create the object twice.
+ *
+ * @author Robert Schuster
+ *
+ */
+abstract class AbstractCreatableObjectContext extends AbstractObjectContext
+{
+ AbstractCreatableObjectContext()
+ {
+ }
+
+ /** Adds a parameter object to this Context if the result object has not been
+ * created yet. Otherwise an AssemblyException is thrown that indicates a wrong
+ * behavior of the decoder.
+ */
+ public final void addParameterObject(Object o) throws AssemblyException
+ {
+ if (object == null)
+ addParameterObjectImpl(o);
+ else
+ throw new AssemblyException(new IllegalStateException("No more parameter objects are allowed when the object as already been created."));
+ }
+
+ /** Adds a parameter object to this Context. Implement this without caring
+ * for illegal states because this has been done already.
+ *
+ * @param obj The parameter object to be added.
+ */
+ protected abstract void addParameterObjectImpl(Object obj);
+
+ /** Creates the result object if it does not exist already.
+ */
+ public final void notifyStatement(Context outerContext)
+ throws AssemblyException
+ {
+ if (object != null)
+ return;
+
+ object = createObject(outerContext);
+ }
+
+ /** Creates the result object. This method is called only once. Implement this
+ * without checking for double invocations as this is already being prevented.
+ *
+ * @param outerContext The Context that exists around this one.
+ * @return The result object.
+ * @throws AssemblerException if the object creation fails somehow.
+ */
+ protected abstract Object createObject(Context outerContext)
+ throws AssemblyException;
+
+ /* (non-Javadoc)
+ * @see gnu.java.beans.decoder.Context#endContext(gnu.java.beans.decoder.Context)
+ */
+ public final Object endContext(Context outerContext)
+ throws AssemblyException
+ {
+ notifyStatement(outerContext);
+ return object;
+ }
+
+ /* (non-Javadoc)
+ * @see gnu.java.beans.decoder.Context#subContextFailed()
+ */
+ public boolean subContextFailed()
+ {
+ /* Returns true when the AbstractCreatableObjectContext has not created the result object yet
+ * (A failed subcontext automatically lets this context fail too.)
+ */
+ return object == null;
+ }
+}
diff --git a/libjava/classpath/gnu/java/beans/decoder/AbstractElementHandler.java b/libjava/classpath/gnu/java/beans/decoder/AbstractElementHandler.java
new file mode 100644
index 00000000000..e5578a990bc
--- /dev/null
+++ b/libjava/classpath/gnu/java/beans/decoder/AbstractElementHandler.java
@@ -0,0 +1,316 @@
+/* gnu.java.beans.decoder.AbstractElementHandler
+ Copyright (C) 2004 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, 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.beans.decoder;
+
+import java.beans.ExceptionListener;
+
+import org.xml.sax.Attributes;
+
+/** ElementHandler manages a Context instance and interacts with
+ * its parent and child handlers.
+ *
+ * @author Robert Schuster
+ */
+abstract class AbstractElementHandler implements ElementHandler
+{
+ /** The Context instance of this handler. The instance is available after the startElement()
+ * method was called. Otherwise the handler is marked as failed.
+ */
+ private Context context;
+
+ /** The parent handler. */
+ private ElementHandler parent;
+
+ /** Stores whether this handler is marked as failed. */
+ private boolean hasFailed;
+
+ /** Stores the character data which is contained in the body of the XML tag. */
+ private StringBuffer buffer = new StringBuffer();
+
+ /** Stores whether this ElementHandler can have subelements. The information for this is taken from
+ * javabeans.dtd which can be found here:
+ * <a href="http://java.sun.com/products/jfc/tsc/articles/persistence3/">Java Persistence Article</a>
+ */
+ private boolean allowsSubelements;
+
+ /** Creates a new ElementHandler with the given ElementHandler instance
+ * as parent.
+ *
+ * @param parentHandler The parent handler.
+ */
+ protected AbstractElementHandler(ElementHandler parentHandler,
+ boolean allowsSubs)
+ {
+ parent = parentHandler;
+ allowsSubelements = allowsSubs;
+ }
+
+ /** Evaluates the attributes and creates a Context instance.
+ * If the creation of the Context instance fails the ElementHandler
+ * is marked as failed which may affect the parent handler other.
+ *
+ * @param attributes Attributes of the XML tag.
+ */
+ public final void start(Attributes attributes,
+ ExceptionListener exceptionListener)
+ {
+ try
+ {
+ // lets the subclass create the appropriate Context instance
+ context = startElement(attributes, exceptionListener);
+ }
+ catch (AssemblyException pe)
+ {
+ Throwable t = pe.getCause();
+
+ if (t instanceof Exception)
+ exceptionListener.exceptionThrown((Exception) t);
+ else
+ throw new InternalError("Unexpected Throwable type in AssemblerException. Please file a bug report.");
+
+ notifyContextFailed();
+
+ return;
+ }
+ }
+
+ /** Analyses the content of the Attributes instance and creates a Context
+ * object accordingly.
+ * An AssemblerException is thrown when the Context instance could not
+ * be created.
+ *
+ * @param attributes Attributes of the XML tag.
+ * @return A Context instance.
+ * @throws AssemblerException when Context instance could not be created.
+ */
+ protected abstract Context startElement(Attributes attributes, ExceptionListener exceptionListener)
+ throws AssemblyException;
+
+ /** Post-processes the Context.
+ */
+ public final void end(ExceptionListener exceptionListener)
+ {
+ // skips processing if the handler is marked as failed (because the Context
+ // is then invalid or may not exist at all)
+ if (!hasFailed)
+ {
+ try
+ {
+ // note: the order of operations is very important here
+ // sends the stored character data to the Context
+ endElement(buffer.toString());
+
+ // reports to the parent handler if this handler's Context is a
+ // statement (returning no value BACK to the parent's Context)
+ if (context.isStatement())
+ {
+ // This may create a valid result in the parent's Context
+ // or let it fail
+ parent.notifyStatement(exceptionListener);
+
+ // skips any further processing if the parent handler is now marked
+ // as failed
+ if (parent.hasFailed())
+ return;
+ }
+
+ // processes the Context and stores the result
+ putObject(context.getId(), context.endContext(parent.getContext()));
+
+ // transfers the Context's results to the parent's Context
+ // if it is an expression (rather than a statement)
+ if (! context.isStatement())
+ parent.getContext().addParameterObject(context.getResult());
+ }
+ catch (AssemblyException pe)
+ {
+ // notifies that an exception was thrown in this handler's Context
+ Throwable t = pe.getCause();
+
+ if (t instanceof Exception)
+ exceptionListener.exceptionThrown((Exception) t);
+ else
+ throw (InternalError) new InternalError("Severe problem while decoding XML data.")
+ .initCause(t);
+
+ // marks the handler as failed
+ notifyContextFailed();
+ }
+ }
+ }
+
+ /** Notifies the handler's Context that its child Context will not return
+ * a value back. Some Context variants need this information to know when
+ * a method or a constructor call can be made.
+ *
+ * This method is called by a child handler.
+ */
+ public void notifyStatement(ExceptionListener exceptionListener)
+ {
+ try
+ {
+
+ // propagates to parent handler first to generate objects
+ // needed by this Context instance
+ if(context.isStatement())
+ {
+ parent.notifyStatement(exceptionListener);
+ }
+
+ // Some Context instances do stuff which can fail now. If that
+ // happens this handler is marked as failed.
+ context.notifyStatement(parent.getContext());
+ }
+ catch (AssemblyException ae)
+ {
+ // notifies that an exception was thrown in this handler's Context
+ Throwable t = ae.getCause();
+
+ if (t instanceof Exception)
+ exceptionListener.exceptionThrown((Exception) t);
+ else
+ throw (InternalError) new InternalError("Severe problem while decoding XML data.")
+ .initCause(t);
+
+ // marks the handler as failed
+ notifyContextFailed();
+ }
+ }
+
+ /** Marks this and any depending parent handlers as failed. Which means that on their end
+ * no result is calculated.
+ *
+ * When a handler has failed no more handlers are accepted within it.
+ */
+ public final void notifyContextFailed()
+ {
+ hasFailed = true;
+
+ // marks the parent handler as failed if its Context
+ // is affected by the failure of this handler's Context
+ if (parent.getContext().subContextFailed())
+ parent.notifyContextFailed();
+ }
+
+ /** Returns whether this handler has failed.
+ *
+ * This is used to skip child elements.
+ *
+ * @return Whether this handler has failed.
+ */
+ public final boolean hasFailed()
+ {
+ return hasFailed;
+ }
+
+ /** Processes the character data when the element ends.
+ *
+ * The default implementation does nothing for convenience.
+ *
+ * @param characters
+ * @throws AssemblerException
+ */
+ protected void endElement(String characters) throws AssemblyException
+ {
+ // XXX: throw an exception when unexpected character data is available?
+ }
+
+ /** Adds characters from the body of the XML tag to the buffer.
+ *
+ * @param ch
+ * @param start
+ * @param length
+ * @throws SAXException
+ */
+ public final void characters(char[] ch, int start, int length)
+ {
+ // simply appends character data
+ buffer.append(ch, start, length);
+ }
+
+ /** Stores an object globally under a unique id. If the id is
+ * null the object is not stored.
+ *
+ * @param objectId
+ * @param o
+ */
+ public void putObject(String objectId, Object o)
+ {
+ if (objectId != null)
+ parent.putObject(objectId, o);
+ }
+
+ /** Returns a previously stored object. If the id is null the
+ * result is null, too.
+ *
+ * @param objectId
+ * @return Returns a previously stored object or null.
+ */
+ public Object getObject(String objectId) throws AssemblyException
+ {
+ return objectId == null ? null : parent.getObject(objectId);
+ }
+
+ /** Returns the Class instance as if called Class.forName() but
+ * uses a ClassLoader given by the user.
+ *
+ * @param className
+ * @return
+ * @throws ClassNotFoundException
+ */
+ public Class instantiateClass(String className)
+ throws ClassNotFoundException
+ {
+ return parent.instantiateClass(className);
+ }
+
+ public final boolean isSubelementAllowed(String subElementName)
+ {
+ return allowsSubelements && ! subElementName.equals("java");
+ }
+
+ public final Context getContext()
+ {
+ return context;
+ }
+
+ public final ElementHandler getParent()
+ {
+ return parent;
+ }
+}
diff --git a/libjava/classpath/gnu/java/beans/decoder/AbstractObjectContext.java b/libjava/classpath/gnu/java/beans/decoder/AbstractObjectContext.java
new file mode 100644
index 00000000000..202c33b3413
--- /dev/null
+++ b/libjava/classpath/gnu/java/beans/decoder/AbstractObjectContext.java
@@ -0,0 +1,127 @@
+/* gnu.java.beans.decoder.AbstractObjectContext
+ Copyright (C) 2004 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, 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.beans.decoder;
+
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
+
+/** AbstractObjectContext is the base for all Context implementations which
+ * create or provide a result object during their lifetime.
+ *
+ * <p>This class provides the implementation for an indexed get and set method.
+ * But this does not mean that the result object supports these operation.</p>
+ *
+ * @author Robert Schuster
+ *
+ */
+abstract class AbstractObjectContext extends AbstractContext
+{
+ protected Object object;
+
+ AbstractObjectContext()
+ {}
+
+ /** Sets the result object of the Context.
+ *
+ * @param obj The result object to be set.
+ */
+ protected final void setObject(Object obj)
+ {
+ object = obj;
+ }
+
+ /* (non-Javadoc)
+ * @see gnu.java.beans.decoder.Context#set(int, java.lang.Object)
+ */
+ public final void set(int index, Object o) throws AssemblyException
+ {
+ try
+ {
+ Method method =
+ object.getClass().getMethod(
+ "set",
+ new Class[] { Integer.TYPE, Object.class });
+
+ method.invoke(object, new Object[] { new Integer(index), o });
+ }
+ catch (NoSuchMethodException nsme)
+ {
+ throw new AssemblyException(nsme);
+ }
+ catch (InvocationTargetException ite)
+ {
+ throw new AssemblyException(ite.getCause());
+ }
+ catch (IllegalAccessException iae)
+ {
+ throw new AssemblyException(iae);
+ }
+ }
+
+ /* (non-Javadoc)
+ * @see gnu.java.beans.decoder.Context#get(int)
+ */
+ public final Object get(int index) throws AssemblyException
+ {
+ try
+ {
+ Method method =
+ object.getClass().getMethod(
+ "get",
+ new Class[] { Integer.TYPE });
+
+ return method.invoke(object, new Object[] { new Integer(index)});
+ }
+ catch (NoSuchMethodException nsme)
+ {
+ throw new AssemblyException(nsme);
+ }
+ catch (InvocationTargetException ite)
+ {
+ throw new AssemblyException(ite.getCause());
+ }
+ catch (IllegalAccessException iae)
+ {
+ throw new AssemblyException(iae);
+ }
+ }
+
+ public final Object getResult()
+ {
+ return object;
+ }
+}
diff --git a/libjava/classpath/gnu/java/beans/decoder/ArrayContext.java b/libjava/classpath/gnu/java/beans/decoder/ArrayContext.java
new file mode 100644
index 00000000000..cf4267f2779
--- /dev/null
+++ b/libjava/classpath/gnu/java/beans/decoder/ArrayContext.java
@@ -0,0 +1,122 @@
+/* gnu.java.beans.decoder.ArrayContext
+ Copyright (C) 2004 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, 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.beans.decoder;
+
+import java.lang.reflect.Array;
+
+/** A Context implementation for a fixed size array. The array
+ * elements have to be set using IndexContext instances.
+ *
+ * @author Robert Schuster
+ */
+class ArrayContext extends AbstractContext
+{
+ private Object array;
+
+ ArrayContext(String id, Class klass, int length)
+ {
+ setId(id);
+ array = Array.newInstance(klass, length);
+ }
+
+ /* (non-Javadoc)
+ * @see gnu.java.beans.decoder.Context#addObject(java.lang.Object)
+ */
+ public void addParameterObject(Object o) throws AssemblyException
+ {
+ throw new AssemblyException(new IllegalStateException("Adding objects without an index to a fixed array is not possible."));
+ }
+
+ /* (non-Javadoc)
+ * @see gnu.java.beans.decoder.Context#reportStatement()
+ */
+ public void notifyStatement(Context outerContext)
+ {
+ // method call intentionally ignored because there is not any useful effect
+ }
+
+ /* (non-Javadoc)
+ * @see gnu.java.beans.decoder.Context#endContext(gnu.java.beans.decoder.Context)
+ */
+ public Object endContext(Context outerContext) throws AssemblyException
+ {
+ return array;
+ }
+
+ /* (non-Javadoc)
+ * @see gnu.java.beans.decoder.Context#subContextFailed()
+ */
+ public boolean subContextFailed()
+ {
+ // returns false to indicate that assembling the array does not fail only because
+ // a subelement failed.
+ return false;
+ }
+
+ public void set(int index, Object o) throws AssemblyException
+ {
+ try
+ {
+ Array.set(array, index, o);
+ }
+ catch (ArrayIndexOutOfBoundsException aioobe)
+ {
+ throw new AssemblyException(aioobe);
+ }
+ }
+
+ public Object get(int index) throws AssemblyException
+ {
+ try
+ {
+ return Array.get(array, index);
+ }
+ catch (ArrayIndexOutOfBoundsException aioobe)
+ {
+ throw new AssemblyException(aioobe);
+ }
+ }
+
+ /* (non-Javadoc)
+ * @see gnu.java.beans.decoder.Context#getResult()
+ */
+ public Object getResult()
+ {
+ return array;
+ }
+}
diff --git a/libjava/classpath/gnu/java/beans/decoder/ArrayHandler.java b/libjava/classpath/gnu/java/beans/decoder/ArrayHandler.java
new file mode 100644
index 00000000000..23f0285192b
--- /dev/null
+++ b/libjava/classpath/gnu/java/beans/decoder/ArrayHandler.java
@@ -0,0 +1,118 @@
+/* gnu.java.beans.decoder.ArrayHandler
+ Copyright (C) 2004 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, 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.beans.decoder;
+
+import java.beans.ExceptionListener;
+import java.util.HashMap;
+
+import org.xml.sax.Attributes;
+
+/** ArrayHandler processes the &lt;array&gt; tag. Depending on the existance of the 'length' attribute a Context for
+ * a fixed-size or growable array is created.
+ *
+ * @author Robert Schuster
+ */
+class ArrayHandler extends AbstractElementHandler
+{
+ /** Contains a mapping between a textual description of a primitive type (like "byte") and
+ * its corresponding wrapper class. This allows it to easily construct Array objects for
+ * primitive data types.
+ */
+ private static HashMap typeMap = new HashMap();
+
+ static
+ {
+ typeMap.put("byte", Byte.TYPE);
+ typeMap.put("short", Short.TYPE);
+ typeMap.put("int", Integer.TYPE);
+ typeMap.put("long", Long.TYPE);
+
+ typeMap.put("float", Float.TYPE);
+ typeMap.put("double", Double.TYPE);
+
+ typeMap.put("boolean", Boolean.TYPE);
+
+ typeMap.put("char", Character.TYPE);
+ }
+
+ /**
+ * @param PersistenceParser
+ */
+ ArrayHandler(ElementHandler parent)
+ {
+ super(parent, true);
+ }
+
+ protected Context startElement(Attributes attributes, ExceptionListener exceptionListener)
+ throws AssemblyException, AssemblyException
+ {
+ String id = attributes.getValue("id");
+ String className = attributes.getValue("class");
+
+ if (className != null)
+ {
+ try
+ {
+ Class klass;
+
+ if (typeMap.containsKey(className))
+ klass = (Class) typeMap.get(className);
+ else
+ klass = instantiateClass(className);
+
+ String length = attributes.getValue("length");
+ if (length != null)
+ // creates Array with predefined length
+ return new ArrayContext(id, klass, Integer.parseInt(length));
+ else
+ // creates Array without length restriction
+ return new GrowableArrayContext(id, klass);
+ }
+ catch (ClassNotFoundException cnfe)
+ {
+ throw new AssemblyException(cnfe);
+ }
+ catch (NumberFormatException nfe)
+ {
+ throw new AssemblyException(nfe);
+ }
+ }
+
+ throw new AssemblyException(new IllegalArgumentException("Missing 'class' attribute in <array> tag."));
+ }
+}
diff --git a/libjava/classpath/gnu/java/beans/decoder/AssemblyException.java b/libjava/classpath/gnu/java/beans/decoder/AssemblyException.java
new file mode 100644
index 00000000000..29dfa65ac7c
--- /dev/null
+++ b/libjava/classpath/gnu/java/beans/decoder/AssemblyException.java
@@ -0,0 +1,57 @@
+/* gnu.java.beans.decoder.AssemblyException
+ Copyright (C) 2004 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, 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.beans.decoder;
+
+
+/** The AssemblyException is used to wrap the cause of problems when assembling objects.
+ * In all cases only the wrapped exception is given to the PersistenceParser's
+ * ExceptionListener instance (never the AssemblyException itself).
+ *
+ * <p>Note: Often multiple steps are needed to construct a fully usuable object instance.
+ * Such a construction can be called assembly and thats why this exception was
+ * named AssemblyException.</p>
+ *
+ * @author Robert Schuster
+ */
+class AssemblyException extends Exception
+{
+ AssemblyException(Throwable cause)
+ {
+ super(cause);
+ }
+}
diff --git a/libjava/classpath/gnu/java/beans/decoder/BooleanHandler.java b/libjava/classpath/gnu/java/beans/decoder/BooleanHandler.java
new file mode 100644
index 00000000000..a34fe346e0f
--- /dev/null
+++ b/libjava/classpath/gnu/java/beans/decoder/BooleanHandler.java
@@ -0,0 +1,67 @@
+/* gnu.java.beans.decoder.BooleanHandler
+ Copyright (C) 2004 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, 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.beans.decoder;
+
+
+/** Creates a Boolean instance from the character data in a &lt;boolean&gt; tag.
+ *
+ * @author Robert Schuster
+ */
+class BooleanHandler extends SimpleHandler
+{
+ /**
+ * @param PersistenceParser
+ */
+ BooleanHandler(ElementHandler parent)
+ {
+ super(parent);
+
+ // TODO Auto-generated constructor stub
+ }
+
+ protected Object parse(String number) throws AssemblyException
+ {
+ if (number.equals("true"))
+ return new Boolean(true);
+
+ if (number.equals("false"))
+ return new Boolean(false);
+
+ throw new AssemblyException(new IllegalArgumentException("Element contained no valid boolean value."));
+ }
+}
diff --git a/libjava/classpath/gnu/java/beans/decoder/ByteHandler.java b/libjava/classpath/gnu/java/beans/decoder/ByteHandler.java
new file mode 100644
index 00000000000..d6c33d14d21
--- /dev/null
+++ b/libjava/classpath/gnu/java/beans/decoder/ByteHandler.java
@@ -0,0 +1,59 @@
+/* gnu.java.beans.decoder.ByteHandler
+ Copyright (C) 2004 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, 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.beans.decoder;
+
+
+/** Creates a Byte instance from the character data in a &lt;byte&gt; tag.
+ *
+ * @author Robert Schuster
+ */
+class ByteHandler extends SimpleHandler
+{
+ /**
+ * @param PersistenceParser
+ */
+ ByteHandler(ElementHandler parent)
+ {
+ super(parent);
+ }
+
+ protected Object parse(String number) throws NumberFormatException
+ {
+ return Byte.valueOf(number);
+ }
+}
diff --git a/libjava/classpath/gnu/java/beans/decoder/CharHandler.java b/libjava/classpath/gnu/java/beans/decoder/CharHandler.java
new file mode 100644
index 00000000000..1b31e5b0559
--- /dev/null
+++ b/libjava/classpath/gnu/java/beans/decoder/CharHandler.java
@@ -0,0 +1,62 @@
+/* gnu.java.beans.decoder.CharHandler
+ Copyright (C) 2004 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, 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.beans.decoder;
+
+
+/** Creates a Character instance from the character data in a &lt;char&gt; tag.
+ *
+ * @author Robert Schuster
+ */
+class CharHandler extends SimpleHandler
+{
+ /**
+ * @param PersistenceParser
+ */
+ CharHandler(ElementHandler parent)
+ {
+ super(parent);
+ }
+
+ protected Object parse(String number) throws AssemblyException
+ {
+ if (number.length() > 1)
+ throw new AssemblyException(new IllegalArgumentException("Element contained no valid character."));
+
+ return new Character(number.charAt(0));
+ }
+}
diff --git a/libjava/classpath/gnu/java/beans/decoder/ClassHandler.java b/libjava/classpath/gnu/java/beans/decoder/ClassHandler.java
new file mode 100644
index 00000000000..1dbdd63e79a
--- /dev/null
+++ b/libjava/classpath/gnu/java/beans/decoder/ClassHandler.java
@@ -0,0 +1,66 @@
+/* gnu.java.beans.decoder.ClassHandler
+ Copyright (C) 2004 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, 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.beans.decoder;
+
+
+/** Creates a Class instance from the character data in a &lt;class&gt; tag.
+ *
+ * @author Robert Schuster
+ */
+class ClassHandler extends SimpleHandler
+{
+ /**
+ * @param PersistenceParser
+ */
+ ClassHandler(ElementHandler parent)
+ {
+ super(parent);
+ }
+
+ protected Object parse(String characters) throws AssemblyException
+ {
+ try
+ {
+ return instantiateClass(characters);
+ }
+ catch (ClassNotFoundException cnfe)
+ {
+ throw new AssemblyException(cnfe);
+ }
+ }
+}
diff --git a/libjava/classpath/gnu/java/beans/decoder/ConstructorContext.java b/libjava/classpath/gnu/java/beans/decoder/ConstructorContext.java
new file mode 100644
index 00000000000..7838fb7e263
--- /dev/null
+++ b/libjava/classpath/gnu/java/beans/decoder/ConstructorContext.java
@@ -0,0 +1,102 @@
+/* gnu.java.beans.decoder.ConstructorContext
+ Copyright (C) 2004 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, 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.beans.decoder;
+
+import java.lang.reflect.Constructor;
+import java.lang.reflect.InvocationTargetException;
+import java.util.ArrayList;
+
+/** A ConstructorContext is a {@link Context} implementation which collects the parameters for a constructor
+ * call and instantiates the result object using that constructor. After that sub-contexts can invoke
+ * methods on the result object.
+ *
+ * <p>The constructor is invoked when a sub-context is a statement or the Context ends.</p>
+ *
+ * @author Robert Schuster
+ */
+class ConstructorContext extends AbstractCreatableObjectContext
+{
+ private ArrayList arguments = new ArrayList();
+ private Class klass;
+
+ ConstructorContext(String id, Class newClass)
+ {
+ setId(id);
+ // sets superclass field
+ klass = newClass;
+ }
+
+ /* (non-Javadoc)
+ * @see gnu.java.beans.decoder.Context#addObject(java.lang.Object)
+ */
+ protected void addParameterObjectImpl(Object o)
+ {
+ arguments.add(o);
+ }
+
+ protected Object createObject(Context outerContext)
+ throws AssemblyException
+ {
+ Object[] args = arguments.toArray();
+
+ try
+ {
+ Constructor constructor = MethodFinder.getConstructor(klass, args);
+
+ // instantiates object (klass field gets re-set by superclass)
+ return constructor.newInstance(args);
+ }
+ catch (NoSuchMethodException nsme)
+ {
+ throw new AssemblyException(nsme);
+ }
+ catch (InvocationTargetException ite)
+ {
+ throw new AssemblyException(ite.getCause());
+ }
+ catch (IllegalAccessException iae)
+ {
+ throw new AssemblyException(iae);
+ }
+ catch (InstantiationException ie)
+ {
+ throw new AssemblyException(ie);
+ }
+ }
+
+}
diff --git a/libjava/classpath/gnu/java/beans/decoder/Context.java b/libjava/classpath/gnu/java/beans/decoder/Context.java
new file mode 100644
index 00000000000..a2db09732d1
--- /dev/null
+++ b/libjava/classpath/gnu/java/beans/decoder/Context.java
@@ -0,0 +1,137 @@
+/* gnu.java.beans.decoder.Context
+ Copyright (C) 2004 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, 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.beans.decoder;
+
+/** A Context is the environment for an object which is being assembler. If there
+ * are no errors each handler creates one Context.
+ * <p>Depending on the result of isStatement() a Context can be statement or an
+ * expression. An expression returns a value to the Context of its parent handler,
+ * a statement does not. Whenever a Context is a statement the parent handler's
+ * Context is informed about that through the {@link notifyStatement}-method.</p>
+ *
+ * @author Robert Schuster
+ */
+interface Context
+{
+ /** Adds a parameter object to the context. This method is used when
+ * sub-Contexts return their result.
+ *
+ * Some Contexts do not accept more than a certain amount of objects
+ * and throw an AssemblerException if the amount is exceeded.
+ *
+ * @param o The object added to this context.
+ */
+ void addParameterObject(Object o) throws AssemblyException;
+
+ /** Notifies that the next element is a statement. This can mean
+ * that an argument list is complete to be called.
+ *
+ */
+ void notifyStatement(Context outerContext) throws AssemblyException;
+
+ /** Notifies that the context ends and the returns the appropriate result
+ * object.
+ *
+ * @param outerContext
+ * @return
+ */
+ Object endContext(Context outerContext) throws AssemblyException;
+
+ /** Notifies that the assembly of a subcontext failed and returns
+ * whether this Context is affected in a way that it fails too.
+ *
+ * @return Whether the failure of a subcontext lets this context fail, too.
+ */
+ boolean subContextFailed();
+
+ /** Calls an appropriate indexed set method if it is available or
+ * throws an AssemblerException if that is not allowed on this Context.
+ *
+ * The behaviour of this method is equal to List.set(int, Object).
+ *
+ * @param index Index position to be set.
+ * @param o Object to be set at the given index position.
+ * @throws AssemblerException Indexed set is not allowed or otherwise failed.
+ */
+ void set(int index, Object o) throws AssemblyException;
+
+ /** Calls an appropriate indexed get method if it is available or
+ * throws an AssemblerException if that is not allowed on this Context.
+ *
+ * The behaviour of this method is equal to List.get(int).
+ *
+ * @param index Index position of the object return.
+ * @throws AssemblerException Indexed get is not allowed or otherwise failed.
+ */
+ Object get(int index) throws AssemblyException;
+
+ /** Returns the result which was calculated by calling endContext() or reportStatement().
+ * Its the handler's responsibility to care that any of these two methods was called.
+ *
+ * This is used by sub-Contexts to access this Context's result.
+ *
+ * @return
+ */
+ Object getResult();
+
+ /** Gives this Context a unique id. For convenience the id may be null which means
+ * that no id exists at all.
+ *
+ * @param id
+ */
+ void setId(String id);
+
+ /** Returns this Context's unique id or null if does not have such an id.
+ *
+ * @return This Context's id or null.
+ */
+ String getId();
+
+ /** Returns whether this Context is a statement (not returning result back
+ * to parent handler's Context) or not (= expression).
+ *
+ * @return
+ */
+ boolean isStatement();
+
+ /** Sets whether this Context is a statement or not.
+ *
+ * @param b
+ */
+ void setStatement(boolean b);
+}
diff --git a/libjava/classpath/gnu/java/beans/decoder/DecoderContext.java b/libjava/classpath/gnu/java/beans/decoder/DecoderContext.java
new file mode 100644
index 00000000000..69d84e57656
--- /dev/null
+++ b/libjava/classpath/gnu/java/beans/decoder/DecoderContext.java
@@ -0,0 +1,124 @@
+/* gnu.java.beans.decoder.DecoderContext
+ Copyright (C) 2004 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, 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.beans.decoder;
+
+import java.beans.XMLDecoder;
+import java.util.ArrayList;
+import java.util.Iterator;
+
+/** DecoderContext is a Context implementation which allows access to
+ * the XMLDecoder instance itself. This is used for the &lt;java&gt; tag.
+ *
+ * @author Robert Schuster
+ */
+public class DecoderContext extends AbstractContext
+{
+ private XMLDecoder decoder;
+
+ public DecoderContext(XMLDecoder xmlDecoder)
+ {
+ decoder = xmlDecoder;
+ }
+
+ private ArrayList objects = new ArrayList();
+
+ /* (non-Javadoc)
+ * @see gnu.java.beans.decoder.Context#addObject(java.lang.Object)
+ */
+ public void addParameterObject(Object o) throws AssemblyException
+ {
+ objects.add(o);
+ }
+
+ /* (non-Javadoc)
+ * @see gnu.java.beans.decoder.Context#reportStatement()
+ */
+ public void notifyStatement(Context outerContext) throws AssemblyException
+ {
+ }
+
+ /* (non-Javadoc)
+ * @see gnu.java.beans.decoder.Context#endContext(gnu.java.beans.decoder.Context)
+ */
+ public Object endContext(Context outerContext) throws AssemblyException
+ {
+ return decoder;
+ }
+
+ /* (non-Javadoc)
+ * @see gnu.java.beans.decoder.Context#subContextFailed()
+ */
+ public boolean subContextFailed()
+ {
+ return false;
+ }
+
+ /* (non-Javadoc)
+ * @see gnu.java.beans.decoder.Context#set(int, java.lang.Object)
+ */
+ public void set(int index, Object o) throws AssemblyException
+ {
+ throw new AssemblyException(new IllegalArgumentException("Set method is not allowed in decoder context."));
+ }
+
+ /* (non-Javadoc)
+ * @see gnu.java.beans.decoder.Context#get(int)
+ */
+ public Object get(int index) throws AssemblyException
+ {
+ throw new AssemblyException(new IllegalArgumentException("Get method is not allowed in decoder context."));
+ }
+
+ /* (non-Javadoc)
+ * @see gnu.java.beans.decoder.Context#getResult()
+ */
+ public Object getResult()
+ {
+ return decoder;
+ }
+
+ /** Returns an Iterator that retrieves the assembled objects.
+ *
+ * @return An Iterator retrieving assembled objects.
+ */
+ public Iterator iterator()
+ {
+ return objects.iterator();
+ }
+
+}
diff --git a/libjava/classpath/gnu/java/beans/decoder/DefaultExceptionListener.java b/libjava/classpath/gnu/java/beans/decoder/DefaultExceptionListener.java
new file mode 100644
index 00000000000..71e7158e7d2
--- /dev/null
+++ b/libjava/classpath/gnu/java/beans/decoder/DefaultExceptionListener.java
@@ -0,0 +1,57 @@
+/* gnu.java.beans.DefaultExceptionListener
+ Copyright (C) 2004 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, 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.beans.decoder;
+
+import java.beans.ExceptionListener;
+
+/** The DefaultExceptionListener is the default implementation of the ExceptionListener
+ * interface. An instance of this class is used whenever the user provided no
+ * ExceptionListener instance on its own.
+ *
+ * <p>The implementation just writes the exception's message to <code>System.err</code>.</p>
+ *
+ * @author Robert Schuster
+ */
+public class DefaultExceptionListener implements ExceptionListener
+{
+ public void exceptionThrown(Exception e)
+ {
+ System.err.println("non-critical exception: " + e + " - message: "
+ + e.getMessage());
+ }
+}
diff --git a/libjava/classpath/gnu/java/beans/decoder/DoubleHandler.java b/libjava/classpath/gnu/java/beans/decoder/DoubleHandler.java
new file mode 100644
index 00000000000..8f6be7ec092
--- /dev/null
+++ b/libjava/classpath/gnu/java/beans/decoder/DoubleHandler.java
@@ -0,0 +1,59 @@
+/* gnu.java.beans.decoder.DoubleHandler
+ Copyright (C) 2004 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, 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.beans.decoder;
+
+
+/** Creates a Double instance from the character data in a &lt;double&gt; tag.
+ *
+ * @author Robert Schuster
+ */
+class DoubleHandler extends SimpleHandler
+{
+ /**
+ * @param PersistenceParser
+ */
+ DoubleHandler(ElementHandler parent)
+ {
+ super(parent);
+ }
+
+ protected Object parse(String number) throws NumberFormatException
+ {
+ return Double.valueOf(number);
+ }
+}
diff --git a/libjava/classpath/gnu/java/beans/decoder/DummyContext.java b/libjava/classpath/gnu/java/beans/decoder/DummyContext.java
new file mode 100644
index 00000000000..f3b24549de2
--- /dev/null
+++ b/libjava/classpath/gnu/java/beans/decoder/DummyContext.java
@@ -0,0 +1,116 @@
+/* gnu.java.beans.decoder.DummyContext
+ Copyright (C) 2004 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, 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.beans.decoder;
+
+/** The DummyContext is used as the Context implementation for the DummyHandler. It
+ * just prevents having a null-reference.
+ *
+ * <p>When the implementation is correct none of this class' methods
+ * (except <code>notifyStatement()</code>) is called.</p>
+ *
+ * @author Robert Schuster
+ */
+public class DummyContext extends AbstractContext
+{
+ /* (non-Javadoc)
+ * @see gnu.java.beans.decoder.Context#addObject(java.lang.Object)
+ */
+ public void addParameterObject(Object o) throws AssemblyException
+ {
+ fail();
+ }
+
+ /* (non-Javadoc)
+ * @see gnu.java.beans.decoder.Context#reportStatement()
+ */
+ public void notifyStatement(Context outerContext) throws AssemblyException
+ {
+ // intentionally ignored
+ }
+
+ /* (non-Javadoc)
+ * @see gnu.java.beans.decoder.Context#endContext(gnu.java.beans.decoder.Context)
+ */
+ public Object endContext(Context outerContext) throws AssemblyException
+ {
+ fail();
+ return null;
+ }
+
+ /* (non-Javadoc)
+ * @see gnu.java.beans.decoder.Context#subContextFailed()
+ */
+ public boolean subContextFailed()
+ {
+ fail();
+ return false;
+ }
+
+ /* (non-Javadoc)
+ * @see gnu.java.beans.decoder.Context#set(int, java.lang.Object)
+ */
+ public void set(int index, Object o) throws AssemblyException
+ {
+ fail();
+ }
+
+ /* (non-Javadoc)
+ * @see gnu.java.beans.decoder.Context#get(int)
+ */
+ public Object get(int index) throws AssemblyException
+ {
+ fail();
+ return null;
+ }
+
+ /* (non-Javadoc)
+ * @see gnu.java.beans.decoder.Context#getResult()
+ */
+ public Object getResult()
+ {
+ fail();
+ return null;
+ }
+
+ private void fail()
+ {
+ throw new InternalError("Invoking the DummyContext is not expected"
+ + " - Please file a bug report at"
+ + " http://www/gnu.org/software/classpath/.");
+ }
+}
diff --git a/libjava/classpath/gnu/java/beans/decoder/DummyHandler.java b/libjava/classpath/gnu/java/beans/decoder/DummyHandler.java
new file mode 100644
index 00000000000..880d76adc0e
--- /dev/null
+++ b/libjava/classpath/gnu/java/beans/decoder/DummyHandler.java
@@ -0,0 +1,156 @@
+/* gnu.java.beans.decoder.DummyHandler
+ Copyright (C) 2004 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, 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.beans.decoder;
+
+import java.beans.ExceptionListener;
+
+import org.xml.sax.Attributes;
+
+/** An ElementHandler implementation that is used as an artificial root
+ * element. This avoids having to check for a null element.
+ *
+ * @author Robert Schuster
+ */
+class DummyHandler implements ElementHandler
+{
+ /* (non-Javadoc)
+ * @see gnu.java.beans.decoder.ElementHandler#start(org.xml.sax.Attributes, java.beans.ExceptionListener)
+ */
+ public void start(
+ Attributes attributes,
+ ExceptionListener exceptionListener)
+ {
+ fail();
+ }
+
+ /* (non-Javadoc)
+ * @see gnu.java.beans.decoder.ElementHandler#end(java.beans.ExceptionListener)
+ */
+ public void end(ExceptionListener exceptionListener)
+ {
+ fail();
+ }
+
+ /* (non-Javadoc)
+ * @see gnu.java.beans.decoder.ElementHandler#characters(char[], int, int)
+ */
+ public void characters(char[] ch, int start, int length)
+ {
+ fail();
+ }
+
+ /* (non-Javadoc)
+ * @see gnu.java.beans.decoder.ElementHandler#isSubelementAllowed(java.lang.String)
+ */
+ public boolean isSubelementAllowed(String subElementName)
+ {
+ return true;
+ }
+
+ /* (non-Javadoc)
+ * @see gnu.java.beans.decoder.ElementHandler#instantiateClass(java.lang.String)
+ */
+ public Class instantiateClass(String className)
+ throws ClassNotFoundException
+ {
+ fail();
+ return null;
+ }
+
+ /* (non-Javadoc)
+ * @see gnu.java.beans.decoder.ElementHandler#reportStatement(java.beans.ExceptionListener)
+ */
+ public void notifyStatement(ExceptionListener exceptionListener)
+ {
+ // ignore
+ }
+
+ /* (non-Javadoc)
+ * @see gnu.java.beans.decoder.ElementHandler#hasFailed()
+ */
+ public boolean hasFailed()
+ {
+ return false;
+ }
+
+ /* (non-Javadoc)
+ * @see gnu.java.beans.decoder.ElementHandler#getContext()
+ */
+ public Context getContext()
+ {
+ return new DummyContext();
+ }
+
+ /* (non-Javadoc)
+ * @see gnu.java.beans.decoder.ElementHandler#contextFailed()
+ */
+ public void notifyContextFailed()
+ {
+ fail();
+ }
+
+ /* (non-Javadoc)
+ * @see gnu.java.beans.decoder.ElementHandler#putObject(java.lang.String, java.lang.Object)
+ */
+ public void putObject(String objectId, Object o)
+ {
+ fail();
+ }
+
+ /* (non-Javadoc)
+ * @see gnu.java.beans.decoder.ElementHandler#getObject(java.lang.String)
+ */
+ public Object getObject(String objectId)
+ {
+ fail();
+ return null;
+ }
+
+ public ElementHandler getParent()
+ {
+ fail();
+ return null;
+ }
+
+ private void fail()
+ {
+ throw new InternalError("Invoking the DummyHandler is not expected"
+ + " - Please file a bug report at "
+ + " http://www.gnu.org/software/classpath/.");
+ }
+}
diff --git a/libjava/classpath/gnu/java/beans/decoder/ElementHandler.java b/libjava/classpath/gnu/java/beans/decoder/ElementHandler.java
new file mode 100644
index 00000000000..e6ae60af886
--- /dev/null
+++ b/libjava/classpath/gnu/java/beans/decoder/ElementHandler.java
@@ -0,0 +1,130 @@
+/* gnu.java.beans.decoder.ElementHandler
+ Copyright (C) 2004 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, 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.beans.decoder;
+
+import java.beans.ExceptionListener;
+
+import org.xml.sax.Attributes;
+
+/** ElementHandler manages a Context instance and interacts with
+ * its parent and child handlers.
+ *
+ * @author Robert Schuster
+ */
+interface ElementHandler
+{
+ /** Evaluates the attributes and creates a Context instance.
+ * If the creation of the Context instance fails the ElementHandler
+ * is marked as failed which may affect the parent handler other.
+ *
+ * @param attributes Attributes of the XML tag.
+ */
+ void start(Attributes attributes, ExceptionListener exceptionListener);
+
+ /** Post-processes the Context.
+ */
+ void end(ExceptionListener exceptionListener);
+
+ /** Adds characters from the body of the XML tag to the buffer.
+ *
+ * @param ch
+ * @param start
+ * @param length
+ * @throws SAXException
+ */
+ void characters(char[] ch, int start, int length);
+
+ /** Returns whether a subelement of the given name is allowed. The rules
+ * for evaluating this are derived from the javabeans.dtd which can be found
+ * here: <a href="http://java.sun.com/products/jfc/tsc/articles/persistence3">Java Persistence Article</a>.
+ *
+ * @param subElementName
+ * @return
+ */
+ boolean isSubelementAllowed(String subElementName);
+
+ /** Provides the same functionality as Class.forName() but allows the decoder
+ * to use a different class loader.
+ *
+ * @param className
+ * @return
+ * @throws ClassNotFoundException
+ */
+ Class instantiateClass(String className) throws ClassNotFoundException;
+
+ /** Notifies the handler's Context that its child Context will not return
+ * a value back. Some Context variants need this information to know when
+ * a method or a constructor call can be made.
+ *
+ * This method is called by a child handler.
+ */
+ void notifyStatement(ExceptionListener exceptionListener);
+
+ /** Returns whether this handler has failed.
+ *
+ * This is used to skip child elements.
+ *
+ * @return Whether this handler has failed.
+ */
+ boolean hasFailed();
+
+ /** Returns the Context instance this handler is working on.
+ *
+ * @return The handler's Context instance.
+ */
+ Context getContext();
+
+ /** Notifies the handler that its Context failed and starts a recursive
+ * invocation of the parent handler if it is affected by that failure.
+ *
+ * Although the method is a public API member it is only used internally.
+ */
+ void notifyContextFailed();
+
+ /** Stores the object under the given id. The object is not stored if the
+ * id is null.
+ *
+ * @param objectId
+ * @param o
+ */
+ void putObject(String objectId, Object o);
+
+ Object getObject(String objectId) throws AssemblyException;
+
+ ElementHandler getParent();
+}
diff --git a/libjava/classpath/gnu/java/beans/decoder/FloatHandler.java b/libjava/classpath/gnu/java/beans/decoder/FloatHandler.java
new file mode 100644
index 00000000000..5f0e15cefed
--- /dev/null
+++ b/libjava/classpath/gnu/java/beans/decoder/FloatHandler.java
@@ -0,0 +1,59 @@
+/* gnu.java.beans.decoder.FloatHandler
+ Copyright (C) 2004 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, 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.beans.decoder;
+
+
+/** Creates a Float instance from the character data in a &lt;float&gt; tag.
+ *
+ * @author Robert Schuster
+ */
+class FloatHandler extends SimpleHandler
+{
+ /**
+ * @param PersistenceParser
+ */
+ FloatHandler(ElementHandler parent)
+ {
+ super(parent);
+ }
+
+ protected Object parse(String number) throws NumberFormatException
+ {
+ return Float.valueOf(number);
+ }
+}
diff --git a/libjava/classpath/gnu/java/beans/decoder/GrowableArrayContext.java b/libjava/classpath/gnu/java/beans/decoder/GrowableArrayContext.java
new file mode 100644
index 00000000000..f24a60b4a4b
--- /dev/null
+++ b/libjava/classpath/gnu/java/beans/decoder/GrowableArrayContext.java
@@ -0,0 +1,138 @@
+/* gnu.java.beans.decoder.GrowableArrayContext
+ Copyright (C) 2004 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, 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.beans.decoder;
+
+import java.lang.reflect.Array;
+
+/** A Context implementation for a growable array. The array
+ * elements have to be set using expressions.
+ *
+ * @author Robert Schuster
+ */
+class GrowableArrayContext extends AbstractContext
+{
+ private static final int INITIAL_SIZE = 16;
+
+ private Class klass;
+ private Object array;
+ private int length;
+
+ GrowableArrayContext(String id, Class newClass)
+ {
+ setId(id);
+ klass = newClass;
+ array = Array.newInstance(klass, INITIAL_SIZE);
+ }
+
+ /* (non-Javadoc)
+ * @see gnu.java.beans.decoder.Context#addObject(java.lang.Object)
+ */
+ public void addParameterObject(Object o) throws AssemblyException
+ {
+ if (length == Array.getLength(array))
+ {
+ Object tmp = Array.newInstance(klass, length * 2);
+ System.arraycopy(array, 0, tmp, 0, length);
+ array = tmp;
+ }
+
+ try {
+ Array.set(array, length++, o);
+ } catch(IllegalArgumentException iae) {
+ throw new AssemblyException(iae);
+ }
+ }
+
+ /* (non-Javadoc)
+ * @see gnu.java.beans.decoder.Context#reportStatement()
+ */
+ public void notifyStatement(Context outerContext) throws AssemblyException
+ {
+ throw new AssemblyException(
+ new IllegalArgumentException("Statements inside a growable array are not allowed."));
+ }
+
+ /* (non-Javadoc)
+ * @see gnu.java.beans.decoder.Context#endContext(gnu.java.beans.decoder.Context)
+ */
+ public Object endContext(Context outerContext) throws AssemblyException
+ {
+ if (length != Array.getLength(array))
+ {
+ Object tmp = Array.newInstance(klass, length);
+ System.arraycopy(array, 0, tmp, 0, length);
+ array = tmp;
+ }
+
+ return array;
+ }
+
+ /* (non-Javadoc)
+ * @see gnu.java.beans.decoder.Context#subContextFailed()
+ */
+ public boolean subContextFailed()
+ {
+ // returns false to indicate that assembling the array does not fail only because
+ // a subelement failed
+ return false;
+ }
+
+ /* (non-Javadoc)
+ * @see gnu.java.beans.decoder.Context#set(int, java.lang.Object)
+ */
+ public void set(int index, Object o) throws AssemblyException
+ {
+ try {
+ Array.set(array, index, o);
+ } catch(IllegalArgumentException iae) {
+ throw new AssemblyException(iae);
+ }
+ }
+
+ /* (non-Javadoc)
+ * @see gnu.java.beans.decoder.Context#get(int)
+ */
+ public Object get(int index) throws AssemblyException
+ {
+ return Array.get(array, index);
+ }
+
+ public Object getResult()
+ {
+ return array;
+ }
+}
diff --git a/libjava/classpath/gnu/java/beans/decoder/IndexContext.java b/libjava/classpath/gnu/java/beans/decoder/IndexContext.java
new file mode 100644
index 00000000000..11f840caeec
--- /dev/null
+++ b/libjava/classpath/gnu/java/beans/decoder/IndexContext.java
@@ -0,0 +1,130 @@
+/* gnu.java.beans.decoder.IndexContext
+ Copyright (C) 2004 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, 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.beans.decoder;
+
+/** IndexContext is Context implementation that senses whether it is an indexed get or set
+ * operation and invokes this operation.
+ *
+ * <p>An IndexContent is a get operation when no argument is provided and a set operation if one
+ * argument is provided.</p>
+ *
+ * @author Robert Schuster
+ */
+class IndexContext extends AbstractContext
+{
+ private Object result;
+ private Object argument;
+ private int index;
+ private boolean isSetter;
+
+ IndexContext(String id, int newIndex)
+ {
+ setId(id);
+ index = newIndex;
+ }
+
+ /* (non-Javadoc)
+ * @see gnu.java.beans.decoder.Context#addObject(java.lang.Object)
+ */
+ public void addParameterObject(Object o) throws AssemblyException
+ {
+ if (! isSetter)
+ {
+ argument = o;
+ isSetter = true;
+ }
+ else
+ throw new AssemblyException(new IllegalStateException("More than one argument for indiced access is not possible."));
+ }
+
+ /* (non-Javadoc)
+ * @see gnu.java.beans.decoder.Context#reportStatement()
+ */
+ public void notifyStatement(Context outerContext) throws AssemblyException
+ {
+ throw new AssemblyException(new IllegalStateException("Statements inside indiced access are not allowed."));
+ }
+
+ /* (non-Javadoc)
+ * @see gnu.java.beans.decoder.Context#endContext(gnu.java.beans.decoder.Context)
+ */
+ public Object endContext(Context outerContext) throws AssemblyException
+ {
+ if (isSetter)
+ {
+ // setter
+ outerContext.set(index, argument);
+
+ return null;
+ }
+ else
+ // getter
+ return result = outerContext.get(index);
+ }
+
+ /* (non-Javadoc)
+ * @see gnu.java.beans.decoder.Context#subContextFailed()
+ */
+ public boolean subContextFailed()
+ {
+ // returns true to indicate that indiced access assembly fails when one of its
+ // argument could not be assembled
+ return true;
+ }
+
+ /* (non-Javadoc)
+ * @see gnu.java.beans.decoder.Context#set(int, java.lang.Object)
+ */
+ public void set(int index, Object o) throws AssemblyException
+ {
+ throw new AssemblyException(new IllegalStateException("Setter is not allowed inside indiced access."));
+ }
+
+ /* (non-Javadoc)
+ * @see gnu.java.beans.decoder.Context#get(int)
+ */
+ public Object get(int index) throws AssemblyException
+ {
+ throw new AssemblyException(new IllegalStateException("getter is not allowed insided indiced access."));
+ }
+
+ public Object getResult()
+ {
+ return result;
+ }
+}
diff --git a/libjava/classpath/gnu/java/beans/decoder/IntHandler.java b/libjava/classpath/gnu/java/beans/decoder/IntHandler.java
new file mode 100644
index 00000000000..a96f4a0315b
--- /dev/null
+++ b/libjava/classpath/gnu/java/beans/decoder/IntHandler.java
@@ -0,0 +1,59 @@
+/* gnu.java.beans.decoder.IntHandler
+ Copyright (C) 2004 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, 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.beans.decoder;
+
+
+/** Creates a Integer instance from the character data in a &lt;int&gt; tag.
+ *
+ * @author Robert Schuster
+ */
+class IntHandler extends SimpleHandler
+{
+ /**
+ * @param PersistenceParser
+ */
+ IntHandler(ElementHandler parent)
+ {
+ super(parent);
+ }
+
+ protected Object parse(String number) throws NumberFormatException
+ {
+ return Integer.valueOf(number);
+ }
+}
diff --git a/libjava/classpath/gnu/java/beans/decoder/JavaHandler.java b/libjava/classpath/gnu/java/beans/decoder/JavaHandler.java
new file mode 100644
index 00000000000..3bc8c60288c
--- /dev/null
+++ b/libjava/classpath/gnu/java/beans/decoder/JavaHandler.java
@@ -0,0 +1,93 @@
+/* gnu.java.beans.decoder.JavaHandler
+ Copyright (C) 2004 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, 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.beans.decoder;
+
+import java.beans.ExceptionListener;
+import java.util.HashMap;
+
+import org.xml.sax.Attributes;
+
+/** Wraps a DecoderContext instance.
+ *
+ * @author Robert Schuster
+ */
+public class JavaHandler extends AbstractElementHandler
+{
+ private Context context;
+ private HashMap objectMap = new HashMap();
+ private ClassLoader classLoader;
+
+ /**
+ * @param PersistenceParser
+ */
+ JavaHandler(DummyHandler parent, Context decoderContext,
+ ClassLoader cl)
+ {
+ super(parent, true);
+
+ classLoader = cl;
+
+ context = decoderContext;
+
+ }
+
+ protected Context startElement(Attributes attributes, ExceptionListener exceptionListener)
+ throws AssemblyException
+ {
+ // may expect version and class attribute but it not used in JDK
+ // so we do either
+ return context;
+ }
+
+ public Object getObject(String objectId)
+ {
+ return objectMap.get(objectId);
+ }
+
+ public void putObject(String objectId, Object o)
+ {
+ if (objectId != null)
+ objectMap.put(objectId, o);
+ }
+
+ public Class instantiateClass(String className)
+ throws ClassNotFoundException
+ {
+ return Class.forName(className, false, classLoader);
+ }
+}
diff --git a/libjava/classpath/gnu/java/beans/decoder/LongHandler.java b/libjava/classpath/gnu/java/beans/decoder/LongHandler.java
new file mode 100644
index 00000000000..d7bfa54e54e
--- /dev/null
+++ b/libjava/classpath/gnu/java/beans/decoder/LongHandler.java
@@ -0,0 +1,59 @@
+/* gnu.java.beans.decoder.LongHandler
+ Copyright (C) 2004 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, 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.beans.decoder;
+
+
+/** Creates a Long instance from the character data in a &lt;long&gt; tag.
+ *
+ * @author Robert Schuster
+ */
+class LongHandler extends SimpleHandler
+{
+ /**
+ * @param PersistenceParser
+ */
+ LongHandler(ElementHandler parent)
+ {
+ super(parent);
+ }
+
+ protected Object parse(String number) throws NumberFormatException
+ {
+ return Long.valueOf(number);
+ }
+}
diff --git a/libjava/classpath/gnu/java/beans/decoder/MethodContext.java b/libjava/classpath/gnu/java/beans/decoder/MethodContext.java
new file mode 100644
index 00000000000..bad0a213f7f
--- /dev/null
+++ b/libjava/classpath/gnu/java/beans/decoder/MethodContext.java
@@ -0,0 +1,107 @@
+/* gnu.java.beans.decoder.MethodContext
+ Copyright (C) 2004 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, 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.beans.decoder;
+
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
+import java.util.ArrayList;
+
+/** MethodContext collects arguments for a method call and creates the result object
+ * using it. The method is called using the result object of the parent Context.
+ *
+ * <p>When the result object is available methods can be called on it using sub-Contexts.</p>
+ *
+ * @author Robert Schuster
+ */
+class MethodContext extends AbstractCreatableObjectContext
+{
+ private ArrayList arguments = new ArrayList();
+ private String methodName;
+
+ MethodContext(String id, String newMethodName)
+ {
+ setId(id);
+ setStatement(true);
+ methodName = newMethodName;
+ }
+
+ /* (non-Javadoc)
+ * @see gnu.java.beans.decoder.Context#addObject(java.lang.Object)
+ */
+ public void addParameterObjectImpl(Object o)
+ {
+ arguments.add(o);
+ }
+
+ /* (non-Javadoc)
+ * @see gnu.java.beans.decoder.Context#endContext(gnu.java.beans.decoder.Context)
+ */
+ protected Object createObject(Context outerContext)
+ throws AssemblyException
+ {
+ Object outerObject = outerContext.getResult();
+
+ if (outerObject == null)
+ throw new AssemblyException(
+ new NullPointerException(
+ "No object to invoke method " + methodName));
+
+ Object[] args = arguments.toArray();
+
+ try
+ {
+ Method method =
+ MethodFinder.getMethod(
+ outerObject.getClass(),
+ methodName,
+ args);
+ return method.invoke(outerObject, args);
+ }
+ catch (NoSuchMethodException nsme)
+ {
+ throw new AssemblyException(nsme);
+ }
+ catch (InvocationTargetException ite)
+ {
+ throw new AssemblyException(ite.getCause());
+ }
+ catch (IllegalAccessException iae)
+ {
+ throw new AssemblyException(iae);
+ }
+ }
+}
diff --git a/libjava/classpath/gnu/java/beans/decoder/MethodFinder.java b/libjava/classpath/gnu/java/beans/decoder/MethodFinder.java
new file mode 100644
index 00000000000..3968b173adb
--- /dev/null
+++ b/libjava/classpath/gnu/java/beans/decoder/MethodFinder.java
@@ -0,0 +1,177 @@
+/* gnu.java.beans.decoder.MethodFinder
+ Copyright (C) 2004 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, 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.beans.decoder;
+
+import java.lang.reflect.Constructor;
+import java.lang.reflect.Method;
+import java.util.HashMap;
+
+class MethodFinder
+{
+ /** Provides a mapping between a wrapper class and its corresponding primitive's type. */
+ private static HashMap typeMapping = new HashMap();
+
+ static {
+ typeMapping.put(Byte.class, Byte.TYPE);
+ typeMapping.put(Short.class, Short.TYPE);
+ typeMapping.put(Integer.class, Integer.TYPE);
+ typeMapping.put(Long.class, Long.TYPE);
+ typeMapping.put(Float.class, Float.TYPE);
+ typeMapping.put(Double.class, Double.TYPE);
+
+ typeMapping.put(Character.class, Character.TYPE);
+ typeMapping.put(Boolean.class, Boolean.TYPE);
+ }
+
+ private MethodFinder()
+ {
+ }
+
+ /** Searches a Method which can accept the given arguments.
+ *
+ * @param klass
+ * @param name
+ * @param arguments
+ * @return
+ * @throws NoSuchMethodException
+ */
+ static Method getMethod(Class klass, String name, Object[] arguments)
+ throws NoSuchMethodException
+ {
+ // prepares array containing the types of the arguments
+ Class[] argumentTypes = getArgumentTypes(arguments);
+
+ Method[] methods = klass.getMethods();
+
+ // iterates over all public methods
+ for (int i = 0; i < methods.length; i++)
+ {
+ if (methods[i].getName().equals(name))
+ {
+ if (matchingArgumentTypes(methods[i].getParameterTypes(),
+ argumentTypes))
+ return methods[i];
+ }
+ }
+
+ throw new NoSuchMethodException(
+ "Could not find a matching method named "
+ + name
+ + "() in class "
+ + klass);
+ }
+
+ static Constructor getConstructor(Class klass, Object[] arguments)
+ throws NoSuchMethodException
+ {
+ Class[] argumentTypes = getArgumentTypes(arguments);
+ Constructor[] constructors = klass.getConstructors();
+
+ // iterates over all public methods
+ for (int i = 0; i < constructors.length; i++)
+ {
+ if (matchingArgumentTypes(constructors[i].getParameterTypes(),
+ argumentTypes))
+ return constructors[i];
+ }
+
+ throw new NoSuchMethodException(
+ "Could not find a matching constructor in class " + klass);
+ }
+
+ /** Transforms an array of argument objects into an array of argument types.
+ * For each argument being null the argument is null, too. An argument type
+ * being null means: Accepts everything (although this can be ambigous).
+ *
+ * @param arguments
+ * @return
+ */
+ private static Class[] getArgumentTypes(Object[] arguments)
+ {
+ if (arguments == null)
+ return new Class[0];
+
+ // prepares array containing the types of the arguments
+ Class[] argumentTypes = new Class[arguments.length];
+ for (int i = 0; i < arguments.length; i++)
+ argumentTypes[i] =
+ (arguments[i] == null) ? null : arguments[i].getClass();
+ return argumentTypes;
+ }
+
+ /** Tests whether the argument types supplied to the method argument types
+ * are assignable. In addition to the assignment specifications this method
+ * handles the primitive's wrapper classes as if they were of their
+ * primitive type (e.g Boolean.class equals Boolean.TYPE).
+ * When a supplied argument type is null it is assumed that no argument
+ * object was supplied for it and the test for this particular parameter will
+ * pass.
+ *
+ * @param methodArgTypes
+ * @param suppliedArgTypes
+ * @return
+ */
+ private static boolean matchingArgumentTypes(
+ Class[] methodArgTypes,
+ Class[] suppliedArgTypes)
+ {
+ if (methodArgTypes.length != suppliedArgTypes.length)
+ return false;
+
+ for (int i = 0; i < methodArgTypes.length; i++)
+ {
+ if (suppliedArgTypes[i] == null)
+ {
+ // by definition a non-existant argument type (null) can be converted to everything
+ continue;
+ }
+ else if (typeMapping.containsKey(suppliedArgTypes[i]))
+ {
+ Class primitiveType =
+ (Class) typeMapping.get(suppliedArgTypes[i]);
+ if (!(methodArgTypes[i].isAssignableFrom(suppliedArgTypes[i])
+ || methodArgTypes[i].isAssignableFrom(primitiveType)))
+ return false;
+ }
+ else if (!methodArgTypes[i].isAssignableFrom(suppliedArgTypes[i]))
+ return false;
+ }
+
+ return true;
+ }
+}
diff --git a/libjava/classpath/gnu/java/beans/decoder/NullHandler.java b/libjava/classpath/gnu/java/beans/decoder/NullHandler.java
new file mode 100644
index 00000000000..549617db3cb
--- /dev/null
+++ b/libjava/classpath/gnu/java/beans/decoder/NullHandler.java
@@ -0,0 +1,62 @@
+/* gnu.java.beans.decoder.NullHandler
+ Copyright (C) 2004 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, 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.beans.decoder;
+
+
+/** Just provides the 'null' object.
+ *
+ * @author Robert Schuster
+ */
+class NullHandler extends SimpleHandler
+{
+ /**
+ * @param PersistenceParser
+ */
+ NullHandler(ElementHandler parent)
+ {
+ super(parent);
+ }
+
+ protected Object parse(String characters) throws AssemblyException
+ {
+ if (! characters.equals(""))
+ throw new AssemblyException(new IllegalArgumentException("No characters inside <void> tag allowed."));
+
+ return null;
+ }
+}
diff --git a/libjava/classpath/gnu/java/beans/decoder/ObjectContext.java b/libjava/classpath/gnu/java/beans/decoder/ObjectContext.java
new file mode 100644
index 00000000000..cf88a2c2c5c
--- /dev/null
+++ b/libjava/classpath/gnu/java/beans/decoder/ObjectContext.java
@@ -0,0 +1,100 @@
+/* gnu.java.beans.decoder.ObjectHandler
+ Copyright (C) 2004 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, 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.beans.decoder;
+
+/** ObjectContext is a {@link Context} implementation that wraps a simple Object instance.
+ * The instance can be provided when the Context is created (due to an 'idref'
+ * attribute) or later (eg. &lt;int&gt; tag)
+ *
+ * <p>The ObjectContext does not accept any parameter object and ignores notifications
+ * about sub-contexts being statements.</p>
+ *
+ * @author Robert Schuster
+ */
+final class ObjectContext extends AbstractObjectContext
+{
+ ObjectContext(Object newObject)
+ {
+ setObject(newObject);
+ }
+
+ ObjectContext(String id, Object newObject)
+ {
+ setId(id);
+ setObject(newObject);
+ }
+
+ ObjectContext()
+ {
+ }
+
+ /* (non-Javadoc)
+ * @see gnu.java.beans.decoder.Context#addObject(java.lang.Object)
+ */
+ public void addParameterObject(Object o) throws AssemblyException
+ {
+ throw new AssemblyException(new IllegalArgumentException("Adding objects to an ObjectContext is not allowed."));
+ }
+
+ /* (non-Javadoc)
+ * @see gnu.java.beans.decoder.Context#reportStatement()
+ */
+ public void notifyStatement(Context outerContext) throws AssemblyException
+ {
+ // can ignore that
+ }
+
+ /* (non-Javadoc)
+ * @see gnu.java.beans.decoder.Context#endContext(gnu.java.beans.decoder.Context)
+ */
+ public Object endContext(Context outerContext) throws AssemblyException
+ {
+ // just returns the object which is encapsuled (may be null)
+ return getResult();
+ }
+
+ /* (non-Javadoc)
+ * @see gnu.java.beans.decoder.Context#subContextFailed()
+ */
+ public boolean subContextFailed()
+ {
+ // this context will not fail when a subcontext fails because the result is
+ // already available when the context is created.
+ return false;
+ }
+}
diff --git a/libjava/classpath/gnu/java/beans/decoder/ObjectHandler.java b/libjava/classpath/gnu/java/beans/decoder/ObjectHandler.java
new file mode 100644
index 00000000000..dc5b3290bb1
--- /dev/null
+++ b/libjava/classpath/gnu/java/beans/decoder/ObjectHandler.java
@@ -0,0 +1,169 @@
+/* gnu.java.beans.decoder.ObjectHandler
+ Copyright (C) 2004 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, 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.beans.decoder;
+
+import java.beans.ExceptionListener;
+
+import org.xml.sax.Attributes;
+
+/** An ObjectHandler parses the &lt;object&gt; tag and thereby creates various
+ * Context implementations.
+ *
+ * @author Robert Schuster
+ *
+ */
+public class ObjectHandler extends AbstractElementHandler
+{
+ /**
+ * XXX: Can all results be stored with an object id?
+ *
+ *
+ * @param PersistenceParser
+ */
+ ObjectHandler(ElementHandler parent)
+ {
+ super(parent, true);
+ }
+
+ protected Context startElement(Attributes attributes, ExceptionListener exceptionListener)
+ throws AssemblyException
+ {
+ String className = attributes.getValue("class");
+ String methodName = attributes.getValue("method");
+ String fieldName = attributes.getValue("field");
+ String index = attributes.getValue("index");
+ String propertyName = attributes.getValue("property");
+ String id = attributes.getValue("id");
+ String idRef = attributes.getValue("idref");
+
+ /* first check if we just want to access an existing object (idref present)
+ *
+ * note: <object idref="foo" method="bar"/> is not valid to call method "bar"
+ * on the object with id "foo". Instead this should return the object "foo"
+ * itself. The right way to this is:
+ * <object idref="foo">
+ * <object method="bar"/>
+ * </object>
+ *
+ * This means that if idref is present class, method, field, index and
+ * property are obsolete.
+ */
+ if (idRef != null)
+ // reactivates an existing object and giving it another name if id exists
+ return new ObjectContext(id, getObject(idRef));
+
+ // decides whether we are in a static (className present) or dynamic context
+ if (className != null)
+ {
+ try
+ {
+ Class klass = instantiateClass(className);
+
+ // class name exists which means that we are in a static context.
+ // so we may want to ...
+ // access a static field if the fieldName exists
+ if (fieldName != null)
+ {
+ try
+ {
+ return new ObjectContext(id,
+ klass.getField(fieldName).get(null));
+ }
+ catch (NoSuchFieldException nsfe)
+ {
+ throw new AssemblyException(nsfe);
+ }
+ catch (IllegalAccessException iae)
+ {
+ throw new AssemblyException(iae);
+ }
+ }
+
+ // (falling through is important!)
+ // run a constructor if methodName is "new" or null
+ if (methodName == null || methodName.equals("new"))
+ return new ConstructorContext(id, klass);
+
+ // (falling through is important!)
+ // run a static method on the given class (if methodName exists, which is implied already)
+ return new StaticMethodContext(id, klass, methodName);
+ // XXX: should fail if unexpected attributes are present?
+ }
+ catch (ClassNotFoundException cnfe)
+ {
+ throw new AssemblyException(cnfe);
+ }
+ }
+ else
+ {
+ // className does not exist which means we are in the context of
+ // some object and want to ...
+ // access the get(int index) method if index != null
+ if (index != null)
+ {
+ try
+ {
+ // Note: http://java.sun.com/products/jfc/tsc/articles/persistence3/ says
+ // that <void index="4"/> will make up a get()-call. But this is wrong because
+ // <void/> tags never return values (to the surrounding context)
+ return new IndexContext(id, Integer.parseInt(index));
+ }
+ catch (NumberFormatException nfe)
+ {
+ throw new AssemblyException(nfe);
+ }
+ }
+
+ // access a method if methodName exists
+ if (methodName != null)
+ return new MethodContext(id, methodName);
+
+ // (falling through is important!)
+ // access a property if a propertyName exists
+ if (propertyName != null && propertyName.length() > 0)
+ // this is reported as an ordinary method access where the propertyName is
+ // converted into a 'getter'-method name: convert first character of property name
+ // to upper case and prepend 'get'
+ // Note: This will be a getter-method because the <object> tag implies that a return
+ // value is expected.
+ return new PropertyContext(id, propertyName);
+ }
+
+ throw new AssemblyException(new IllegalArgumentException("Wrong or missing attributes for <object> tag."));
+ }
+}
diff --git a/libjava/classpath/gnu/java/beans/decoder/PersistenceParser.java b/libjava/classpath/gnu/java/beans/decoder/PersistenceParser.java
new file mode 100644
index 00000000000..4eb37abef97
--- /dev/null
+++ b/libjava/classpath/gnu/java/beans/decoder/PersistenceParser.java
@@ -0,0 +1,485 @@
+/* gnu.java.beans.PersistenceParser
+ Copyright (C) 2004, 2005 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, 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.beans.decoder;
+
+import java.beans.ExceptionListener;
+import java.beans.XMLDecoder;
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.LinkedList;
+import java.util.List;
+
+import javax.xml.parsers.ParserConfigurationException;
+import javax.xml.parsers.SAXParser;
+import javax.xml.parsers.SAXParserFactory;
+
+import org.xml.sax.Attributes;
+import org.xml.sax.SAXException;
+import org.xml.sax.helpers.DefaultHandler;
+
+/** The PersistenceParser parses an XML data stream and delegates actions to ElementHandler
+ * instances. The parser catches and recovers from all exception which reside from wrong usage
+ * of attributes and tags.
+ *
+ * @author Robert Schuster
+ */
+public class PersistenceParser extends DefaultHandler implements Context
+{
+ /** The ExceptionListener instance which is informed of non-critical parsing exceptions.
+ */
+ private ExceptionListener exceptionListener;
+
+ /** When an element was not usable all elements inside it should be skipped.
+ * This is done by skipping startElement() and endElement() invocations whenever
+ * this value is above 0.
+ */
+ private int skipElement;
+
+ /** Stores the Creator instances which can instantiate the appropriate handler implementation
+ * for a given element.
+ */
+ private HashMap handlerCreators = new HashMap();
+
+ /** Denotes the current ElementHandler. To avoid checking for null-values it is pre-assigned
+ * with a DummyHandler instance which must not be used but acts as a root element.
+ */
+ private ElementHandler currentHandler;
+
+ /** The real root element that stores all objects created during parsing.
+ * Package-private to avoid an accessor method.
+ */
+ JavaHandler javaHandler;
+
+ /** Stores the decoded objects. */
+ private List objects = new LinkedList();
+
+ /** The XMLDecoder instance that started this PersistenceParser */
+ private XMLDecoder decoder;
+
+ /** Creates a PersistenceParser which reads XML data from the given InputStream, reports
+ * exceptions to ExceptionListener instance, stores resulting object in the DecoderContext
+ * and uses the given ClassLoader to resolve classes.
+ *
+ * @param inputStream
+ * @param exceptionListener
+ * @param decoderContext
+ * @param cl
+ */
+ public PersistenceParser(
+ InputStream inputStream,
+ ExceptionListener exceptionListener,
+ ClassLoader cl,
+ XMLDecoder decoder)
+ {
+
+ this.exceptionListener = exceptionListener;
+ this.decoder = decoder;
+
+ DummyHandler dummyHandler = new DummyHandler();
+ currentHandler = dummyHandler;
+ javaHandler = new JavaHandler(dummyHandler, this, cl);
+
+ SAXParserFactory factory = SAXParserFactory.newInstance();
+
+ SAXParser parser;
+ try
+ {
+ parser = factory.newSAXParser();
+ }
+ catch (ParserConfigurationException pce)
+ {
+ // should not happen when a parser is available because we did
+ // not request any requirements on the XML parser
+ throw (InternalError) new InternalError(
+ "No SAX Parser available.").initCause(
+ pce);
+ }
+ catch (SAXException saxe)
+ {
+ // should not happen when a parser is available because we did
+ // not request any requirements on the XML parser
+ throw (InternalError) new InternalError(
+ "No SAX Parser available.").initCause(
+ saxe);
+ }
+
+ // prepares a map of Creator instances which can instantiate a handler which is
+ // appropriate for the tag that is used as a key for the Creator
+ handlerCreators.put("java", new JavaHandlerCreator());
+
+ // calls methods (properties), constructors, access fields
+ handlerCreators.put("object", new ObjectHandlerCreator());
+ handlerCreators.put("void", new VoidHandlerCreator());
+
+ handlerCreators.put("array", new ArrayHandlerCreator());
+
+ // these handler directly create an Object (or null)
+ handlerCreators.put("class", new ClassHandlerCreator());
+ handlerCreators.put("null", new NullHandlerCreator());
+
+ handlerCreators.put("char", new CharHandlerCreator());
+ handlerCreators.put("string", new StringHandlerCreator());
+ handlerCreators.put("boolean", new BooleanHandlerCreator());
+ handlerCreators.put("byte", new ByteHandlerCreator());
+ handlerCreators.put("short", new ShortHandlerCreator());
+ handlerCreators.put("int", new IntHandlerCreator());
+ handlerCreators.put("long", new LongHandlerCreator());
+ handlerCreators.put("float", new FloatHandlerCreator());
+ handlerCreators.put("double", new DoubleHandlerCreator());
+
+ // parses the data and sends all exceptions to the ExceptionListener
+ try
+ {
+ parser.parse(inputStream, this);
+ }
+ catch (SAXException saxe)
+ {
+ exceptionListener.exceptionThrown(
+ new IllegalArgumentException("XML data not well-formed."));
+ }
+ catch (IOException ioe)
+ {
+ exceptionListener.exceptionThrown(ioe);
+ }
+ }
+
+ public void startElement(
+ String uri,
+ String localName,
+ String qName,
+ Attributes attributes)
+ throws SAXException
+ {
+ /* The element is skipped if
+ * a) the current handler has already failed or a previous error occured
+ * which makes all children obsolete
+ */
+ if (currentHandler.hasFailed() || skipElement > 0)
+ {
+ exceptionListener.exceptionThrown(
+ new IllegalArgumentException(
+ "Element unusable due to previous error: " + qName));
+
+ skipElement++;
+
+ return;
+ }
+
+ /* b) Subelements are not allowed within the current ElementHandler.
+ */
+ if (!currentHandler.isSubelementAllowed(qName))
+ {
+ exceptionListener.exceptionThrown(
+ new IllegalArgumentException(
+ "Element is not allowed here: " + qName));
+
+ skipElement++;
+
+ return;
+ }
+
+ /* c) The tag name is not a key in the map of Creator instances. This means that
+ * either the XML data is of a newer version or simply contains a miss-spelled element.
+ */
+ if (!handlerCreators.containsKey(qName))
+ {
+ exceptionListener.exceptionThrown(
+ new IllegalArgumentException(
+ "Element unusable because tag is unknown: " + qName));
+
+ skipElement++;
+
+ return;
+ }
+
+ // creates a new handler for the new element
+ AbstractElementHandler handler =
+ ((Creator) handlerCreators.get(qName)).createHandler(
+ currentHandler);
+
+ // makes it the current handler to receive character data
+ currentHandler = handler;
+
+ // starts the handler
+ currentHandler.start(attributes, exceptionListener);
+ }
+
+ public void endElement(String uri, String localName, String qName)
+ throws SAXException
+ {
+ // skips processing the current handler if we are parsing an element
+ // which was marked invalid (in startElement() )
+ if (skipElement > 0)
+ {
+ skipElement--;
+ return;
+ }
+
+ // invokes the handler's finishing method
+ currentHandler.end(exceptionListener);
+
+ // removes the current handler and reactivates its parent
+ currentHandler = currentHandler.getParent();
+ }
+
+ /** Transfers character data to the current handler
+ */
+ public void characters(char[] ch, int start, int length)
+ throws SAXException
+ {
+ // prevents sending character data of invalid elements
+ if (skipElement > 0)
+ return;
+
+ currentHandler.characters(ch, start, length);
+ }
+
+ /** Creator interface provided a mechanism to instantiate ElementHandler instances
+ * for the appropriate tag.
+ *
+ * @author Robert Schuster
+ */
+ interface Creator
+ {
+ /** Creates an ElementHandler instance using the given ElementHandler as its parent.
+ *
+ * @param parent The parent ElementHandler of the result.
+ * @return A new ElementHandler instance.
+ */
+ AbstractElementHandler createHandler(ElementHandler parent);
+ }
+
+ class BooleanHandlerCreator implements Creator
+ {
+ public AbstractElementHandler createHandler(ElementHandler parent)
+ {
+ return new BooleanHandler(parent);
+ }
+ }
+
+ class ByteHandlerCreator implements Creator
+ {
+ public AbstractElementHandler createHandler(ElementHandler parent)
+ {
+ return new ByteHandler(parent);
+ }
+ }
+
+ class ShortHandlerCreator implements Creator
+ {
+ public AbstractElementHandler createHandler(ElementHandler parent)
+ {
+ return new ShortHandler(parent);
+ }
+ }
+
+ class IntHandlerCreator implements Creator
+ {
+ public AbstractElementHandler createHandler(ElementHandler parent)
+ {
+ return new IntHandler(parent);
+ }
+ }
+
+ class LongHandlerCreator implements Creator
+ {
+ public AbstractElementHandler createHandler(ElementHandler parent)
+ {
+ return new LongHandler(parent);
+ }
+ }
+
+ class FloatHandlerCreator implements Creator
+ {
+ public AbstractElementHandler createHandler(ElementHandler parent)
+ {
+ return new FloatHandler(parent);
+ }
+ }
+
+ class DoubleHandlerCreator implements Creator
+ {
+ public AbstractElementHandler createHandler(ElementHandler parent)
+ {
+ return new DoubleHandler(parent);
+ }
+ }
+
+ class CharHandlerCreator implements Creator
+ {
+ public AbstractElementHandler createHandler(ElementHandler parent)
+ {
+ return new CharHandler(parent);
+ }
+ }
+
+ class StringHandlerCreator implements Creator
+ {
+ public AbstractElementHandler createHandler(ElementHandler parent)
+ {
+ return new StringHandler(parent);
+ }
+ }
+
+ class JavaHandlerCreator implements Creator
+ {
+ public AbstractElementHandler createHandler(ElementHandler parent)
+ {
+ return javaHandler;
+ }
+ }
+
+ class ObjectHandlerCreator implements Creator
+ {
+ public AbstractElementHandler createHandler(ElementHandler parent)
+ {
+ return new ObjectHandler(parent);
+ }
+ }
+
+ class VoidHandlerCreator implements Creator
+ {
+ public AbstractElementHandler createHandler(ElementHandler parent)
+ {
+ return new VoidHandler(parent);
+ }
+ }
+
+ class ClassHandlerCreator implements Creator
+ {
+ public AbstractElementHandler createHandler(ElementHandler parent)
+ {
+ return new ClassHandler(parent);
+ }
+ }
+
+ class NullHandlerCreator implements Creator
+ {
+ public AbstractElementHandler createHandler(ElementHandler parent)
+ {
+ return new NullHandler(parent);
+ }
+ }
+
+ class ArrayHandlerCreator implements Creator
+ {
+ public AbstractElementHandler createHandler(ElementHandler parent)
+ {
+ return new ArrayHandler(parent);
+ }
+ }
+
+ /** Adds a decoded object to the Context. */
+ public void addParameterObject(Object o) throws AssemblyException
+ {
+ objects.add(o);
+ }
+
+ public void notifyStatement(Context outerContext) throws AssemblyException
+ {
+ // can be ignored because theis Context does not react to statement and expressions
+ // differently
+ }
+
+ public Object endContext(Context outerContext) throws AssemblyException
+ {
+ return null;
+ }
+
+ public boolean subContextFailed()
+ {
+ // failing of subcontexts is no problem for the mother of all contexts
+ return false;
+ }
+
+ public void set(int index, Object o) throws AssemblyException
+ {
+ // not supported
+ throw new AssemblyException(
+ new IllegalArgumentException("Set method is not allowed in decoder context."));
+ }
+
+ public Object get(int index) throws AssemblyException
+ {
+ // not supported
+ throw new AssemblyException(
+ new IllegalArgumentException("Get method is not allowed in decoder context."));
+ }
+
+ public Object getResult()
+ {
+ // returns the XMLDecoder instance which is requested by child contexts this way.
+ // That is needed to invoke methods on the decoder.
+ return decoder;
+ }
+
+ public void setId(String id)
+ {
+ exceptionListener.exceptionThrown(new IllegalArgumentException("id attribute is not allowed for <java> tag."));
+ }
+
+ public String getId()
+ {
+ // appears to have no id
+ return null;
+ }
+
+ public boolean isStatement()
+ {
+ // this context is a statement by definition because it never returns anything to a parent because
+ // there is no such parent (DummyContext does not count!)
+ return true;
+ }
+
+ public void setStatement(boolean b)
+ {
+ // ignores that because this Context is always a statement
+ }
+
+ /** Returns an Iterator instance which returns the decoded objects.
+ *
+ * This method is used by the XMLDecoder directly.
+ */
+ public Iterator iterator()
+ {
+ return objects.iterator();
+ }
+
+}
diff --git a/libjava/classpath/gnu/java/beans/decoder/PropertyContext.java b/libjava/classpath/gnu/java/beans/decoder/PropertyContext.java
new file mode 100644
index 00000000000..838ef814b01
--- /dev/null
+++ b/libjava/classpath/gnu/java/beans/decoder/PropertyContext.java
@@ -0,0 +1,137 @@
+/* gnu.java.beans.decoder.PropertyContext
+ Copyright (C) 2004 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, 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.beans.decoder;
+
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
+
+/** PropertyContext is a Context implementation that is very similar to MethodContext
+ * and IndexContext. The sole purpose of PropertyContext to find out whether it should
+ * 'set' or 'get' a certain property. This decision is made using the number of
+ * arguments.
+ * <p>When the method call has to be made and there is no argument we 'get' the property.
+ * With one argument it is 'set'.</p>
+ *
+ * @author Robert Schuster
+ */
+class PropertyContext extends AbstractObjectContext
+{
+ private Object argument;
+ private String propertyName;
+ private String prefix = "get";
+ private boolean methodCalled;
+
+ PropertyContext(String id, String newPropertyName)
+ {
+ setId(id);
+ propertyName = newPropertyName;
+ }
+
+ /* (non-Javadoc)
+ * @see gnu.java.beans.decoder.Context#addObject(java.lang.Object)
+ */
+ public void addParameterObject(Object o) throws AssemblyException
+ {
+ if (methodCalled)
+ throw new AssemblyException(new IllegalArgumentException("Cannot add parameter object when method was already called."));
+
+ if (argument != null)
+ throw new AssemblyException(new IllegalArgumentException("Property attribut allows zero or one argument only."));
+
+ argument = o;
+ setStatement(true);
+ prefix = "set";
+ }
+
+ /* (non-Javadoc)
+ * @see gnu.java.beans.decoder.Context#endContext(gnu.java.beans.decoder.Context)
+ */
+ public void notifyStatement(Context outerContext) throws AssemblyException
+ {
+ if (methodCalled)
+ return;
+ methodCalled = true;
+
+ Object outerObject = outerContext.getResult();
+
+ if (outerObject == null)
+ throw new AssemblyException(new NullPointerException("No object to access property "
+ + propertyName));
+
+
+ // converts property name into a method name
+ String methodName = prefix + propertyName.substring(0, 1).toUpperCase()
+ + propertyName.substring(1);
+
+ // prepares the argument
+ Object[] args = (argument != null) ? new Object[] { argument } : null;
+
+ try
+ {
+ Method method = MethodFinder.getMethod(outerObject.getClass(),
+ methodName, args);
+
+ // stores the result whether it is available or not
+ setObject(method.invoke(outerObject, args));
+ }
+ catch (NoSuchMethodException nsme)
+ {
+ throw new AssemblyException(nsme);
+ }
+ catch (InvocationTargetException ite)
+ {
+ throw new AssemblyException(ite.getCause());
+ }
+ catch (IllegalAccessException iae)
+ {
+ throw new AssemblyException(iae);
+ }
+ }
+
+ public Object endContext(Context outerContext) throws AssemblyException
+ {
+ notifyStatement(outerContext);
+
+ return getResult();
+ }
+
+ public boolean subContextFailed()
+ {
+ return ! methodCalled;
+ }
+}
diff --git a/libjava/classpath/gnu/java/beans/decoder/ShortHandler.java b/libjava/classpath/gnu/java/beans/decoder/ShortHandler.java
new file mode 100644
index 00000000000..ab6ddbece26
--- /dev/null
+++ b/libjava/classpath/gnu/java/beans/decoder/ShortHandler.java
@@ -0,0 +1,58 @@
+/* gnu.java.beans.decoder.ShortHandler
+ Copyright (C) 2004 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, 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.beans.decoder;
+
+/** Creates a Short instance from the character data in a &lt;short&gt; tag.
+ *
+ * @author Robert Schuster
+ */
+class ShortHandler extends SimpleHandler
+{
+ /**
+ * @param PersistenceParser
+ */
+ ShortHandler(ElementHandler parent)
+ {
+ super(parent);
+ }
+
+ protected Object parse(String number) throws NumberFormatException
+ {
+ return Short.valueOf(number);
+ }
+}
diff --git a/libjava/classpath/gnu/java/beans/decoder/SimpleHandler.java b/libjava/classpath/gnu/java/beans/decoder/SimpleHandler.java
new file mode 100644
index 00000000000..bc187e8a052
--- /dev/null
+++ b/libjava/classpath/gnu/java/beans/decoder/SimpleHandler.java
@@ -0,0 +1,111 @@
+/* gnu.java.beans.decoder.SimpleHandler
+ Copyright (C) 2004 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, 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.beans.decoder;
+
+import java.beans.ExceptionListener;
+
+import org.xml.sax.Attributes;
+
+/** XML element handler that is specialized on tags that contains a simple string in their
+ * body which has to be parsed in a specific way.
+ * <p>All of these tags have in common that they do not accept attributes. A warning is
+ * send to the parser's ExceptionListener when one or more attributes exist.</p>
+ *
+ * @author Robert Schuster
+ */
+abstract class SimpleHandler extends AbstractElementHandler
+{
+ private ObjectContext context;
+
+ /**
+ * @param PersistenceParser
+ */
+ SimpleHandler(ElementHandler parent)
+ {
+ super(parent, false);
+
+ // SimpleHandler do not accept any subelements
+ }
+
+ protected final Context startElement(Attributes attributes, ExceptionListener exceptionListener)
+ throws AssemblyException
+ {
+
+ // note: simple elements should not have any attributes. We inform
+ // the user of this syntactical but uncritical problem by sending
+ // an IllegalArgumentException for each unneccessary attribute
+ int size = attributes.getLength();
+ for (int i = 0; i < size; i++) {
+ String attributeName = attributes.getQName(i);
+ Exception e =
+ new IllegalArgumentException(
+ "Unneccessary attribute '"
+ + attributeName
+ + "' discarded.");
+ exceptionListener.exceptionThrown(e);
+ }
+
+ return context = new ObjectContext();
+ }
+
+ public void endElement(String characters)
+ throws AssemblyException, AssemblyException
+ {
+ // reports the number when the character data can be parsed
+ try
+ {
+ context.setObject(parse(characters));
+ }
+ catch (NumberFormatException nfe)
+ {
+ throw new AssemblyException(nfe);
+ }
+ }
+
+ /** Returns an object that is created from the given characters. If the string is
+ * converted into a number a NumberFormatException is cathed and reported
+ * appropriately.
+ *
+ * @param characters A string of characters that has to be processed in some way.
+ * @return An Object instance generated from the given data.
+ * @throws AssemblerException When the string was invalid.
+ * @throws NumberFormatException When the string could not be parsed into a number.
+ */
+ protected abstract Object parse(String characters)
+ throws AssemblyException, NumberFormatException;
+}
diff --git a/libjava/classpath/gnu/java/beans/decoder/StaticMethodContext.java b/libjava/classpath/gnu/java/beans/decoder/StaticMethodContext.java
new file mode 100644
index 00000000000..959c949f77b
--- /dev/null
+++ b/libjava/classpath/gnu/java/beans/decoder/StaticMethodContext.java
@@ -0,0 +1,95 @@
+/* gnu.java.beans.decoder.StaticMethodContext
+ Copyright (C) 2004 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, 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.beans.decoder;
+
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
+import java.util.ArrayList;
+
+/**
+ * @author Robert Schuster
+ */
+class StaticMethodContext extends AbstractCreatableObjectContext
+{
+ private ArrayList arguments = new ArrayList();
+ private Class klass;
+ private String methodName;
+
+ StaticMethodContext(String id, Class newClass, String newMethodName)
+ {
+ setId(id);
+ klass = newClass;
+ methodName = newMethodName;
+ }
+
+ /* (non-Javadoc)
+ * @see gnu.java.beans.decoder.Context#addObject(java.lang.Object)
+ */
+ public void addParameterObjectImpl(Object o)
+ {
+ arguments.add(o);
+ }
+
+ /* (non-Javadoc)
+ * @see gnu.java.beans.decoder.Context#endContext(gnu.java.beans.decoder.Context)
+ */
+ protected Object createObject(Context outerContext)
+ throws AssemblyException
+ {
+ Object[] args = arguments.toArray();
+
+ try
+ {
+ Method method = MethodFinder.getMethod(klass, methodName, args);
+ return method.invoke(null, args);
+ }
+ catch (NoSuchMethodException nsme)
+ {
+ throw new AssemblyException(nsme);
+ }
+ catch (InvocationTargetException ite)
+ {
+ // rethrows the reason for the InvocationTargetsException (ie. the exception in the called code)
+ throw new AssemblyException(ite.getCause());
+ }
+ catch (IllegalAccessException iae)
+ {
+ throw new AssemblyException(iae);
+ }
+ }
+}
diff --git a/libjava/classpath/gnu/java/beans/decoder/StringHandler.java b/libjava/classpath/gnu/java/beans/decoder/StringHandler.java
new file mode 100644
index 00000000000..6f2311a9e62
--- /dev/null
+++ b/libjava/classpath/gnu/java/beans/decoder/StringHandler.java
@@ -0,0 +1,54 @@
+/* gnu.java.beans.decoder.StringHandler
+ Copyright (C) 2004 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, 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.beans.decoder;
+
+class StringHandler extends SimpleHandler
+{
+ /**
+ * @param PersistenceParser
+ */
+ StringHandler(ElementHandler parent)
+ {
+ super(parent);
+ }
+
+ protected Object parse(String characters)
+ {
+ return characters;
+ }
+}
diff --git a/libjava/classpath/gnu/java/beans/decoder/VoidHandler.java b/libjava/classpath/gnu/java/beans/decoder/VoidHandler.java
new file mode 100644
index 00000000000..ca3664bbed1
--- /dev/null
+++ b/libjava/classpath/gnu/java/beans/decoder/VoidHandler.java
@@ -0,0 +1,140 @@
+/* gnu.java.beans.decoder.VoidHandler
+ Copyright (C) 2004 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, 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.beans.decoder;
+
+import java.beans.ExceptionListener;
+
+import org.xml.sax.Attributes;
+
+public class VoidHandler extends AbstractElementHandler
+{
+ /**
+ * @param PersistenceParser
+ */
+ VoidHandler(ElementHandler parent)
+ {
+ super(parent, true);
+ }
+
+ protected Context startElement(
+ Attributes attributes,
+ ExceptionListener exceptionListener)
+ throws AssemblyException
+ {
+ Context ctx = startElementImpl(attributes);
+ ctx.setStatement(true);
+
+ return ctx;
+ }
+
+ private Context startElementImpl(Attributes attributes)
+ throws AssemblyException
+ {
+ String id = attributes.getValue("id");
+ String className = attributes.getValue("class");
+ String methodName = attributes.getValue("method");
+ String propertyName = attributes.getValue("property");
+ String index = attributes.getValue("index");
+
+ if (className != null)
+ {
+ try
+ {
+ Class klass = instantiateClass(className);
+
+ // class name exists which means that we are in a static context.
+ // so we may want to ...
+ // run a constructor if methodName is "new" or null
+ if (methodName == null || methodName.equals("new"))
+ // if the id is null the result cannot be by the decoder accessed but the
+ // constructor may have side effects (e.g. registering itself in a global registry)
+ return new ConstructorContext(id, klass);
+
+ // (falling through is important!)
+ // run a static method on the given class (if methodName exists, which is implied already)
+ return new StaticMethodContext(id, klass, methodName);
+ }
+ catch (ClassNotFoundException cnfe)
+ {
+ throw new AssemblyException(cnfe);
+ }
+ }
+ else
+ {
+ // className does not exist which means we are in the context of
+ // some object and want to ...
+ // access an element by index
+ if (index != null)
+ {
+ // note: whether this resolves into get(i) or set(i, o) depends on the
+ // number of arguments and is decided by the ObjectAssembler
+ try
+ {
+ return new IndexContext(id, Integer.parseInt(index));
+ }
+ catch (NumberFormatException nfe)
+ {
+ throw new AssemblyException(nfe);
+ }
+ }
+
+ // access a method if methodName exists
+ if (methodName != null)
+ return new MethodContext(id, methodName);
+
+ // (falling through is important!)
+ // access a property if a propertyName exists
+ if (propertyName != null && propertyName.length() > 0)
+ // this is reported as an ordinary method invocation where the propertyName is
+ // converted into a 'setter'-method name: convert first character of property name
+ // to upper case and prepend 'set'
+ // Note: This will be a setter-method because the <void> tag implies that no return
+ // value is expected (but a side effect)
+ return new PropertyContext(id, propertyName);
+ }
+
+ // if code reaches this point the tag has wrong attributes. The following test
+ // does not make it better but can provide are more specific error message for
+ // a common mistake: <void> tags are not allowed to have an idref attribute
+ throw new AssemblyException(
+ new IllegalArgumentException(
+ (attributes.getValue("idref") == null)
+ ? "Missing attributes for <void> tag"
+ : "<void> does not support 'idref' attribute."));
+ }
+}
diff --git a/libjava/classpath/gnu/java/beans/decoder/package.html b/libjava/classpath/gnu/java/beans/decoder/package.html
new file mode 100644
index 00000000000..8fe65eeed78
--- /dev/null
+++ b/libjava/classpath/gnu/java/beans/decoder/package.html
@@ -0,0 +1,46 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
+<!-- package.html - describes classes in gnu.java.beans.decoder 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 - gnu.java.beans.decoder</title></head>
+
+<body>
+<p></p>
+
+</body>
+</html>
diff --git a/libjava/classpath/gnu/java/beans/editors/ColorEditor.java b/libjava/classpath/gnu/java/beans/editors/ColorEditor.java
new file mode 100644
index 00000000000..b099eb2f0e9
--- /dev/null
+++ b/libjava/classpath/gnu/java/beans/editors/ColorEditor.java
@@ -0,0 +1,100 @@
+/* gnu.java.beans.editors.ColorEditor
+ Copyright (C) 1998 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, 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.beans.editors;
+
+import java.awt.Color;
+import java.beans.PropertyEditorSupport;
+
+/**
+ ** NativeByteEditor is a property editor for the
+ ** byte type.
+ **
+ ** @author John Keiser
+ ** @version 1.1.0, 29 Jul 1998
+ **/
+
+public class ColorEditor extends PropertyEditorSupport {
+ Color[] stdColors = {Color.black,Color.blue,Color.cyan,
+ Color.darkGray,Color.gray,Color.green,
+ Color.lightGray,Color.magenta,Color.orange,
+ Color.pink,Color.red,Color.white,
+ Color.yellow};
+ String[] stdColorNames = {"black","blue","cyan",
+ "dark gray","gray","green",
+ "light gray","magenta","orange",
+ "pink","red","white",
+ "yellow"};
+
+ /** setAsText for Color checks for standard color names
+ ** and then checks for a #RRGGBB value or just RRGGBB,
+ ** both in hex.
+ **/
+ public void setAsText(String val) throws IllegalArgumentException {
+ if(val.length() == 0) {
+ throw new IllegalArgumentException("Tried to set empty value!");
+ }
+ for(int i=0;i<stdColorNames.length;i++) {
+ if(stdColorNames[i].equalsIgnoreCase(val)) {
+ setValue(stdColors[i]);
+ return;
+ }
+ }
+ if(val.charAt(0) == '#') {
+ setValue(new Color(Integer.parseInt(val.substring(1),16)));
+ } else {
+ setValue(new Color(Integer.parseInt(val,16)));
+ }
+ }
+
+ /** getAsText for Color turns the color into either one of the standard
+ ** colors or into an RGB hex value with # prepended. **/
+ public String getAsText() {
+ for(int i=0;i<stdColors.length;i++) {
+ if(stdColors[i].equals(getValue())) {
+ return stdColorNames[i];
+ }
+ }
+ return "#" + Integer.toHexString(((Color)getValue()).getRGB() & 0x00FFFFFF);
+ }
+
+ /** getTags for Color returns a list of standard colors. **/
+ public String[] getTags() {
+ return stdColorNames;
+ }
+}
diff --git a/libjava/classpath/gnu/java/beans/editors/FontEditor.java b/libjava/classpath/gnu/java/beans/editors/FontEditor.java
new file mode 100644
index 00000000000..904f7bebfbe
--- /dev/null
+++ b/libjava/classpath/gnu/java/beans/editors/FontEditor.java
@@ -0,0 +1,77 @@
+/* gnu.java.beans.editors.FontEditor
+ Copyright (C) 1998 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, 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.beans.editors;
+
+import java.awt.Font;
+import java.beans.PropertyEditorSupport;
+
+/**
+ ** FontEditor is a property editor for java.awt.Font.
+ **
+ ** <STRONG>To Do:</STRONG> Add custom font chooser
+ ** component.
+ **
+ ** @author John Keiser
+ ** @version 1.1.0, 29 Jul 1998
+ **/
+
+public class FontEditor extends PropertyEditorSupport {
+ /** setAsText for Font calls Font.decode(). **/
+ public void setAsText(String val) throws IllegalArgumentException {
+ setValue(Font.decode(val));
+ }
+
+ /** getAsText for Font returns a value in the format
+ ** expected by Font.decode().
+ **/
+ public String getAsText() {
+ Font f = (Font)getValue();
+ if(f.isBold()) {
+ if(f.isItalic()) {
+ return f.getName()+"-bolditalic-"+f.getSize();
+ } else {
+ return f.getName()+"-bold-"+f.getSize();
+ }
+ } else if(f.isItalic()) {
+ return f.getName()+"-italic-"+f.getSize();
+ } else {
+ return f.getName()+"-"+f.getSize();
+ }
+ }
+}
diff --git a/libjava/classpath/gnu/java/beans/editors/NativeBooleanEditor.java b/libjava/classpath/gnu/java/beans/editors/NativeBooleanEditor.java
new file mode 100644
index 00000000000..3620cc1747a
--- /dev/null
+++ b/libjava/classpath/gnu/java/beans/editors/NativeBooleanEditor.java
@@ -0,0 +1,76 @@
+/* gnu.java.beans.editors.NativeBooleanEditor
+ Copyright (C) 1998, 2002 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, 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.beans.editors;
+
+import java.beans.PropertyEditorSupport;
+
+/**
+ ** NativeBooleanEditor is a property editor for the
+ ** boolean type.<P>
+ **
+ ** <STRONG>To Do:</STRONG> add support for a checkbox
+ ** as the custom editor.
+ **
+ ** @author John Keiser
+ ** @version 1.1.0, 29 Jul 1998
+ **/
+
+public class NativeBooleanEditor extends PropertyEditorSupport {
+ String[] tags = {"true","false"};
+
+ /**
+ * setAsText for boolean checks for true or false or t or f.
+ * "" also means false.
+ **/
+ public void setAsText(String val) throws IllegalArgumentException {
+ if(val.equalsIgnoreCase("true") || val.equalsIgnoreCase("t")) {
+ setValue(Boolean.TRUE);
+ } else if(val.equalsIgnoreCase("false") || val.equalsIgnoreCase("f") || val.equals("")) {
+ setValue(Boolean.FALSE);
+ } else {
+ throw new IllegalArgumentException("Value must be true, false, t, f or empty.");
+ }
+ }
+
+
+ /** getAsText for boolean calls Boolean.toString(). **/
+ public String getAsText() {
+ return getValue().toString();
+ }
+}
diff --git a/libjava/classpath/gnu/java/beans/editors/NativeByteEditor.java b/libjava/classpath/gnu/java/beans/editors/NativeByteEditor.java
new file mode 100644
index 00000000000..f3ec5fa1945
--- /dev/null
+++ b/libjava/classpath/gnu/java/beans/editors/NativeByteEditor.java
@@ -0,0 +1,61 @@
+/* gnu.java.beans.editors.NativeByteEditor
+ Copyright (C) 1998 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, 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.beans.editors;
+
+import java.beans.PropertyEditorSupport;
+
+/**
+ ** NativeByteEditor is a property editor for the
+ ** byte type.
+ **
+ ** @author John Keiser
+ ** @version 1.1.0, 29 Jul 1998
+ **/
+
+public class NativeByteEditor extends PropertyEditorSupport {
+ /** setAsText for byte calls Byte.valueOf(). **/
+ public void setAsText(String val) throws IllegalArgumentException {
+ setValue(Byte.valueOf(val));
+ }
+
+ /** getAsText for byte calls Byte.toString(). **/
+ public String getAsText() {
+ return getValue().toString();
+ }
+}
diff --git a/libjava/classpath/gnu/java/beans/editors/NativeDoubleEditor.java b/libjava/classpath/gnu/java/beans/editors/NativeDoubleEditor.java
new file mode 100644
index 00000000000..8d8aae15337
--- /dev/null
+++ b/libjava/classpath/gnu/java/beans/editors/NativeDoubleEditor.java
@@ -0,0 +1,61 @@
+/* gnu.java.beans.editors.NativeDoubleEditor
+ Copyright (C) 1998 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, 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.beans.editors;
+
+import java.beans.PropertyEditorSupport;
+
+/**
+ ** NativeDoubleEditor is a property editor for the
+ ** double type.
+ **
+ ** @author John Keiser
+ ** @version 1.1.0, 29 Jul 1998
+ **/
+
+public class NativeDoubleEditor extends PropertyEditorSupport {
+ /** setAsText for double calls Double.valueOf(). **/
+ public void setAsText(String val) throws IllegalArgumentException {
+ setValue(Double.valueOf(val));
+ }
+
+ /** getAsText for double calls Double.toString(). **/
+ public String getAsText() {
+ return getValue().toString();
+ }
+}
diff --git a/libjava/classpath/gnu/java/beans/editors/NativeFloatEditor.java b/libjava/classpath/gnu/java/beans/editors/NativeFloatEditor.java
new file mode 100644
index 00000000000..801377e7df9
--- /dev/null
+++ b/libjava/classpath/gnu/java/beans/editors/NativeFloatEditor.java
@@ -0,0 +1,61 @@
+/* gnu.java.beans.editors.NativeFloatEditor
+ Copyright (C) 1998 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, 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.beans.editors;
+
+import java.beans.PropertyEditorSupport;
+
+/**
+ ** NativeFloatEditor is a property editor for the
+ ** float type.
+ **
+ ** @author John Keiser
+ ** @version 1.1.0, 29 Jul 1998
+ **/
+
+public class NativeFloatEditor extends PropertyEditorSupport {
+ /** setAsText for float calls Float.valueOf(). **/
+ public void setAsText(String val) throws IllegalArgumentException {
+ setValue(Float.valueOf(val));
+ }
+
+ /** getAsText for float calls Float.toString(). **/
+ public String getAsText() {
+ return getValue().toString();
+ }
+}
diff --git a/libjava/classpath/gnu/java/beans/editors/NativeIntEditor.java b/libjava/classpath/gnu/java/beans/editors/NativeIntEditor.java
new file mode 100644
index 00000000000..a6148841c46
--- /dev/null
+++ b/libjava/classpath/gnu/java/beans/editors/NativeIntEditor.java
@@ -0,0 +1,61 @@
+/* gnu.java.beans.editors.NativeIntEditor
+ Copyright (C) 1998 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, 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.beans.editors;
+
+import java.beans.PropertyEditorSupport;
+
+/**
+ ** NativeIntEditor is a property editor for the
+ ** int type.
+ **
+ ** @author John Keiser
+ ** @version 1.1.0, 29 Jul 1998
+ **/
+
+public class NativeIntEditor extends PropertyEditorSupport {
+ /** setAsText for int calls Integer.valueOf(). **/
+ public void setAsText(String val) throws IllegalArgumentException {
+ setValue(Integer.valueOf(val));
+ }
+
+ /** getAsText for int calls Integer.toString(). **/
+ public String getAsText() {
+ return getValue().toString();
+ }
+}
diff --git a/libjava/classpath/gnu/java/beans/editors/NativeLongEditor.java b/libjava/classpath/gnu/java/beans/editors/NativeLongEditor.java
new file mode 100644
index 00000000000..95e9dc87028
--- /dev/null
+++ b/libjava/classpath/gnu/java/beans/editors/NativeLongEditor.java
@@ -0,0 +1,61 @@
+/* gnu.java.beans.editors.NativeLongEditor
+ Copyright (C) 1998 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, 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.beans.editors;
+
+import java.beans.PropertyEditorSupport;
+
+/**
+ ** NativeLongEditor is a property editor for the
+ ** long type.
+ **
+ ** @author John Keiser
+ ** @version 1.1.0, 29 Jul 1998
+ **/
+
+public class NativeLongEditor extends PropertyEditorSupport {
+ /** setAsText for long calls Long.valueOf(). **/
+ public void setAsText(String val) throws IllegalArgumentException {
+ setValue(Long.valueOf(val));
+ }
+
+ /** getAsText for long calls Long.toString(). **/
+ public String getAsText() {
+ return getValue().toString();
+ }
+}
diff --git a/libjava/classpath/gnu/java/beans/editors/NativeShortEditor.java b/libjava/classpath/gnu/java/beans/editors/NativeShortEditor.java
new file mode 100644
index 00000000000..ffaa266492e
--- /dev/null
+++ b/libjava/classpath/gnu/java/beans/editors/NativeShortEditor.java
@@ -0,0 +1,61 @@
+/* gnu.java.beans.editors.NativeShortEditor
+ Copyright (C) 1998 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, 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.beans.editors;
+
+import java.beans.PropertyEditorSupport;
+
+/**
+ ** NativeShortEditor is a property editor for the
+ ** short type.
+ **
+ ** @author John Keiser
+ ** @version 1.1.0, 29 Jul 1998
+ **/
+
+public class NativeShortEditor extends PropertyEditorSupport {
+ /** setAsText for short calls Short.valueOf(). **/
+ public void setAsText(String val) throws IllegalArgumentException {
+ setValue(Short.valueOf(val));
+ }
+
+ /** getAsText for short calls Short.toString(). **/
+ public String getAsText() {
+ return getValue().toString();
+ }
+}
diff --git a/libjava/classpath/gnu/java/beans/editors/StringEditor.java b/libjava/classpath/gnu/java/beans/editors/StringEditor.java
new file mode 100644
index 00000000000..8242d5475a5
--- /dev/null
+++ b/libjava/classpath/gnu/java/beans/editors/StringEditor.java
@@ -0,0 +1,61 @@
+/* gnu.java.beans.editors.StringEditor
+ Copyright (C) 1998 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, 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.beans.editors;
+
+import java.beans.PropertyEditorSupport;
+
+/**
+ ** NativeByteEditor is a property editor for the
+ ** byte type.
+ **
+ ** @author John Keiser
+ ** @version 1.1.0, 29 Jul 1998
+ **/
+
+public class StringEditor extends PropertyEditorSupport {
+ /** setAsText just sets the value. **/
+ public void setAsText(String val) throws IllegalArgumentException {
+ setValue(val);
+ }
+
+ /** getAsText just returns the value. **/
+ public String getAsText() {
+ return (String)getValue();
+ }
+}
diff --git a/libjava/classpath/gnu/java/beans/editors/TODO b/libjava/classpath/gnu/java/beans/editors/TODO
new file mode 100644
index 00000000000..6877f4caf4b
--- /dev/null
+++ b/libjava/classpath/gnu/java/beans/editors/TODO
@@ -0,0 +1,4 @@
+- write tests for all editors
+- add some sort of ColorChooser as a custom editor for ColorEditor
+- add a FileNameEditor
+- add a FontChooser as a custom editor for FontEditor
diff --git a/libjava/classpath/gnu/java/beans/editors/package.html b/libjava/classpath/gnu/java/beans/editors/package.html
new file mode 100644
index 00000000000..465f68d174d
--- /dev/null
+++ b/libjava/classpath/gnu/java/beans/editors/package.html
@@ -0,0 +1,46 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
+<!-- package.html - describes classes in gnu.java.beans.editors 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 - gnu.java.beans.editors</title></head>
+
+<body>
+<p></p>
+
+</body>
+</html>
diff --git a/libjava/classpath/gnu/java/beans/package.html b/libjava/classpath/gnu/java/beans/package.html
new file mode 100644
index 00000000000..f3b0526834c
--- /dev/null
+++ b/libjava/classpath/gnu/java/beans/package.html
@@ -0,0 +1,46 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
+<!-- package.html - describes classes in gnu.java.beans 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 - gnu.java.beans</title></head>
+
+<body>
+<p></p>
+
+</body>
+</html>