[kaffe] CVS kaffe (dalibor): Merged in more of java.beans from GNU Classpath

Kaffe CVS cvs-commits at kaffe.org
Tue Oct 14 17:24:02 PDT 2003


PatchSet 4110 
Date: 2003/10/15 00:13:05
Author: dalibor
Branch: HEAD
Tag: (none) 
Log:
Merged in more of java.beans from GNU Classpath

Members: 
	ChangeLog:1.1704->1.1705 
	libraries/javalib/gnu/java/beans/BeanInfoEmbryo.java:INITIAL->1.1 
	libraries/javalib/gnu/java/beans/ExplicitBeanInfo.java:INITIAL->1.1 
	libraries/javalib/gnu/java/beans/IntrospectionIncubator.java:INITIAL->1.1 
	libraries/javalib/gnu/java/beans/editors/ColorEditor.java:INITIAL->1.1 
	libraries/javalib/gnu/java/beans/editors/FontEditor.java:INITIAL->1.1 
	libraries/javalib/gnu/java/beans/editors/NativeBooleanEditor.java:INITIAL->1.1 
	libraries/javalib/gnu/java/beans/editors/NativeByteEditor.java:INITIAL->1.1 
	libraries/javalib/gnu/java/beans/editors/NativeDoubleEditor.java:INITIAL->1.1 
	libraries/javalib/gnu/java/beans/editors/NativeFloatEditor.java:INITIAL->1.1 
	libraries/javalib/gnu/java/beans/editors/NativeIntEditor.java:INITIAL->1.1 
	libraries/javalib/gnu/java/beans/editors/NativeLongEditor.java:INITIAL->1.1 
	libraries/javalib/gnu/java/beans/editors/NativeShortEditor.java:INITIAL->1.1 
	libraries/javalib/gnu/java/beans/editors/StringEditor.java:INITIAL->1.1 
	libraries/javalib/java/beans/IndexedPropertyDescriptor.java:1.4->1.5 
	libraries/javalib/java/beans/ParameterDescriptor.java:1.1->1.2 
	libraries/javalib/java/beans/PropertyChangeEvent.java:1.4->1.5 
	libraries/javalib/java/beans/PropertyChangeSupport.java:1.7->1.8 
	libraries/javalib/java/beans/PropertyEditorManager.java:1.2->1.3 
	libraries/javalib/java/beans/PropertyEditorSupport.java:1.1->1.2 
	libraries/javalib/java/beans/SimpleBeanInfo.java:1.3->1.4 
	libraries/javalib/java/beans/VetoableChangeSupport.java:1.3->1.4 
	libraries/javalib/profiles/allatonce/all.files:1.23->1.24 
	libraries/javalib/profiles/default/rest.files:1.6->1.7 
	test/regression/Bean.java:1.3->1.4 

Index: kaffe/ChangeLog
diff -u kaffe/ChangeLog:1.1704 kaffe/ChangeLog:1.1705
--- kaffe/ChangeLog:1.1704	Mon Oct 13 03:10:02 2003
+++ kaffe/ChangeLog	Wed Oct 15 00:13:05 2003
@@ -1,3 +1,40 @@
+2003-10-09 Milos Negovanovic <milosn at bmf.bounceme.net>
+
+        * libraries/javalib/gnu/java/beans/BeanInfoEmbryo.java,
+        libraries/javalib/gnu/java/beans/ExplicitBeanInfo.java,
+        libraries/javalib/gnu/java/beans/IntrospectionIncubator.java,
+        libraries/javalib/gnu/java/beans/editors/ColorEditor.java,
+        libraries/javalib/gnu/java/beans/editors/FontEditor.java,
+        libraries/javalib/gnu/java/beans/editors/NativeBooleanEditor.java,
+        libraries/javalib/gnu/java/beans/editors/NativeByteEditor.java,
+        libraries/javalib/gnu/java/beans/editors/NativeDoubleEditor.java,
+        libraries/javalib/gnu/java/beans/editors/NativeFloatEditor.java,
+        libraries/javalib/gnu/java/beans/editors/NativeIntEditor.java,
+        libraries/javalib/gnu/java/beans/editors/NativeLongEditor.java,
+        libraries/javalib/gnu/java/beans/editors/NativeShortEditor.java,
+        libraries/javalib/gnu/java/beans/editors/StringEditor.java:
+	New classes from GNU Classpath.
+
+        * libraries/javalib/java/beans/IndexedPropertyDescriptor.java:
+	Replaced with GNU Classpath class.
+	(IndexedPropertyDescriptor) Fixed a typo.
+
+        * libraries/javalib/java/beans/ParameterDescriptor.java,
+        libraries/javalib/java/beans/PropertyChangeEvent.java,
+        libraries/javalib/java/beans/PropertyChangeSupport.java,
+        libraries/javalib/java/beans/PropertyEditorManager.java,
+        libraries/javalib/java/beans/PropertyEditorSupport.java,
+        libraries/javalib/java/beans/SimpleBeanInfo.java,
+        libraries/javalib/java/beans/VetoableChangeSupport.java:
+	Replaced with stuff from GNU Classpath.
+
+        * libraries/javalib/profiles/allatonce/all.files,
+        libraries/javalib/profiles/default/rest.files:
+	Added the new classes from GNU Classpath.
+
+        * test/regression/Bean.java:
+	Fixed regression test for new string editor class name.
+
 2003-10-12  Jim Pick  <jim at kaffe.org>
 
 	* libraries/javalib/java/util/regex/Matcher.java,
===================================================================
Checking out kaffe/libraries/javalib/gnu/java/beans/BeanInfoEmbryo.java
RCS:  /home/cvs/kaffe/kaffe/libraries/javalib/gnu/java/beans/BeanInfoEmbryo.java,v
VERS: 1.1
***************
--- /dev/null	Sun Aug  4 19:57:58 2002
+++ kaffe/libraries/javalib/gnu/java/beans/BeanInfoEmbryo.java	Wed Oct 15 00:15:40 2003
@@ -0,0 +1,165 @@
+/*
+ *
+ * Imported from GNU Classpath by M.Negovanovic
+ *
+ */
+
+
+/* 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., 59 Temple Place, Suite 330, Boston, MA
+02111-1307 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library.  Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module.  An independent module is a module which is not derived from
+or based on this library.  If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so.  If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package gnu.java.beans;
+
+import java.beans.*;
+import java.util.*;
+import gnu.java.lang.*;
+import java.lang.reflect.*;
+
+/**
+ ** 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 {
+	Hashtable properties = new Hashtable();
+	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;
+		Enumeration enum = properties.elements();
+		while(enum.hasMoreElements()) {
+			Aproperties[i] = (PropertyDescriptor)enum.nextElement();
+			if(defaultPropertyName != null && Aproperties[i].getName().equals(defaultPropertyName)) {
+				defaultProperty = i;
+			}
+			i++;
+		}
+
+		EventSetDescriptor[] Aevents = new EventSetDescriptor[events.size()];
+		i = 0;
+		enum = events.elements();
+		while(enum.hasMoreElements()) {
+			Aevents[i] = (EventSetDescriptor)enum.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;
+	}
+}
===================================================================
Checking out kaffe/libraries/javalib/gnu/java/beans/ExplicitBeanInfo.java
RCS:  /home/cvs/kaffe/kaffe/libraries/javalib/gnu/java/beans/ExplicitBeanInfo.java,v
VERS: 1.1
***************
--- /dev/null	Sun Aug  4 19:57:58 2002
+++ kaffe/libraries/javalib/gnu/java/beans/ExplicitBeanInfo.java	Wed Oct 15 00:15:40 2003
@@ -0,0 +1,151 @@
+/*
+ *
+ * Imported from GNU Classpath by M.Negovanovic
+ *
+ */
+
+
+/* gnu.java.beans.ExplicitBeanInfo
+   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., 59 Temple Place, Suite 330, Boston, MA
+02111-1307 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library.  Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module.  An independent module is a module which is not derived from
+or based on this library.  If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so.  If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package gnu.java.beans;
+
+import java.beans.*;
+
+/**
+ ** 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 java.awt.Image[] icons;
+
+	public ExplicitBeanInfo(BeanDescriptor beanDescriptor,
+	                        BeanInfo[] additionalBeanInfo,
+	                        PropertyDescriptor[] propertyDescriptors,
+				int defaultPropertyIndex,
+	                        EventSetDescriptor[] eventSetDescriptors,
+				int defaultEventIndex,
+	                        MethodDescriptor[] methodDescriptors,
+				java.awt.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 java.awt.Image getIcon(int iconType) {
+		return icons != null ? icons[iconType] : null;
+	}
+}
===================================================================
Checking out kaffe/libraries/javalib/gnu/java/beans/IntrospectionIncubator.java
RCS:  /home/cvs/kaffe/kaffe/libraries/javalib/gnu/java/beans/IntrospectionIncubator.java,v
VERS: 1.1
***************
--- /dev/null	Sun Aug  4 19:57:58 2002
+++ kaffe/libraries/javalib/gnu/java/beans/IntrospectionIncubator.java	Wed Oct 15 00:15:40 2003
@@ -0,0 +1,362 @@
+/*
+ *
+ * Imported from GNU Classpath by M.Negovanovic
+ *
+ */
+
+
+/* gnu.java.beans.IntrospectionIncubator
+   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., 59 Temple Place, Suite 330, Boston, MA
+02111-1307 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library.  Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module.  An independent module is a module which is not derived from
+or based on this library.  If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so.  If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package gnu.java.beans;
+
+import java.beans.*;
+import java.util.*;
+import java.lang.reflect.*;
+import gnu.java.lang.*;
+
+/**
+ ** IntrospectionIncubator takes in a bunch of Methods, and
+ ** Introspects only those Methods you give it.
+ **
+ ** @author John Keiser
+ ** @version 1.1.0, 30 Jul 1998
+ ** @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() {
+	}
+
+	/* Paving the way for automatic Introspection */
+	public void addMethod(Method method) {
+		if(Modifier.isPublic(method.getModifiers()) && !Modifier.isStatic(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();
+			if(propertyStopClass == null || (propertyStopClass.isAssignableFrom(methodClass) && !propertyStopClass.equals(methodClass))) {
+				if(name.startsWith("is")
+				   && retType.equals(java.lang.Boolean.TYPE)
+				   && params.length == 0) {
+					addToPropertyHash(name,method,IS);
+				} else if(name.startsWith("get") && !isVoid) {
+					if(params.length == 0) {
+						addToPropertyHash(name,method,GET);
+					} else if(params.length == 1 && params[0].equals(java.lang.Integer.TYPE)) {
+						addToPropertyHash(name,method,GET_I);
+					} else {
+						otherMethods.addElement(method);
+					}
+				} else if(name.startsWith("set") && isVoid) {
+					if(params.length == 1) {
+						addToPropertyHash(name,method,SET);
+					} else if(params.length == 2 && params[0].equals(java.lang.Integer.TYPE)) {
+						addToPropertyHash(name,method,SET_I);
+					} else {
+						otherMethods.addElement(method);
+					}
+				}
+			}
+			if(eventStopClass == null || (eventStopClass.isAssignableFrom(methodClass) && !eventStopClass.equals(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(methodStopClass == null || (methodStopClass.isAssignableFrom(methodClass) && !methodStopClass.equals(methodClass))) {
+				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);
+
+		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);
+
+		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;
+	}
+
+	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;
+		}
+	}
+}
+
+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();
+	}
+}
===================================================================
Checking out kaffe/libraries/javalib/gnu/java/beans/editors/ColorEditor.java
RCS:  /home/cvs/kaffe/kaffe/libraries/javalib/gnu/java/beans/editors/ColorEditor.java,v
VERS: 1.1
***************
--- /dev/null	Sun Aug  4 19:57:58 2002
+++ kaffe/libraries/javalib/gnu/java/beans/editors/ColorEditor.java	Wed Oct 15 00:15:40 2003
@@ -0,0 +1,107 @@
+/*
+ *
+ * Imported from GNU Classpath by M.Negovanovic
+ *
+ */
+
+
+/* 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., 59 Temple Place, Suite 330, Boston, MA
+02111-1307 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library.  Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module.  An independent module is a module which is not derived from
+or based on this library.  If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so.  If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package gnu.java.beans.editors;
+
+import java.beans.*;
+import java.awt.Color;
+
+/**
+ ** 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;
+	}
+}
===================================================================
Checking out kaffe/libraries/javalib/gnu/java/beans/editors/FontEditor.java
RCS:  /home/cvs/kaffe/kaffe/libraries/javalib/gnu/java/beans/editors/FontEditor.java,v
VERS: 1.1
***************
--- /dev/null	Sun Aug  4 19:57:58 2002
+++ kaffe/libraries/javalib/gnu/java/beans/editors/FontEditor.java	Wed Oct 15 00:15:40 2003
@@ -0,0 +1,84 @@
+/*
+ *
+ * Imported from GNU Classpath by M.Negovanovic
+ *
+ */
+
+
+/* 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., 59 Temple Place, Suite 330, Boston, MA
+02111-1307 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library.  Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module.  An independent module is a module which is not derived from
+or based on this library.  If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so.  If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package gnu.java.beans.editors;
+
+import java.beans.*;
+import java.awt.Font;
+
+/**
+ ** 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();
+		}
+	}
+}
===================================================================
Checking out kaffe/libraries/javalib/gnu/java/beans/editors/NativeBooleanEditor.java
RCS:  /home/cvs/kaffe/kaffe/libraries/javalib/gnu/java/beans/editors/NativeBooleanEditor.java,v
VERS: 1.1
***************
--- /dev/null	Sun Aug  4 19:57:58 2002
+++ kaffe/libraries/javalib/gnu/java/beans/editors/NativeBooleanEditor.java	Wed Oct 15 00:15:40 2003
@@ -0,0 +1,83 @@
+/*
+ *
+ * Imported from GNU Classpath by M.Negovanovic

*** Patch too long, truncated ***




More information about the kaffe mailing list