diff options
Diffstat (limited to 'java/beans')
46 files changed, 2231 insertions, 2233 deletions
diff --git a/java/beans/AppletInitializer.java b/java/beans/AppletInitializer.java index 69dc2cae5..3bc2534e1 100644 --- a/java/beans/AppletInitializer.java +++ b/java/beans/AppletInitializer.java @@ -7,7 +7,7 @@ GNU Classpath is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2, or (at your option) any later version. - + GNU Classpath is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU diff --git a/java/beans/BeanDescriptor.java b/java/beans/BeanDescriptor.java index b4bc6870d..6795d91b3 100644 --- a/java/beans/BeanDescriptor.java +++ b/java/beans/BeanDescriptor.java @@ -7,7 +7,7 @@ GNU Classpath is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2, or (at your option) any later version. - + GNU Classpath is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU @@ -48,42 +48,42 @@ package java.beans; **/ public class BeanDescriptor extends FeatureDescriptor { - Class<?> beanClass; - Class<?> customizerClass; - - /** Create a new BeanDescriptor with the given beanClass and - ** no customizer class. - ** @param beanClass the class of the Bean. - **/ - public BeanDescriptor(Class<?> beanClass) { - this(beanClass,null); - } - - /** Create a new BeanDescriptor with the given bean class and - ** customizer class. - ** @param beanClass the class of the Bean. - ** @param customizerClass the class of the Bean's Customizer. - **/ - public BeanDescriptor(Class<?> beanClass, Class<?> customizerClass) { - this.beanClass = beanClass; - this.customizerClass = customizerClass; - - // Set the FeatureDescriptor programmatic name. - String name = beanClass.getName(); - int lastInd = name.lastIndexOf('.'); - if (lastInd != -1) - name = name.substring(lastInd + 1); - - setName(name); - } - - /** Get the Bean's class. **/ - public Class<?> getBeanClass() { - return beanClass; - } - - /** Get the Bean's customizer's class. **/ - public Class<?> getCustomizerClass() { - return customizerClass; - } + Class<?> beanClass; + Class<?> customizerClass; + + /** Create a new BeanDescriptor with the given beanClass and + ** no customizer class. + ** @param beanClass the class of the Bean. + **/ + public BeanDescriptor(Class<?> beanClass) { + this(beanClass,null); + } + + /** Create a new BeanDescriptor with the given bean class and + ** customizer class. + ** @param beanClass the class of the Bean. + ** @param customizerClass the class of the Bean's Customizer. + **/ + public BeanDescriptor(Class<?> beanClass, Class<?> customizerClass) { + this.beanClass = beanClass; + this.customizerClass = customizerClass; + + // Set the FeatureDescriptor programmatic name. + String name = beanClass.getName(); + int lastInd = name.lastIndexOf('.'); + if (lastInd != -1) + name = name.substring(lastInd + 1); + + setName(name); + } + + /** Get the Bean's class. **/ + public Class<?> getBeanClass() { + return beanClass; + } + + /** Get the Bean's customizer's class. **/ + public Class<?> getCustomizerClass() { + return customizerClass; + } } diff --git a/java/beans/BeanInfo.java b/java/beans/BeanInfo.java index 525500a38..3c9bf1bcd 100644 --- a/java/beans/BeanInfo.java +++ b/java/beans/BeanInfo.java @@ -7,7 +7,7 @@ GNU Classpath is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2, or (at your option) any later version. - + GNU Classpath is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU @@ -73,109 +73,109 @@ package java.beans; **/ public interface BeanInfo { - /** Use this as a parameter for the getIcon() command to retrieve a certain type of icon. **/ - int ICON_COLOR_16x16 = 1; - /** Use this as a parameter for the getIcon() command to retrieve a certain type of icon. **/ - int ICON_COLOR_32x32 = 2; - /** Use this as a parameter for the getIcon() command to retrieve a certain type of icon. **/ - int ICON_MONO_16x16 = 3; - /** Use this as a parameter for the getIcon() command to retrieve a certain type of icon. **/ - int ICON_MONO_32x32 = 4; - - /** Get the general description of this Bean type. - ** @return the BeanDescriptor for the Bean, or null if - ** the BeanDescriptor should be obtained by - ** Introspection. - **/ - BeanDescriptor getBeanDescriptor(); - - /** Get the events this Bean type fires. - ** @return the EventDescriptors representing events this - ** Bean fires. Returns <CODE>null</CODE> if the - ** events are to be acquired by Introspection. - **/ - EventSetDescriptor[] getEventSetDescriptors(); - - /** Get the "default" event, basically the one a RAD tool - ** user is most likely to select. - ** @return the index into the getEventSetDescriptors() - ** that the user is most likely to use. Returns - ** <CODE>-1</CODE> if there is no default event. - **/ - int getDefaultEventIndex(); - - /** Get the properties (get/set method pairs) this Bean - ** type supports. - ** @return the PropertyDescriptors representing the - ** properties this Bean type supports. - ** Returns <CODE>null</CODE> if the properties - ** are to be obtained by Introspection. - **/ - PropertyDescriptor[] getPropertyDescriptors(); - - /** Get the "default" property, basically the one a RAD - ** tool user is most likely to select. - ** @return the index into the getPropertyDescriptors() - ** that the user is most likely to use. Returns - ** <CODE>-1</CODE> if there is no default event. - **/ - int getDefaultPropertyIndex(); - - /** Get the methods this Bean type supports. - ** @return the MethodDescriptors representing the - ** methods this Bean type supports. Returns - ** <CODE>null</CODE> if the methods are to be - ** obtained by Introspection. - **/ - MethodDescriptor[] getMethodDescriptors(); - - /** Get additional BeanInfos representing this Bean. - ** In this version of JavaBeans, this method is used so - ** that space and time can be saved by reading a BeanInfo - ** for each class in the hierarchy (super, super(super), - ** and so on).<P> - ** - ** The order of precedence when two pieces of BeanInfo - ** conflict (such as two PropertyDescriptors that have - ** the same name), in order from highest precedence to - ** lowest, is: - ** <OL> - ** <LI>This BeanInfo object.</LI> - ** <LI><CODE>getAdditionalBeanInfo()[getAdditionalBeanInfo().length]</CODE></LI> - ** <LI> ... </LI> - ** <LI><CODE>getAdditionalBeanInfo()[1]</CODE></LI> - ** <LI><CODE>getAdditionalBeanInfo()[0]</CODE></LI> - ** </OL><P> - ** - ** <STRONG>Spec Note:</STRONG> It is possible that - ** returning <CODE>null</CODE> from this method could - ** stop Introspection in its tracks, but it is unclear - ** from the spec whether this is the case. - ** - ** @return additional BeanInfos representing this Bean. - ** <CODE>null</CODE> may be returned (see Spec - ** Note, above). - **/ - BeanInfo[] getAdditionalBeanInfo(); - - /** Get a visual icon for this Bean. - ** A Bean does not have to support icons, and if it does - ** support icons, it does not have to support every single - ** type. Sun recommends that if you only support one - ** type, you support 16x16 color. Sun also notes that you - ** should try to use a type (like GIF) that allows for - ** transparent pixels, so that the background of the RAD - ** tool can show through.<P> - ** - ** <STRONG>Spec Note:</STRONG> If you do not support the - ** type of icon that is being asked for, but you do - ** support another type, it is unclear whether you should - ** return the other type or not. I would presume not. - ** - ** @param iconType the type of icon to get (see the - ** ICON_* constants in this class). - ** @return the icon, or null if that type of icon is - ** unsupported by this Bean. - **/ - java.awt.Image getIcon(int iconType); + /** Use this as a parameter for the getIcon() command to retrieve a certain type of icon. **/ + int ICON_COLOR_16x16 = 1; + /** Use this as a parameter for the getIcon() command to retrieve a certain type of icon. **/ + int ICON_COLOR_32x32 = 2; + /** Use this as a parameter for the getIcon() command to retrieve a certain type of icon. **/ + int ICON_MONO_16x16 = 3; + /** Use this as a parameter for the getIcon() command to retrieve a certain type of icon. **/ + int ICON_MONO_32x32 = 4; + + /** Get the general description of this Bean type. + ** @return the BeanDescriptor for the Bean, or null if + ** the BeanDescriptor should be obtained by + ** Introspection. + **/ + BeanDescriptor getBeanDescriptor(); + + /** Get the events this Bean type fires. + ** @return the EventDescriptors representing events this + ** Bean fires. Returns <CODE>null</CODE> if the + ** events are to be acquired by Introspection. + **/ + EventSetDescriptor[] getEventSetDescriptors(); + + /** Get the "default" event, basically the one a RAD tool + ** user is most likely to select. + ** @return the index into the getEventSetDescriptors() + ** that the user is most likely to use. Returns + ** <CODE>-1</CODE> if there is no default event. + **/ + int getDefaultEventIndex(); + + /** Get the properties (get/set method pairs) this Bean + ** type supports. + ** @return the PropertyDescriptors representing the + ** properties this Bean type supports. + ** Returns <CODE>null</CODE> if the properties + ** are to be obtained by Introspection. + **/ + PropertyDescriptor[] getPropertyDescriptors(); + + /** Get the "default" property, basically the one a RAD + ** tool user is most likely to select. + ** @return the index into the getPropertyDescriptors() + ** that the user is most likely to use. Returns + ** <CODE>-1</CODE> if there is no default event. + **/ + int getDefaultPropertyIndex(); + + /** Get the methods this Bean type supports. + ** @return the MethodDescriptors representing the + ** methods this Bean type supports. Returns + ** <CODE>null</CODE> if the methods are to be + ** obtained by Introspection. + **/ + MethodDescriptor[] getMethodDescriptors(); + + /** Get additional BeanInfos representing this Bean. + ** In this version of JavaBeans, this method is used so + ** that space and time can be saved by reading a BeanInfo + ** for each class in the hierarchy (super, super(super), + ** and so on).<P> + ** + ** The order of precedence when two pieces of BeanInfo + ** conflict (such as two PropertyDescriptors that have + ** the same name), in order from highest precedence to + ** lowest, is: + ** <OL> + ** <LI>This BeanInfo object.</LI> + ** <LI><CODE>getAdditionalBeanInfo()[getAdditionalBeanInfo().length]</CODE></LI> + ** <LI> ... </LI> + ** <LI><CODE>getAdditionalBeanInfo()[1]</CODE></LI> + ** <LI><CODE>getAdditionalBeanInfo()[0]</CODE></LI> + ** </OL><P> + ** + ** <STRONG>Spec Note:</STRONG> It is possible that + ** returning <CODE>null</CODE> from this method could + ** stop Introspection in its tracks, but it is unclear + ** from the spec whether this is the case. + ** + ** @return additional BeanInfos representing this Bean. + ** <CODE>null</CODE> may be returned (see Spec + ** Note, above). + **/ + BeanInfo[] getAdditionalBeanInfo(); + + /** Get a visual icon for this Bean. + ** A Bean does not have to support icons, and if it does + ** support icons, it does not have to support every single + ** type. Sun recommends that if you only support one + ** type, you support 16x16 color. Sun also notes that you + ** should try to use a type (like GIF) that allows for + ** transparent pixels, so that the background of the RAD + ** tool can show through.<P> + ** + ** <STRONG>Spec Note:</STRONG> If you do not support the + ** type of icon that is being asked for, but you do + ** support another type, it is unclear whether you should + ** return the other type or not. I would presume not. + ** + ** @param iconType the type of icon to get (see the + ** ICON_* constants in this class). + ** @return the icon, or null if that type of icon is + ** unsupported by this Bean. + **/ + java.awt.Image getIcon(int iconType); } diff --git a/java/beans/Beans.java b/java/beans/Beans.java index 2f6e0a991..3066be7a5 100644 --- a/java/beans/Beans.java +++ b/java/beans/Beans.java @@ -7,7 +7,7 @@ GNU Classpath is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2, or (at your option) any later version. - + GNU Classpath is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU @@ -52,7 +52,7 @@ import java.net.URL; * * @author John Keiser * @author Robert Schuster - * + * * @since 1.1 * @status updated to 1.4 * @@ -74,13 +74,13 @@ public class Beans /** Creates a bean. * <p>This is a convenience method that calls <code>instantiate(cl, beanName, null, null)</code>.</p> - * + * * @see instantiate(ClassLoader, String, BeanContext, AppletInitializer) * @param cl ClassLoader to be used or <code>null</code> for the system classloader. * @param beanName Name of a serialized bean or class name. * @return A newly created bean. * @throws IOException If access of an IO resource failed. - * @throws ClassNotFoundException If the class name is not known or does not lead to a proper bean class. + * @throws ClassNotFoundException If the class name is not known or does not lead to a proper bean class. */ public static Object instantiate(ClassLoader cl, String beanName) throws IOException, ClassNotFoundException @@ -89,16 +89,16 @@ public class Beans } /** Creates a bean. - * + * * <p>This is a convenience method that calls <code>instantiate(cl, beanName, beanContext, null)</code>.</p> - * + * * @see instantiate(ClassLoader, String, BeanContext, AppletInitializer) * @param cl ClassLoader to be used or <code>null</code> for the system classloader. * @param beanName Name of a serialized bean or class name. * @param beanContext Context to which the newly created Bean should be added. * @return A newly created bean. * @throws IOException If access of an IO resource failed. - * @throws ClassNotFoundException If the class name is not known or does not lead to a proper bean class. + * @throws ClassNotFoundException If the class name is not known or does not lead to a proper bean class. */ public static Object instantiate( ClassLoader cl, @@ -110,38 +110,38 @@ public class Beans } /** Instantiates a bean according to Beans 1.0. - * + * * <p>In Beans 1.0 the instantiation scheme is as follows:</p> * <p>The name should be dot-separated (e.g "place.for.beans.myBean") and indicate either a * serialized object or a class name. In the first case all dots in the name are replaced with * slashes ('/') and ".ser" is appended ("place.for.beans.myBean" becomes "place/for/beans/myBean.ser"). * The bean is then loaded as an application or system resource depending on whether a * <code>ClassLoader</code> was provided.</p> - * + * * <p>If no such resource exists or if it contains no bean the name is interpreted as a class name of * which an instance is then created.</p> - * + * * <p>If a <code>BeanContext</code> instance is available the created bean is added to it.</p> - * + * * <p>If the created Bean is an <code>Applet</code> or subclass and an <code>AppletInitializer</code> * instance is available the applet is initialized and afterwards activated using the initializer. Additionally * every instantiated <code>Applet</code> bean is initialized using the {@link Applet.init} method. * Furthermore every applet gets a default <code>AppletStub</code>. The <code>Applet</code>'s * document base is the location of the ".ser" file if it was deserialized or the location of its class * file if it was instantiated.</p> - * + * * <p>A <code>ClassNotFoundException</code> is not only thrown when a class name was unknown * but even when the class has public no-argument constructor * (<code>IllegalAccessException</code> is wrapped) or an exception is thrown while * invoking such a constructor (causing exception is wrapped).</p> - * + * * @param cl ClassLoader to be used or <code>null</code> for the system classloader. * @param beanName Name of a serialized bean or class name. * @param beanContext Context to which the newly created Bean should be added. * @param initializer The AppletInitializer which is used for initializing <code>Applet</code> beans. * @return A newly created bean. * @throws IOException If access of an IO resource failed. - * @throws ClassNotFoundException If the class name is not known or does not lead to a proper bean class. + * @throws ClassNotFoundException If the class name is not known or does not lead to a proper bean class. */ public static Object instantiate( ClassLoader cl, @@ -154,12 +154,12 @@ public class Beans URL beanLocation = null; URL classLocation = null; - // Converts bean name into a resource name (eg. "a.b.c" -> "a/b/c"). + // Converts bean name into a resource name (eg. "a.b.c" -> "a/b/c"). String resourceName = beanName.replace('.', '/'); /* Tries to get an input stream of the Bean, reading it as a system resource * if no ClassLoader is present or as an application resource if a classloader - * is given. + * is given. */ beanLocation = (cl == null) @@ -211,10 +211,10 @@ public class Beans bean = beanClass.newInstance(); } catch(Exception e) { - /* Wraps all kinds of Exceptions in a ClassNotFoundException (this behavior - * matches with official >= 1.5, this was different for <=1.4) - */ - throw new ClassNotFoundException(null, e); + /* Wraps all kinds of Exceptions in a ClassNotFoundException (this behavior + * matches with official >= 1.5, this was different for <=1.4) + */ + throw new ClassNotFoundException(null, e); } } @@ -224,8 +224,8 @@ public class Beans * - as every other Bean Applets are added to a BeanContext if one is available * - each instantiated Applet is initialized using Applet.init() (this is not done for deserialized ones) * - finally AppletS get activated using the AppletInitializerS activate-Method - * - * The order of operations is important for compatibility. + * + * The order of operations is important for compatibility. */ Applet applet = null; if (bean instanceof Applet) @@ -344,7 +344,7 @@ public class Beans /** * Sets whether the GUI is available to use. - * + * * @param guiAvailable whether the GUI is available to use. */ public static void setGuiAvailable(boolean guiAvailable) diff --git a/java/beans/Customizer.java b/java/beans/Customizer.java index b36c89f88..bb6b4e2dd 100644 --- a/java/beans/Customizer.java +++ b/java/beans/Customizer.java @@ -7,7 +7,7 @@ GNU Classpath is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2, or (at your option) any later version. - + GNU Classpath is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU @@ -67,20 +67,20 @@ package java.beans; **/ public interface Customizer { - /** Set the object to Customize. This will always be a - ** Bean that had a BeanDescriptor indicating this - ** Customizer. - ** @param bean the Bean to customize. - **/ - void setObject(Object bean); + /** Set the object to Customize. This will always be a + ** Bean that had a BeanDescriptor indicating this + ** Customizer. + ** @param bean the Bean to customize. + **/ + void setObject(Object bean); - /** Add a PropertyChangeListener. - ** @param l the PropertyChangeListener to add. - **/ - void addPropertyChangeListener(PropertyChangeListener l); + /** Add a PropertyChangeListener. + ** @param l the PropertyChangeListener to add. + **/ + void addPropertyChangeListener(PropertyChangeListener l); - /** Remove a PropertyChangeListener. - ** @param l the PropertyChangeListener to remove. - **/ - void removePropertyChangeListener(PropertyChangeListener l); + /** Remove a PropertyChangeListener. + ** @param l the PropertyChangeListener to remove. + **/ + void removePropertyChangeListener(PropertyChangeListener l); } diff --git a/java/beans/DefaultPersistenceDelegate.java b/java/beans/DefaultPersistenceDelegate.java index c4328e030..3a4d86cca 100644 --- a/java/beans/DefaultPersistenceDelegate.java +++ b/java/beans/DefaultPersistenceDelegate.java @@ -44,7 +44,7 @@ import java.lang.reflect.Method; /** <p><code>DefaultPersistenceDelegate</code> is a {@link PersistenceDelegate} * implementation that can be used to serialize objects which adhere to the * Java Beans naming convention.</p> - * + * * @author Robert Schuster (robertschuster@fsfe.org) * @since 1.4 */ @@ -62,11 +62,11 @@ public class DefaultPersistenceDelegate extends PersistenceDelegate /** This constructor allows to specify which Bean properties appear * in the constructor. - * + * * <p>The implementation reads the mentioned properties from the Bean * instance and applies it in the given order to a corresponding * constructor.</p> - * + * * @param constructorPropertyNames The properties the Bean's constructor * should be given to. */ @@ -167,13 +167,13 @@ public class DefaultPersistenceDelegate extends PersistenceDelegate // * PersistenceDelegate.initialize() is implemented in a way that it // calls the initialize method of the superclass' persistence delegate. super.initialize(type, oldInstance, newInstance, out); - + // Suppresses the writing of property setting statements when this delegate // is not used for the exact instance type. By doing so the following code // is called only once per object. if (type != oldInstance.getClass()) return; - + try { PropertyDescriptor[] propertyDescs = Introspector.getBeanInfo( diff --git a/java/beans/DesignMode.java b/java/beans/DesignMode.java index 9897f022e..bc79361c1 100644 --- a/java/beans/DesignMode.java +++ b/java/beans/DesignMode.java @@ -7,7 +7,7 @@ GNU Classpath is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2, or (at your option) any later version. - + GNU Classpath is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU @@ -49,7 +49,7 @@ package java.beans; * @since JDK1.2 * @see java.beans.beancontext.BeanContextChild */ -public interface DesignMode +public interface DesignMode { /** diff --git a/java/beans/Encoder.java b/java/beans/Encoder.java index 6dc36277f..b3d232a31 100644 --- a/java/beans/Encoder.java +++ b/java/beans/Encoder.java @@ -119,11 +119,11 @@ public class Encoder pd = new CollectionPersistenceDelegate(); delegates.put(AbstractCollection.class, pd); - + pd = new MapPersistenceDelegate(); delegates.put(java.util.AbstractMap.class, pd); delegates.put(java.util.Hashtable.class, pd); - + defaultPersistenceDelegate = new DefaultPersistenceDelegate(); delegates.put(Object.class, defaultPersistenceDelegate); @@ -158,7 +158,7 @@ public class Encoder accessCounter++; pd.writeObject(o, this); accessCounter--; - + } /** @@ -169,8 +169,8 @@ public class Encoder */ public void setExceptionListener(ExceptionListener listener) { - exceptionListener = (listener != null) - ? listener : DefaultExceptionListener.INSTANCE; + exceptionListener = (listener != null) + ? listener : DefaultExceptionListener.INSTANCE; } /** @@ -261,7 +261,7 @@ public class Encoder // String instances are handled in a special way. // No one knows why this is not officially specified // because this is a rather important design decision. - return (oldInstance == null) ? null : + return (oldInstance == null) ? null : (oldInstance.getClass() == String.class) ? oldInstance : candidates.get(oldInstance); } @@ -338,8 +338,8 @@ public class Encoder exceptionListener.exceptionThrown(e); return; } - - + + newValue = get(value); if (newValue == null) @@ -369,15 +369,15 @@ public class Encoder newArgs[i] = get(args[i]); } } - + Expression newExpr = new Expression(newTarget, expr.getMethodName(), newArgs); - + // Fakes the result of Class.forName(<primitiveType>) to make it possible // to hand such a type to the encoding process. if (value instanceof Class && ((Class) value).isPrimitive()) newExpr.setValue(value); - + // Instantiates the new object. try { @@ -388,10 +388,10 @@ public class Encoder catch (Exception e) { exceptionListener.exceptionThrown(e); - + return; } - + writeObject(value); } @@ -404,10 +404,10 @@ public class Encoder /** Returns whether the given class is an immutable * type which has to be handled differently when serializing it. - * + * * <p>Immutable objects always have to be instantiated instead of * modifying an existing instance.</p> - * + * * @param type The class to test. * @return Whether the first argument is an immutable type. */ @@ -419,9 +419,9 @@ public class Encoder || type == Long.class || type == Float.class || type == Double.class; } - + /** Sets the stream candidate for a given object. - * + * * @param oldObject The object given to the encoder. * @param newObject The object the encoder generated. */ @@ -429,5 +429,5 @@ public class Encoder { candidates.put(oldObject, newObject); } - + } diff --git a/java/beans/EventHandler.java b/java/beans/EventHandler.java index 5efbc8dc6..967ba8294 100644 --- a/java/beans/EventHandler.java +++ b/java/beans/EventHandler.java @@ -7,7 +7,7 @@ GNU Classpath is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2, or (at your option) any later version. - + GNU Classpath is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU @@ -46,14 +46,14 @@ import java.lang.reflect.Proxy; /** * <p>EventHandler forms a bridge between dynamically created listeners and * arbitrary properties and methods.</p> - * + * * <p>You can use this class to easily create listener implementations for * some basic interactions between an event source and its target. Using * the three static methods named <code>create</code> you can create * these listener implementations.</p> - * + * * <p>See the documentation of each method for usage examples.</p> - * + * * @author Jerry Quinn (jlquinn@optonline.net) * @author Robert Schuster (thebohemian@gmx.net) * @since 1.4 @@ -74,7 +74,7 @@ public class EventHandler implements InvocationHandler // The target objects Class. private Class targetClass; - + // String class doesn't already have a capitalize routine. private String capitalize(String s) { @@ -90,9 +90,9 @@ public class EventHandler implements InvocationHandler * <p>This constructs an EventHandler that will connect the method * listenerMethodName to target.action, extracting eventPropertyName from * the first argument of listenerMethodName. and sending it to action.</p> - * + * * <p>Throws a <code>NullPointerException</code> if the <code>target</code> - * argument is <code>null</code>. + * argument is <code>null</code>. * * @param target Object that will perform the action. * @param action A property or method of the target. @@ -100,17 +100,17 @@ public class EventHandler implements InvocationHandler * @param listenerMethodName The listener method name triggering the action. */ public EventHandler(Object target, String action, String eventPropertyName, - String listenerMethodName) + String listenerMethodName) { this.target = target; - + // Retrieving the class is done for two reasons: // 1) The class object is needed very frequently in the invoke() method. // 2) The constructor should throw a NullPointerException if target is null. targetClass = target.getClass(); - - this.action = action; // Turn this into a method or do we wait till - // runtime + + this.action = action; // Turn this into a method or do we wait till + // runtime property = eventPropertyName; listenerMethod = listenerMethodName; } @@ -164,16 +164,16 @@ public class EventHandler implements InvocationHandler String rest = null; if ((pos = prop.indexOf('.')) != -1) { - rest = prop.substring(pos + 1); - prop = prop.substring(0, pos); + rest = prop.substring(pos + 1); + prop = prop.substring(0, pos); } // Find a method named getProp. It could be isProp instead. Method getter; try { - // Look for boolean property getter isProperty - getter = o.getClass().getMethod("is" + capitalize(prop)); + // Look for boolean property getter isProperty + getter = o.getClass().getMethod("is" + capitalize(prop)); } catch (NoSuchMethodException nsme1) { @@ -209,9 +209,9 @@ public class EventHandler implements InvocationHandler /** * Invokes the <code>EventHandler</code>. - * + * * <p>This method is normally called by the listener's proxy implementation.</p> - * + * * @param proxy The listener interface that is implemented using * the proxy mechanism. * @param method The method that was called on the proxy instance. @@ -245,11 +245,11 @@ public class EventHandler implements InvocationHandler // - need method and object to do the invoke and get return type Object v[] = getProperty(event, property); Object[] args = new Object[] { v[0] }; - + // Changes the class array that controls which method signature we are going // to look up in the target object. Class[] argTypes = new Class[] { initClass((Class) v[1]) }; - + // Tries to find a setter method to which we can apply the while(argTypes[0] != null) { try @@ -263,16 +263,16 @@ public class EventHandler implements InvocationHandler { // If action as property didn't work, try as method later. } - + argTypes[0] = nextClass(argTypes[0]); } - + // We could not find a suitable setter method. Now we try again interpreting // action as the method name itself. - // Since we probably have changed the block local argTypes array + // Since we probably have changed the block local argTypes array // we need to rebuild it. argTypes = new Class[] { initClass((Class) v[1]) }; - + // Tries to find a setter method to which we can apply the while(argTypes[0] != null) { try @@ -284,15 +284,15 @@ public class EventHandler implements InvocationHandler catch (NoSuchMethodException e) { } - + argTypes[0] = nextClass(argTypes[0]); } - + throw new RuntimeException("Method not called: Could not find a public method named '" + action + "' in target " + targetClass + " which takes a '" + v[1] + "' argument or a property of this type."); - } - + } + // If property was null we will search for a no-argument method here. // Note: The ordering of method lookups is important because we want to prefer no-argument // calls like the JDK does. This means if we have actionMethod() and actionMethod(Event) we will @@ -312,25 +312,25 @@ public class EventHandler implements InvocationHandler // else this can stay this way. if(arguments != null && arguments.length >= 1/* && arguments[0] instanceof EventObject*/) { Class[] targetArgTypes = new Class[] { initClass(arguments[0].getClass()) }; - + while(targetArgTypes[0] != null) { try { // If no property exists we expect the first element of the arguments to be // an EventObject which is then applied to the target method. - + actionMethod = targetClass.getMethod(action, targetArgTypes); - + return actionMethod.invoke(target, new Object[] { arguments[0] }); } catch(NoSuchMethodException nsme2) { - + } - + targetArgTypes[0] = nextClass(targetArgTypes[0]); } - + } } @@ -338,7 +338,7 @@ public class EventHandler implements InvocationHandler // failed. The JDK throws an ArrayIndexOutOfBoundsException in this case. if(actionMethod == null) throw new ArrayIndexOutOfBoundsException(0); - + // Invoke target.action(property) return actionMethod.invoke(target); } catch(InvocationTargetException ite) { @@ -350,75 +350,75 @@ public class EventHandler implements InvocationHandler throw (InternalError) new InternalError("Non-public method was invoked.").initCause(iae); } } - + /** * <p>Returns the primitive type for every wrapper class or the * class itself if it is no wrapper class.</p> - * + * * <p>This is needed because to be able to find both kinds of methods: * One that takes a wrapper class as the first argument and one that * accepts a primitive instead.</p> */ private Class initClass(Class klass) { if(klass == Boolean.class) { - return Boolean.TYPE; + return Boolean.TYPE; } else if(klass == Byte.class) { - return Byte.TYPE; + return Byte.TYPE; } else if(klass == Short.class) { - return Short.TYPE; + return Short.TYPE; } else if(klass == Integer.class) { - return Integer.TYPE; + return Integer.TYPE; } else if(klass == Long.class) { - return Long.TYPE; + return Long.TYPE; } else if(klass == Float.class) { - return Float.TYPE; + return Float.TYPE; } else if(klass == Double.class) { - return Double.TYPE; + return Double.TYPE; } else { - return klass; + return klass; } } /** - * - * + * + * * @param klass * @return */ private Class nextClass(Class klass) { if(klass == Boolean.TYPE) { - return Boolean.class; + return Boolean.class; } else if(klass == Byte.TYPE) { - return Byte.class; + return Byte.class; } else if(klass == Short.TYPE) { - return Short.class; + return Short.class; } else if(klass == Integer.TYPE) { - return Integer.class; + return Integer.class; } else if(klass == Long.TYPE) { - return Long.class; + return Long.class; } else if(klass == Float.TYPE) { - return Float.class; + return Float.class; } else if(klass == Double.TYPE) { - return Double.class; + return Double.class; } else { return klass.getSuperclass(); } } - + /** * <p>Constructs an implementation of <code>listenerInterface</code> * to dispatch events.</p> - * + * * <p>You can use such an implementation to simply call a public * no-argument method of an arbitrary target object or to forward * the first argument of the listener method to the target method.</p> - * + * * <p>Call this method like:</p> * <code> * button.addActionListener((ActionListener) * EventHandler.create(ActionListener.class, target, "dispose")); * </code> - * + * * <p>to achieve the following behavior:</p> * <code> * button.addActionListener(new ActionListener() { @@ -427,11 +427,11 @@ public class EventHandler implements InvocationHandler * } * }); * </code> - * + * * <p>That means if you need a listener implementation that simply calls a * a no-argument method on a given instance for <strong>each</strong> * method of the listener interface.</p> - * + * * <p>Note: The <code>action</code> is interpreted as a method name. If your target object * has no no-argument method of the given name the EventHandler tries to find * a method with the same name but which can accept the first argument of the @@ -444,15 +444,15 @@ public class EventHandler implements InvocationHandler * to their wrapper class and vice versa. Furthermore it will call * a target method if it accepts a superclass of the type of the * first argument of the listener method.</p> - * + * * <p>In case that the method of the target object throws an exception * it will be wrapped in a <code>RuntimeException</code> and thrown out * of the listener method.</p> - * + * * <p>In case that the method of the target object cannot be found an * <code>ArrayIndexOutOfBoundsException</code> will be thrown when the * listener method is invoked.</p> - * + * * <p>A call to this method is equivalent to: * <code>create(listenerInterface, target, action, null, null)</code></p> * @@ -462,7 +462,7 @@ public class EventHandler implements InvocationHandler * @return A constructed proxy object. */ public static <T> T create(Class<T> listenerInterface, Object target, - String action) + String action) { return create(listenerInterface, target, action, null, null); } @@ -476,27 +476,27 @@ public class EventHandler implements InvocationHandler * and applies it to the target's property or method. This first argument * of the listener is usually an event object but any other object is * valid, too.</p> - * + * * <p>You can set the value of <code>eventPropertyName</code> to "prop" * to denote the retrieval of a property named "prop" from the event * object. In case that no such property exists the <code>EventHandler</code> * will try to find a method with that name.</p> - * + * * <p>If you set <code>eventPropertyName</code> to a value like this "a.b.c" * <code>EventHandler</code> will recursively evaluate the properties "a", "b" * and "c". Again if no property can be found the <code>EventHandler</code> * tries a method name instead. This allows mixing the names, too: "a.toString" * will retrieve the property "a" from the event object and will then call * the method "toString" on it.</p> - * + * * <p>An exception thrown in any of these methods will provoke a * <code>RuntimeException</code> to be thrown which contains an * <code>InvocationTargetException</code> containing the triggering exception.</p> - * + * * <p>If you set <code>eventPropertyName</code> to a non-null value the * <code>action</code> parameter will be interpreted as a property name * or a method name of the target object.</p> - * + * * <p>Any object retrieved from the event object and applied to the * target will converted from primitives to their wrapper class or * vice versa or applied to a method that accepts a superclass @@ -512,35 +512,35 @@ public class EventHandler implements InvocationHandler * } * }); * </code> - * + * * <p>Can be expressed using the <code>EventHandler</code> like this:</p> * <p> * <code>button.addActionListener((ActionListener) * EventHandler.create(ActionListener.class, textField, "text", "source.class.name"); * <code> * </p> - * + * * <p>As said above you can specify the target as a method, too:</p> * <p> * <code>button.addActionListener((ActionListener) * EventHandler.create(ActionListener.class, textField, "setText", "source.class.name"); * <code> * </p> - * + * * <p>Furthermore you can use method names in the property:</p> * <p> * <code>button.addActionListener((ActionListener) * EventHandler.create(ActionListener.class, textField, "setText", "getSource.getClass.getName"); * <code> * </p> - * + * * <p>Finally you can mix names:</p> * <p> * <code>button.addActionListener((ActionListener) * EventHandler.create(ActionListener.class, textField, "setText", "source.getClass.name"); * <code> * </p> - * + * * <p>A call to this method is equivalent to: * <code>create(listenerInterface, target, action, null, null)</code> * </p> @@ -552,7 +552,7 @@ public class EventHandler implements InvocationHandler * @return A constructed proxy object. */ public static <T> T create(Class<T> listenerInterface, Object target, - String action, String eventPropertyName) + String action, String eventPropertyName) { return create(listenerInterface, target, action, eventPropertyName, null); } @@ -566,7 +566,7 @@ public class EventHandler implements InvocationHandler * to filter the listener method that should have an effect. Look at these * method's documentation for more information about the <code>EventHandler</code>'s * usage.</p> - * + * * <p>If you want to call <code>dispose</code> on a <code>JFrame</code> instance * when the <code>WindowListener.windowClosing()</code> method was invoked use * the following code:</p> @@ -575,10 +575,10 @@ public class EventHandler implements InvocationHandler * EventHandler.create(WindowListener.class, jframeInstance, "dispose", null, "windowClosing"); * </code> * </p> - * + * * <p>A <code>NullPointerException</code> is thrown if the <code>listenerInterface</code> * or <code>target</code> argument are <code>null</code>. - * + * * @param listenerInterface Listener interface to implement. * @param target Object to invoke action on. * @param action Target method name to invoke. @@ -587,17 +587,17 @@ public class EventHandler implements InvocationHandler * @return A constructed proxy object. */ public static <T> T create(Class<T> listenerInterface, Object target, - String action, String eventPropertyName, - String listenerMethodName) + String action, String eventPropertyName, + String listenerMethodName) { // Create EventHandler instance EventHandler eh = new EventHandler(target, action, eventPropertyName, - listenerMethodName); + listenerMethodName); // Create proxy object passing in the event handler Object proxy = Proxy.newProxyInstance(listenerInterface.getClassLoader(), - new Class<?>[] {listenerInterface}, - eh); + new Class<?>[] {listenerInterface}, + eh); return (T) proxy; } diff --git a/java/beans/EventSetDescriptor.java b/java/beans/EventSetDescriptor.java index 69c07423f..3f537c743 100644 --- a/java/beans/EventSetDescriptor.java +++ b/java/beans/EventSetDescriptor.java @@ -7,7 +7,7 @@ it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2, or (at your option) any later version. - + GNU Classpath is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU @@ -47,13 +47,13 @@ import java.util.Vector; /** * EventSetDescriptor describes the hookup between an event source class and * an event listener class. - * + * * <p>EventSets have several attributes: the listener class, * the events that can be fired to the listener (methods in the listener * class), and an add and remove listener method from the event firer's * class. * </p> - * + * * <p> * The methods have these constraints on them: * <ul> @@ -62,29 +62,29 @@ import java.util.Vector; * package-protected. (Don't ask me why that is, I'm just following the spec. * The only place it is even mentioned is in the Java Beans white paper, and * there it is only implied.)</li> - * + * * <li>add listener method: must have <code>void</code> return value. Must * take exactly one argument, of the listener class's type. May fire either * zero exceptions, or one exception of type * <code>java.util.TooManyListenersException</code>. * Must be public.</li> - * + * * <li>remove listener method: must have <code>void</code> return value. Must * take exactly one argument, of the listener class's type. May not fire any * exceptions. Must be public.</li> * </ul> - * + * * <p> * A final constraint is that event listener classes must extend from * EventListener. * </p> - * + * * <p> * There are also various design patterns associated with some of the methods * of construction. Those are explained in more detail in the appropriate * constructors. * </p> - * + * * <p> * <strong>Documentation Convention:</strong> for proper Internalization of * Beans inside an RAD tool, sometimes there are two names for a property or @@ -92,7 +92,7 @@ import java.util.Vector; * anywhere, and a localized, display name, for ease of use. In the * documentation I will specify different String values as either * <em>programmatic</em> or <em>localized</em> to make this distinction clear. - * + * * @author John Keiser * @author Robert Schuster (robertschuster@fsfe.org) * @since 1.1 @@ -118,12 +118,12 @@ public class EventSetDescriptor extends FeatureDescriptor /** * Creates a new <code>EventSetDescriptor</code<. - * + * * <p> * This version of the constructor enforces the rules imposed on the methods * described at the top of this class, as well as searching for: * </p> - * + * * <ol> * <li> * The event-firing method must be non-private with signature <code>void @@ -140,7 +140,7 @@ public class EventSetDescriptor extends FeatureDescriptor * should be chosen (they probably weren't thinking as pathologically as I * was). I don't like arbitrarily choosing things. If your class has only one * such signature, as most do, you'll have no problems.</li> - * + * * <li>The add and remove methods must be public and named <code>void * add<eventSetName>Listener(<listenerType>)</code> and * <code>void remove<eventSetName>Listener(<listenerType>)</code> @@ -148,7 +148,7 @@ public class EventSetDescriptor extends FeatureDescriptor * <code><eventSetName></code> will have its first letter capitalized. * Standard exception rules (see class description) apply.</li> * </ol> - * + * * @param eventSourceClass * the class containing the add/remove listener methods. * @param eventSetName @@ -202,12 +202,12 @@ public class EventSetDescriptor extends FeatureDescriptor /** * Creates a new <code>EventSetDescriptor</code>. - * + * * <p>This form of the constructor allows you to specify the names of the * methods and adds no new constraints on top of the rules already described * at the top of the class. * </p> - * + * * @param eventSourceClass * the class containing the add and remove listener methods. * @param eventSetName @@ -251,7 +251,7 @@ public class EventSetDescriptor extends FeatureDescriptor /** * Creates a new <code>EventSetDescriptor</code>. - * + * * <p> * This variant of the constructor allows you to specify the names of the * methods and adds no new constraints on top of the rules already described @@ -266,7 +266,7 @@ public class EventSetDescriptor extends FeatureDescriptor * Note: The validity of the return value of the GetListener method is not * checked. * </p> - * + * * @param eventSourceClass * the class containing the add and remove listener methods. * @param eventSetName @@ -301,13 +301,13 @@ public class EventSetDescriptor extends FeatureDescriptor try { - newGetListenerMethod + newGetListenerMethod = eventSourceClass.getMethod(getListenerMethodName, new Class[] { Class.class }); } catch (NoSuchMethodException nsme) { - throw (IntrospectionException) + throw (IntrospectionException) new IntrospectionException("No method named " + getListenerMethodName + " in class " + listenerType + " which can be used as" @@ -323,7 +323,7 @@ public class EventSetDescriptor extends FeatureDescriptor /** * Creates a new <code>EventSetDescriptor.</code> - * + * * <p> * This variant of the constructor allows you to specify the names of the * methods and adds no new constraints on top of the rules already described @@ -338,7 +338,7 @@ public class EventSetDescriptor extends FeatureDescriptor * Note: The validity of the return value of the GetListener method is not * checked. * </p> - * + * * @param eventSetName * the programmatic name of the event set, generally starting with a * lowercase letter (i.e. fooManChu instead of FooManChu). @@ -381,12 +381,12 @@ public class EventSetDescriptor extends FeatureDescriptor /** * Creates a new <code>EventSetDescriptor</code>. - * + * * <p>This form of constructor allows you to explicitly say which methods * do what, and no reflection is done by the <code>EventSetDescriptor</code>. * The methods are, however, checked to ensure that they follow the rules * set forth at the top of the class. - * + * * @param eventSetName * the programmatic name of the event set, generally starting with a * lowercase letter (i.e. fooManChu instead of FooManChu). @@ -428,12 +428,12 @@ public class EventSetDescriptor extends FeatureDescriptor } /** Creates a new <code>EventSetDescriptor</code>. - * + * * <p>This form of constructor allows you to explicitly say which methods do * what, and no reflection is done by the <code>EventSetDescriptor</code>. * The methods are, however, checked to ensure that they follow the rules * set forth at the top of the class. - * + * * @param eventSetName * the programmatic name of the event set, generally starting with a * lowercase letter (i.e. fooManChu instead of FooManChu). @@ -504,14 +504,14 @@ public class EventSetDescriptor extends FeatureDescriptor { listenerMethodDescriptors = new MethodDescriptor[listenerMethods.length]; - + for (int i = 0; i < listenerMethods.length; i++) { listenerMethodDescriptors[i] = new MethodDescriptor(listenerMethods[i]); } } - + return listenerMethodDescriptors; } @@ -539,7 +539,7 @@ public class EventSetDescriptor extends FeatureDescriptor } /** Sets whether or not multiple listeners may be added. - * + * * @param unicast * whether or not multiple listeners may be added. */ @@ -557,7 +557,7 @@ public class EventSetDescriptor extends FeatureDescriptor } /** Sets whether or not this is in the default event set. - * + * * @param inDefaultEventSet * whether this is in the default event set. */ @@ -759,5 +759,5 @@ public class EventSetDescriptor extends FeatureDescriptor this.listenerMethods[i] = (Method) chosenMethods.elementAt(i); } } - + } diff --git a/java/beans/Expression.java b/java/beans/Expression.java index b327864d9..d07c28b4a 100644 --- a/java/beans/Expression.java +++ b/java/beans/Expression.java @@ -7,7 +7,7 @@ GNU Classpath is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2, or (at your option) any later version. - + GNU Classpath is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU @@ -40,13 +40,13 @@ package java.beans; /** * <p>An Expression captures the execution of an object method * that returns a value.</p> - * + * * <p>It stores an object, the method to call, and the arguments to pass to * the method.</p> - * + * * <p>While this class can generally be used to describe method calls it is - * part of the XML serialization API.</p> - * + * part of the XML serialization API.</p> + * * @author Robert Schuster (robertschuster@fsfe.org) * @since 1.4 */ @@ -63,7 +63,7 @@ public class Expression extends Statement * Constructor Constructs an Expression representing the invocation of * object.methodName(arg[0], arg[1], ...); However, it will never be executed. * Instead, value will always be returned. - * + * * @param value * The value to return. * @param target @@ -83,7 +83,7 @@ public class Expression extends Statement /** * Constructor Constructs an Expression representing the invocation of * object.methodName(arg[0], arg[1], ...); - * + * * @param target * The object to invoke the method on. * @param methodName @@ -102,7 +102,7 @@ public class Expression extends Statement * been set, the method is executed in the same way as Statement.execute(), * except that the value is cached, and then returned. If the value has been * set, it is returned without executing the method again. - * + * * @return the result of executing the method. * @exception Exception * if an error occurs @@ -116,7 +116,7 @@ public class Expression extends Statement /** * Set the cached value to be returned by getValue() - * + * * @param value * the value to cache and return. */ diff --git a/java/beans/FeatureDescriptor.java b/java/beans/FeatureDescriptor.java index 050885158..87e4a2fe7 100644 --- a/java/beans/FeatureDescriptor.java +++ b/java/beans/FeatureDescriptor.java @@ -7,7 +7,7 @@ GNU Classpath is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2, or (at your option) any later version. - + GNU Classpath is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU diff --git a/java/beans/IndexedPropertyChangeEvent.java b/java/beans/IndexedPropertyChangeEvent.java index 1a7306d14..9c46e1fa1 100644 --- a/java/beans/IndexedPropertyChangeEvent.java +++ b/java/beans/IndexedPropertyChangeEvent.java @@ -71,7 +71,7 @@ public class IndexedPropertyChangeEvent extends PropertyChangeEvent } /** - * Return the index of the changed property. + * Return the index of the changed property. * @return the index */ public int getIndex() diff --git a/java/beans/IndexedPropertyDescriptor.java b/java/beans/IndexedPropertyDescriptor.java index 61c3f228d..b7914133a 100644 --- a/java/beans/IndexedPropertyDescriptor.java +++ b/java/beans/IndexedPropertyDescriptor.java @@ -7,7 +7,7 @@ GNU Classpath is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2, or (at your option) any later version. - + GNU Classpath is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU @@ -175,7 +175,7 @@ public class IndexedPropertyDescriptor extends PropertyDescriptor * Create a new PropertyDescriptor using explicit Methods. * Note that the methods will be checked for conformance to standard * Property method rules, as described above at the top of this class. - * + * * @param name the programmatic name of the property, usually * starting with a lowercase letter (e.g. fooManChu * instead of FooManChu). diff --git a/java/beans/Introspector.java b/java/beans/Introspector.java index 28df87f67..76412e022 100644 --- a/java/beans/Introspector.java +++ b/java/beans/Introspector.java @@ -7,7 +7,7 @@ GNU Classpath is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2, or (at your option) any later version. - + GNU Classpath is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU @@ -94,7 +94,7 @@ import java.util.Vector; * * * <STRONG>Properties:</STRONG><P> - * + * * <OL> * <LI>If there is a <CODE>public boolean isXXX()</CODE> * method, then XXX is a read-only boolean property. @@ -167,7 +167,7 @@ import java.util.Vector; * not the case in general.<P> * * <STRONG>Methods:</STRONG><P> - * + * * Any public methods (including those which were used * for Properties or Events) are used as Methods. * @@ -176,18 +176,18 @@ import java.util.Vector; * @see java.beans.BeanInfo */ public class Introspector { - + public static final int USE_ALL_BEANINFO = 1; public static final int IGNORE_IMMEDIATE_BEANINFO = 2; public static final int IGNORE_ALL_BEANINFO = 3; static String[] beanInfoSearchPath = {"gnu.java.beans.info"}; - static Hashtable<Class<?>,BeanInfo> beanInfoCache = + static Hashtable<Class<?>,BeanInfo> beanInfoCache = new Hashtable<Class<?>,BeanInfo>(); - + private Introspector() {} - - /** + + /** * Get the BeanInfo for class <CODE>beanClass</CODE>, * first by looking for explicit information, next by * using standard design patterns to determine @@ -196,32 +196,32 @@ public class Introspector { * @param beanClass the class to get BeanInfo about. * @return the BeanInfo object representing the class. */ - public static BeanInfo getBeanInfo(Class<?> beanClass) - throws IntrospectionException + public static BeanInfo getBeanInfo(Class<?> beanClass) + throws IntrospectionException { BeanInfo cachedInfo; - synchronized(beanClass) + synchronized(beanClass) { - cachedInfo = beanInfoCache.get(beanClass); - if(cachedInfo != null) - { - return cachedInfo; - } - cachedInfo = getBeanInfo(beanClass,null); - beanInfoCache.put(beanClass,cachedInfo); - return cachedInfo; + cachedInfo = beanInfoCache.get(beanClass); + if(cachedInfo != null) + { + return cachedInfo; + } + cachedInfo = getBeanInfo(beanClass,null); + beanInfoCache.put(beanClass,cachedInfo); + return cachedInfo; } } - + /** * Returns a {@BeanInfo} instance for the given Bean class where a flag * controls the usage of explicit BeanInfo class to retrieve that * information. - * + * * <p>You have three options:</p> * <p>With {@link #USE_ALL_BEANINFO} the result is the same as * {@link #getBeanInfo(Class)}.</p> - * + * * <p>Calling the method with <code>flag</code> set to * {@link #IGNORE_IMMEDIATE_BEANINFO} will let it use all * explicit BeanInfo classes for the beans superclasses @@ -232,17 +232,17 @@ public class Introspector { * {@link BeanInfo.getEventSetDescriptors} and * {@link BeanInfo.getPropertyDescriptors}.) * </p> - * + * * <p>When the method is called with <code>flag</code< set to * {@link #IGNORE_ALL_BEANINFO} all the bean data is retrieved * by inspecting the class.</p> - * + * * <p>Note: Any unknown value for <code>flag</code> is interpreted * as {@link #IGNORE_ALL_BEANINFO}</p>. - * + * * @param beanClass The class whose BeanInfo should be returned. * @param flag Controls the usage of explicit <code>BeanInfo</code> classes. - * @return A BeanInfo object describing the class. + * @return A BeanInfo object describing the class. * @throws IntrospectionException If something goes wrong while retrieving * the bean data. */ @@ -251,7 +251,7 @@ public class Introspector { { IntrospectionIncubator ii; BeanInfoEmbryo infoEmbryo; - + switch(flag) { case USE_ALL_BEANINFO: @@ -259,24 +259,24 @@ public class Introspector { case IGNORE_IMMEDIATE_BEANINFO: Class superclass = beanClass.getSuperclass(); ExplicitInfo explicit = new ExplicitInfo(superclass, null); - + ii = new IntrospectionIncubator(); if (explicit.explicitEventSetDescriptors != null) ii.setEventStopClass(superclass); - + if (explicit.explicitMethodDescriptors != null) ii.setMethodStopClass(superclass); - + if (explicit.explicitPropertyDescriptors != null) ii.setPropertyStopClass(superclass); - + ii.addMethods(beanClass.getMethods()); infoEmbryo = ii.getBeanInfoEmbryo(); merge(infoEmbryo, explicit); infoEmbryo.setBeanDescriptor(new BeanDescriptor(beanClass, null)); - + return infoEmbryo.getBeanInfo(); case IGNORE_ALL_BEANINFO: default: @@ -284,7 +284,7 @@ public class Introspector { ii.addMethods(beanClass.getMethods()); infoEmbryo = ii.getBeanInfoEmbryo(); infoEmbryo.setBeanDescriptor(new BeanDescriptor(beanClass, null)); - + return infoEmbryo.getBeanInfo(); } } @@ -298,11 +298,11 @@ public class Introspector { { beanInfoCache.clear(); - // Clears all the intermediate ExplicitInfo instances which - // have been created. - // This makes sure we have to retrieve stuff like BeanDescriptors - // again. (Remember that FeatureDescriptor can be modified by the user.) - ExplicitInfo.flushCaches(); + // Clears all the intermediate ExplicitInfo instances which + // have been created. + // This makes sure we have to retrieve stuff like BeanDescriptors + // again. (Remember that FeatureDescriptor can be modified by the user.) + ExplicitInfo.flushCaches(); } /** @@ -317,62 +317,62 @@ public class Introspector { { synchronized (clz) { - beanInfoCache.remove(clz); + beanInfoCache.remove(clz); } } /** Adds all explicity given bean info data to the introspected * data. - * + * * @param infoEmbryo Bean info data retrieved by introspection. * @param explicit Bean info data retrieved by BeanInfo classes. */ private static void merge(BeanInfoEmbryo infoEmbryo, ExplicitInfo explicit) { PropertyDescriptor[] p = explicit.explicitPropertyDescriptors; - if(p!=null) + if(p!=null) { - for(int i=0;i<p.length;i++) + for(int i=0;i<p.length;i++) { - if(!infoEmbryo.hasProperty(p[i])) + if(!infoEmbryo.hasProperty(p[i])) { infoEmbryo.addProperty(p[i]); } } - + // -1 should be used to denote a missing default property but // for robustness reasons any value below zero is discarded. // Not doing so would let Classpath fail where the JDK succeeds. - if(explicit.defaultProperty > -1) + if(explicit.defaultProperty > -1) { infoEmbryo.setDefaultPropertyName(p[explicit.defaultProperty].getName()); } } EventSetDescriptor[] e = explicit.explicitEventSetDescriptors; - if(e!=null) + if(e!=null) { - for(int i=0;i<e.length;i++) + for(int i=0;i<e.length;i++) { - if(!infoEmbryo.hasEvent(e[i])) + if(!infoEmbryo.hasEvent(e[i])) { infoEmbryo.addEvent(e[i]); } } - + // -1 should be used to denote a missing default event but // for robustness reasons any value below zero is discarded. // Not doing so would let Classpath fail where the JDK succeeds. - if(explicit.defaultEvent > -1) + if(explicit.defaultEvent > -1) { infoEmbryo.setDefaultEventName(e[explicit.defaultEvent].getName()); } } MethodDescriptor[] m = explicit.explicitMethodDescriptors; - if(m!=null) + if(m!=null) { - for(int i=0;i<m.length;i++) + for(int i=0;i<m.length;i++) { - if(!infoEmbryo.hasMethod(m[i])) + if(!infoEmbryo.hasMethod(m[i])) { infoEmbryo.addMethod(m[i]); } @@ -381,10 +381,10 @@ public class Introspector { infoEmbryo.setAdditionalBeanInfo(explicit.explicitBeanInfo); infoEmbryo.setIcons(explicit.im); - + } - - /** + + /** * Get the BeanInfo for class <CODE>beanClass</CODE>, * first by looking for explicit information, next by * using standard design patterns to determine @@ -395,8 +395,8 @@ public class Introspector { * @param stopClass the class to stop at. * @return the BeanInfo object representing the class. */ - public static BeanInfo getBeanInfo(Class<?> beanClass, Class<?> stopClass) - throws IntrospectionException + public static BeanInfo getBeanInfo(Class<?> beanClass, Class<?> stopClass) + throws IntrospectionException { ExplicitInfo explicit = new ExplicitInfo(beanClass, stopClass); @@ -405,11 +405,11 @@ public class Introspector { ii.setEventStopClass(explicit.eventStopClass); ii.setMethodStopClass(explicit.methodStopClass); ii.addMethods(beanClass.getMethods()); - + BeanInfoEmbryo currentInfo = ii.getBeanInfoEmbryo(); - + merge(currentInfo, explicit); - + // Sets the info's BeanDescriptor to the one we extracted from the // explicit BeanInfo instance(s) if they contained one. Otherwise we // create the BeanDescriptor from scratch. @@ -417,33 +417,33 @@ public class Introspector { // the user to modify the instance while it is cached. However this is how // the RI does it. currentInfo.setBeanDescriptor( - (explicit.explicitBeanDescriptor == null ? + (explicit.explicitBeanDescriptor == null ? new BeanDescriptor(beanClass, null) : - explicit.explicitBeanDescriptor)); + explicit.explicitBeanDescriptor)); return currentInfo.getBeanInfo(); } - - /** + + /** * Get the search path for BeanInfo classes. * * @return the BeanInfo search path. */ - public static String[] getBeanInfoSearchPath() + public static String[] getBeanInfoSearchPath() { return beanInfoSearchPath; } - - /** + + /** * Set the search path for BeanInfo classes. * @param beanInfoSearchPath the new BeanInfo search * path. */ - public static void setBeanInfoSearchPath(String[] beanInfoSearchPath) + public static void setBeanInfoSearchPath(String[] beanInfoSearchPath) { Introspector.beanInfoSearchPath = beanInfoSearchPath; } - - /** + + /** * A helper method to convert a name to standard Java * naming conventions: anything with two capitals as the * first two letters remains the same, otherwise the @@ -453,80 +453,80 @@ public class Introspector { * @param name the name to decapitalize. * @return the decapitalized name. */ - public static String decapitalize(String name) + public static String decapitalize(String name) { - try + try { - if(!Character.isUpperCase(name.charAt(0))) - { - return name; - } - else - { - try - { - if(Character.isUpperCase(name.charAt(1))) - { - return name; - } - else - { - char[] c = name.toCharArray(); - c[0] = Character.toLowerCase(c[0]); - return new String(c); - } - } - catch(StringIndexOutOfBoundsException E) - { - char[] c = new char[1]; - c[0] = Character.toLowerCase(name.charAt(0)); - return new String(c); - } - } - } - catch(StringIndexOutOfBoundsException E) + if(!Character.isUpperCase(name.charAt(0))) + { + return name; + } + else + { + try + { + if(Character.isUpperCase(name.charAt(1))) + { + return name; + } + else + { + char[] c = name.toCharArray(); + c[0] = Character.toLowerCase(c[0]); + return new String(c); + } + } + catch(StringIndexOutOfBoundsException E) + { + char[] c = new char[1]; + c[0] = Character.toLowerCase(name.charAt(0)); + return new String(c); + } + } + } + catch(StringIndexOutOfBoundsException E) { - return name; - } - catch(NullPointerException E) + return name; + } + catch(NullPointerException E) { - return null; + return null; } } - static BeanInfo copyBeanInfo(BeanInfo b) + static BeanInfo copyBeanInfo(BeanInfo b) { java.awt.Image[] icons = new java.awt.Image[4]; - for(int i=1;i<=4;i++) + for(int i=1;i<=4;i++) { - icons[i-1] = b.getIcon(i); + icons[i-1] = b.getIcon(i); } return new ExplicitBeanInfo(b.getBeanDescriptor(), - b.getAdditionalBeanInfo(), - b.getPropertyDescriptors(), - b.getDefaultPropertyIndex(), - b.getEventSetDescriptors(), - b.getDefaultEventIndex(), - b.getMethodDescriptors(), - icons); + b.getAdditionalBeanInfo(), + b.getPropertyDescriptors(), + b.getDefaultPropertyIndex(), + b.getEventSetDescriptors(), + b.getDefaultEventIndex(), + b.getMethodDescriptors(), + icons); } } -class ExplicitInfo +class ExplicitInfo { BeanDescriptor explicitBeanDescriptor; BeanInfo[] explicitBeanInfo; - + PropertyDescriptor[] explicitPropertyDescriptors; EventSetDescriptor[] explicitEventSetDescriptors; MethodDescriptor[] explicitMethodDescriptors; - + int defaultProperty; int defaultEvent; - + java.awt.Image[] im = new java.awt.Image[4]; - + Class propertyStopClass; Class eventStopClass; Class methodStopClass; @@ -534,119 +534,119 @@ class ExplicitInfo static Hashtable explicitBeanInfos = new Hashtable(); static Vector emptyBeanInfos = new Vector(); - ExplicitInfo(Class beanClass, Class stopClass) + ExplicitInfo(Class beanClass, Class stopClass) { - while(beanClass != null && !beanClass.equals(stopClass)) + while(beanClass != null && !beanClass.equals(stopClass)) { - BeanInfo explicit = findExplicitBeanInfo(beanClass); - - - if(explicit != null) - { - - if(explicitBeanDescriptor == null) - { - explicitBeanDescriptor = explicit.getBeanDescriptor(); - } - - if(explicitBeanInfo == null) - { - explicitBeanInfo = explicit.getAdditionalBeanInfo(); - } - - if(explicitPropertyDescriptors == null) - { - if(explicit.getPropertyDescriptors() != null) - { - explicitPropertyDescriptors = explicit.getPropertyDescriptors(); - defaultProperty = explicit.getDefaultPropertyIndex(); - propertyStopClass = beanClass; - } - } - - if(explicitEventSetDescriptors == null) - { - if(explicit.getEventSetDescriptors() != null) - { - explicitEventSetDescriptors = explicit.getEventSetDescriptors(); - defaultEvent = explicit.getDefaultEventIndex(); - eventStopClass = beanClass; - } - } - - if(explicitMethodDescriptors == null) - { - if(explicit.getMethodDescriptors() != null) - { - explicitMethodDescriptors = explicit.getMethodDescriptors(); - methodStopClass = beanClass; - } - } - - if(im[0] == null && im[1] == null - && im[2] == null && im[3] == null) - { - im[0] = explicit.getIcon(0); - im[1] = explicit.getIcon(1); - im[2] = explicit.getIcon(2); - im[3] = explicit.getIcon(3); - } - } - beanClass = beanClass.getSuperclass(); + BeanInfo explicit = findExplicitBeanInfo(beanClass); + + + if(explicit != null) + { + + if(explicitBeanDescriptor == null) + { + explicitBeanDescriptor = explicit.getBeanDescriptor(); + } + + if(explicitBeanInfo == null) + { + explicitBeanInfo = explicit.getAdditionalBeanInfo(); + } + + if(explicitPropertyDescriptors == null) + { + if(explicit.getPropertyDescriptors() != null) + { + explicitPropertyDescriptors = explicit.getPropertyDescriptors(); + defaultProperty = explicit.getDefaultPropertyIndex(); + propertyStopClass = beanClass; + } + } + + if(explicitEventSetDescriptors == null) + { + if(explicit.getEventSetDescriptors() != null) + { + explicitEventSetDescriptors = explicit.getEventSetDescriptors(); + defaultEvent = explicit.getDefaultEventIndex(); + eventStopClass = beanClass; + } + } + + if(explicitMethodDescriptors == null) + { + if(explicit.getMethodDescriptors() != null) + { + explicitMethodDescriptors = explicit.getMethodDescriptors(); + methodStopClass = beanClass; + } + } + + if(im[0] == null && im[1] == null + && im[2] == null && im[3] == null) + { + im[0] = explicit.getIcon(0); + im[1] = explicit.getIcon(1); + im[2] = explicit.getIcon(2); + im[3] = explicit.getIcon(3); + } + } + beanClass = beanClass.getSuperclass(); } - if(propertyStopClass == null) + if(propertyStopClass == null) { - propertyStopClass = stopClass; + propertyStopClass = stopClass; } - if(eventStopClass == null) + if(eventStopClass == null) { - eventStopClass = stopClass; + eventStopClass = stopClass; } - if(methodStopClass == null) + if(methodStopClass == null) { - methodStopClass = stopClass; + methodStopClass = stopClass; } } - + /** Throws away all cached data and makes sure we re-instantiate things * like BeanDescriptors again. */ static void flushCaches() { - explicitBeanInfos.clear(); - emptyBeanInfos.clear(); + explicitBeanInfos.clear(); + emptyBeanInfos.clear(); } - - static BeanInfo findExplicitBeanInfo(Class beanClass) + + static BeanInfo findExplicitBeanInfo(Class beanClass) { BeanInfo retval = (BeanInfo)explicitBeanInfos.get(beanClass); - if(retval != null) + if(retval != null) { - return retval; - } - else if(emptyBeanInfos.indexOf(beanClass) != -1) + return retval; + } + else if(emptyBeanInfos.indexOf(beanClass) != -1) { - return null; - } - else + return null; + } + else { - retval = reallyFindExplicitBeanInfo(beanClass); - if(retval != null) - { - explicitBeanInfos.put(beanClass,retval); - } - else - { - emptyBeanInfos.addElement(beanClass); - } - return retval; + retval = reallyFindExplicitBeanInfo(beanClass); + if(retval != null) + { + explicitBeanInfos.put(beanClass,retval); + } + else + { + emptyBeanInfos.addElement(beanClass); + } + return retval; } } - - static BeanInfo reallyFindExplicitBeanInfo(Class beanClass) + + static BeanInfo reallyFindExplicitBeanInfo(Class beanClass) { ClassLoader beanClassLoader = beanClass.getClassLoader(); BeanInfo beanInfo; @@ -654,25 +654,25 @@ class ExplicitInfo beanInfo = getBeanInfo(beanClassLoader, beanClass.getName() + "BeanInfo"); if (beanInfo == null) { - String newName; - newName = ClassHelper.getTruncatedClassName(beanClass) + "BeanInfo"; - - for(int i = 0; i < Introspector.beanInfoSearchPath.length; i++) - { - if (Introspector.beanInfoSearchPath[i].equals("")) - beanInfo = getBeanInfo(beanClassLoader, newName); - else - beanInfo = getBeanInfo(beanClassLoader, - Introspector.beanInfoSearchPath[i] + "." - + newName); - - // Returns the beanInfo if it exists and the described class matches - // the one we searched. - if (beanInfo != null && beanInfo.getBeanDescriptor() != null && - beanInfo.getBeanDescriptor().getBeanClass() == beanClass) - - return beanInfo; - } + String newName; + newName = ClassHelper.getTruncatedClassName(beanClass) + "BeanInfo"; + + for(int i = 0; i < Introspector.beanInfoSearchPath.length; i++) + { + if (Introspector.beanInfoSearchPath[i].equals("")) + beanInfo = getBeanInfo(beanClassLoader, newName); + else + beanInfo = getBeanInfo(beanClassLoader, + Introspector.beanInfoSearchPath[i] + "." + + newName); + + // Returns the beanInfo if it exists and the described class matches + // the one we searched. + if (beanInfo != null && beanInfo.getBeanDescriptor() != null && + beanInfo.getBeanDescriptor().getBeanClass() == beanClass) + + return beanInfo; + } } return beanInfo; @@ -686,20 +686,20 @@ class ExplicitInfo { try { - return (BeanInfo) Class.forName(infoName, true, cl).newInstance(); + return (BeanInfo) Class.forName(infoName, true, cl).newInstance(); } catch (ClassNotFoundException cnfe) { - return null; + return null; } catch (IllegalAccessException iae) { - return null; + return null; } catch (InstantiationException ie) { - return null; + return null; } } - + } diff --git a/java/beans/MethodDescriptor.java b/java/beans/MethodDescriptor.java index 123dba60c..0185fde81 100644 --- a/java/beans/MethodDescriptor.java +++ b/java/beans/MethodDescriptor.java @@ -7,7 +7,7 @@ GNU Classpath is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2, or (at your option) any later version. - + GNU Classpath is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU @@ -49,40 +49,39 @@ import java.lang.reflect.Method; ** @version 1.1.0, 26 Jul 1998 **/ public class MethodDescriptor extends FeatureDescriptor { - private Method m; - private ParameterDescriptor[] parameterDescriptors; + private Method m; + private ParameterDescriptor[] parameterDescriptors; - /** Create a new MethodDescriptor. - ** This method sets the name to the name of the method (Method.getName()). - ** @param m the method it will represent. - **/ - public MethodDescriptor(Method m) { - setName(m.getName()); - this.m = m; - } + /** Create a new MethodDescriptor. + ** This method sets the name to the name of the method (Method.getName()). + ** @param m the method it will represent. + **/ + public MethodDescriptor(Method m) { + setName(m.getName()); + this.m = m; + } - /** Create a new MethodDescriptor. - ** This method sets the name to the name of the method (Method.getName()). - ** @param m the method it will represent. - ** @param parameterDescriptors descriptions of the parameters (especially names). - **/ - public MethodDescriptor(Method m, ParameterDescriptor[] parameterDescriptors) { - setName(m.getName()); - this.m = m; - this.parameterDescriptors = parameterDescriptors; - } + /** Create a new MethodDescriptor. + ** This method sets the name to the name of the method (Method.getName()). + ** @param m the method it will represent. + ** @param parameterDescriptors descriptions of the parameters (especially names). + **/ + public MethodDescriptor(Method m, ParameterDescriptor[] parameterDescriptors) { + setName(m.getName()); + this.m = m; + this.parameterDescriptors = parameterDescriptors; + } - /** Get the parameter descriptors from this method. - ** Since MethodDescriptor has no way of determining what - ** the parameter names were, this defaults to null. - **/ - public ParameterDescriptor[] getParameterDescriptors() { - return parameterDescriptors; - } + /** Get the parameter descriptors from this method. + ** Since MethodDescriptor has no way of determining what + ** the parameter names were, this defaults to null. + **/ + public ParameterDescriptor[] getParameterDescriptors() { + return parameterDescriptors; + } - /** Get the method this MethodDescriptor represents. **/ - public Method getMethod() { - return m; - } + /** Get the method this MethodDescriptor represents. **/ + public Method getMethod() { + return m; + } } - diff --git a/java/beans/ParameterDescriptor.java b/java/beans/ParameterDescriptor.java index 8ea93a9bd..148690066 100644 --- a/java/beans/ParameterDescriptor.java +++ b/java/beans/ParameterDescriptor.java @@ -7,7 +7,7 @@ GNU Classpath is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2, or (at your option) any later version. - + GNU Classpath is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU @@ -48,5 +48,5 @@ package java.beans; ** @version 1.1.0, 26 Jul 1998 **/ public class ParameterDescriptor extends FeatureDescriptor { - + } diff --git a/java/beans/PersistenceDelegate.java b/java/beans/PersistenceDelegate.java index a6f715763..d4e777844 100644 --- a/java/beans/PersistenceDelegate.java +++ b/java/beans/PersistenceDelegate.java @@ -7,7 +7,7 @@ GNU Classpath is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2, or (at your option) any later version. - + GNU Classpath is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU @@ -40,12 +40,12 @@ package java.beans; /** <p>A <code>PersistenceDelegate</code> describes how a another object * has to constructed and transformed in order to create a complete * replicate.</p> - * + * * <p>For custom classes you will need to implement * <code>PersistenceDelegate</code> in a way that is suitable for them. * To make use of the implementation you have to register it with an * {@link Encoder} using the {Encoder#setPersistenceDelegate} method.</p> - * + * * @author Robert Schuster (robertschuster@fsfe.org) * @since 1.4 */ @@ -60,7 +60,7 @@ public abstract class PersistenceDelegate type = type.getSuperclass(); PersistenceDelegate pd = out.getPersistenceDelegate(type); - + pd.initialize(type, oldInstance, newInstance, out); } } diff --git a/java/beans/PropertyChangeSupport.java b/java/beans/PropertyChangeSupport.java index ecadb146f..3f3f53d42 100644 --- a/java/beans/PropertyChangeSupport.java +++ b/java/beans/PropertyChangeSupport.java @@ -404,7 +404,7 @@ public class PropertyChangeSupport implements Serializable /** * Fire an indexed property change event. This will only fire - * an event if the old and new values are not equal and not null. + * an event if the old and new values are not equal and not null. * @param name the name of the property which changed * @param index the index of the property which changed * @param oldValue the old value of the property diff --git a/java/beans/PropertyDescriptor.java b/java/beans/PropertyDescriptor.java index 4b586d915..a74fa7b13 100644 --- a/java/beans/PropertyDescriptor.java +++ b/java/beans/PropertyDescriptor.java @@ -7,7 +7,7 @@ GNU Classpath is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2, or (at your option) any later version. - + GNU Classpath is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU @@ -100,7 +100,7 @@ public class PropertyDescriptor extends FeatureDescriptor ** starting with a lowercase letter (e.g. fooManChu ** instead of FooManChu). ** @param beanClass the class the get and set methods live in. - ** @exception IntrospectionException if the methods are not found + ** @exception IntrospectionException if the methods are not found ** or invalid. **/ public PropertyDescriptor(String name, Class<?> beanClass) @@ -126,7 +126,7 @@ public class PropertyDescriptor extends FeatureDescriptor "Cannot find a " + caps + " method"); } - // finally check the methods compatibility + // finally check the methods compatibility propertyType = checkMethods(getMethod, setMethod); } @@ -154,7 +154,7 @@ public class PropertyDescriptor extends FeatureDescriptor ** @param beanClass the class the get and set methods live in. ** @param getMethodName the name of the get method or <code>null</code> if the property is write-only. ** @param setMethodName the name of the set method or <code>null</code> if the property is read-only. - ** @exception IntrospectionException if the methods are not found + ** @exception IntrospectionException if the methods are not found ** or invalid. **/ public PropertyDescriptor( @@ -188,13 +188,13 @@ public class PropertyDescriptor extends FeatureDescriptor **<br> ** It is possible to call this method with both <code>Method</code> arguments ** being <code>null</code>. In such a case the property type is <code>null</code>. - ** + ** ** @param name the programmatic name of the property, usually ** starting with a lowercase letter (e.g. fooManChu ** instead of FooManChu). ** @param readMethod the read method or <code>null</code> if the property is write-only. ** @param writeMethod the write method or <code>null</code> if the property is read-only. - ** @exception IntrospectionException if the methods are not found + ** @exception IntrospectionException if the methods are not found ** or invalid. **/ public PropertyDescriptor( @@ -234,7 +234,7 @@ public class PropertyDescriptor extends FeatureDescriptor * <br/> * It is legal to set the read and the write method to <code>null</code> * or provide method which have been declared in distinct classes. - * + * * @param readMethod The new method to be used or <code>null</code>. * @throws IntrospectionException If the given method is invalid. * @since 1.2 @@ -262,7 +262,7 @@ public class PropertyDescriptor extends FeatureDescriptor * <br/> * It is legal to set the read and the write method to <code>null</code> * or provide method which have been declared in distinct classes. - * + * * @param writeMethod The new method to be used or <code>null</code>. * @throws IntrospectionException If the given method is invalid. * @since 1.2 @@ -338,7 +338,7 @@ public class PropertyDescriptor extends FeatureDescriptor /** Set the PropertyEditor class. If the class does not implement ** the PropertyEditor interface, you will likely get an exception ** late in the game. - ** @param propertyEditorClass the PropertyEditor class for this + ** @param propertyEditorClass the PropertyEditor class for this ** class to use. **/ public void setPropertyEditorClass(Class<?> propertyEditorClass) @@ -510,7 +510,7 @@ public class PropertyDescriptor extends FeatureDescriptor * <br/> * For compatibility this has to be noted:<br/> * The two methods are allowed to be defined in two distinct classes and may both be null. - * + * * @param readMethod The new read method to check. * @param writeMethod The new write method to check. * @return The common property type of the two method. @@ -566,7 +566,7 @@ public class PropertyDescriptor extends FeatureDescriptor } /* note: the check whether both method are defined in related classes makes sense but is not - * done in the JDK. + * done in the JDK. * I leave this code here in case someone at Sun decides to add that functionality in later versions (rschuster) if ((!readMethod .getDeclaringClass() @@ -659,7 +659,7 @@ public class PropertyDescriptor extends FeatureDescriptor { return false; } - + } } diff --git a/java/beans/PropertyEditor.java b/java/beans/PropertyEditor.java index d1c510341..5fba014ea 100644 --- a/java/beans/PropertyEditor.java +++ b/java/beans/PropertyEditor.java @@ -7,7 +7,7 @@ GNU Classpath is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2, or (at your option) any later version. - + GNU Classpath is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU @@ -109,101 +109,101 @@ package java.beans; **/ public interface PropertyEditor { - /** Called by the RAD tool to set the value of this property for the PropertyEditor. - ** If the property type is native, it should be wrapped in the appropriate - ** wrapper type. - ** @param value the value to set this property to. - **/ - void setValue(Object value); - - /** Accessor method to get the current value the PropertyEditor is working with. - ** If the property type is native, it will be wrapped in the appropriate - ** wrapper type. - ** @return the current value of the PropertyEditor. - **/ - Object getValue(); - - - /** Set the value of this property using a String. - ** Whether or not this PropertyEditor is editing a String type, this converts - ** the String into the type of the PropertyEditor. - ** @param text the text to set it to. - ** @exception IllegalArgumentException if the String is in the wrong format or setAsText() is not supported. - **/ - void setAsText(String text) throws IllegalArgumentException; - - /** Get the value of this property in String format. - ** Many times this can simply use Object.toString().<P> - ** Return null if you do not support getAsText()/setAsText(). - ** <code>setAsText(getAsText())</code> should be valid; i.e. the stuff you spit out in - ** getAsText() should be able to go into setAsText(). - ** @return the value of this property in String format. - **/ - String getAsText(); - - /** Get a list of possible Strings which this property type can have. - ** The value of these will be used by the RAD tool to construct some sort - ** of list box or to check text box input, and the resulting String passed - ** to setAsText() should be one of these. Note, however, that like most things - ** with this mammoth, unwieldy interface, this is not guaranteed. Thus, you - ** must check the value in setAsText() anyway. - ** @return the list of possible String values for this property type. - **/ - String[] getTags(); - - - /** The RAD tool calls this to find out whether the PropertyEditor can paint itself. - ** @return true if it can paint itself graphically, false if it cannot. - **/ - boolean isPaintable(); - - /** The RAD tool calls this to paint the actual value of the property. - ** The Graphics context will have the same current font, color, etc. as the - ** parent Container. You may safely change the font, color, etc. and not - ** change them back.<P> - ** This method should do a silent no-op if isPaintable() is false. - ** @param g the Graphics context to paint on - ** @param bounds the rectangle you have reserved to work in - **/ - void paintValue(java.awt.Graphics g, java.awt.Rectangle bounds); - - - /** The RAD tool calls this to find out whether the PropertyEditor supports a custom component to edit and display itself. - ** @return true if getCustomEditor() will return a component, false if not. - **/ - boolean supportsCustomEditor(); - - /** The RAD tool calls this to grab the component that can edit this type. - ** The component may be painted anywhere the RAD tool wants to paint it-- - ** even in its own window.<P> - ** The component must hook up with the PropertyEditor and, whenever a - ** change to the value is made, fire a PropertyChangeEvent to the source.<P> - ** @return the custom editor for this property type. - **/ - java.awt.Component getCustomEditor(); - - - /** Adds a property change listener to this PropertyEditor. - ** @param listener the listener to add - **/ - void addPropertyChangeListener(PropertyChangeListener listener); - - /** Removes a property change listener from this PropertyEditor. - ** @param listener the listener to remove - **/ - void removePropertyChangeListener(PropertyChangeListener listener); - - /** Get a Java language-specific String which could be used to create an Object - ** of the specified type. Every PropertyEditor must support this.<P> - ** The reason for this is that while most RAD tools will serialize the Beans - ** and deserialize them at runtime, some RAD tools will generate code that - ** creates the Beans. Examples of Java initialization strings would be:<P> - ** <OL> - ** <LI><CODE>2</CODE></LI> - ** <LI><CODE>"I am a String"</CODE></LI> - ** <LI><CODE>new MyObject(2, "String", new StringBuffer())</CODE></LI> - ** </OL> - ** @return the initialization string for this object in Java. - **/ - String getJavaInitializationString(); + /** Called by the RAD tool to set the value of this property for the PropertyEditor. + ** If the property type is native, it should be wrapped in the appropriate + ** wrapper type. + ** @param value the value to set this property to. + **/ + void setValue(Object value); + + /** Accessor method to get the current value the PropertyEditor is working with. + ** If the property type is native, it will be wrapped in the appropriate + ** wrapper type. + ** @return the current value of the PropertyEditor. + **/ + Object getValue(); + + + /** Set the value of this property using a String. + ** Whether or not this PropertyEditor is editing a String type, this converts + ** the String into the type of the PropertyEditor. + ** @param text the text to set it to. + ** @exception IllegalArgumentException if the String is in the wrong format or setAsText() is not supported. + **/ + void setAsText(String text) throws IllegalArgumentException; + + /** Get the value of this property in String format. + ** Many times this can simply use Object.toString().<P> + ** Return null if you do not support getAsText()/setAsText(). + ** <code>setAsText(getAsText())</code> should be valid; i.e. the stuff you spit out in + ** getAsText() should be able to go into setAsText(). + ** @return the value of this property in String format. + **/ + String getAsText(); + + /** Get a list of possible Strings which this property type can have. + ** The value of these will be used by the RAD tool to construct some sort + ** of list box or to check text box input, and the resulting String passed + ** to setAsText() should be one of these. Note, however, that like most things + ** with this mammoth, unwieldy interface, this is not guaranteed. Thus, you + ** must check the value in setAsText() anyway. + ** @return the list of possible String values for this property type. + **/ + String[] getTags(); + + + /** The RAD tool calls this to find out whether the PropertyEditor can paint itself. + ** @return true if it can paint itself graphically, false if it cannot. + **/ + boolean isPaintable(); + + /** The RAD tool calls this to paint the actual value of the property. + ** The Graphics context will have the same current font, color, etc. as the + ** parent Container. You may safely change the font, color, etc. and not + ** change them back.<P> + ** This method should do a silent no-op if isPaintable() is false. + ** @param g the Graphics context to paint on + ** @param bounds the rectangle you have reserved to work in + **/ + void paintValue(java.awt.Graphics g, java.awt.Rectangle bounds); + + + /** The RAD tool calls this to find out whether the PropertyEditor supports a custom component to edit and display itself. + ** @return true if getCustomEditor() will return a component, false if not. + **/ + boolean supportsCustomEditor(); + + /** The RAD tool calls this to grab the component that can edit this type. + ** The component may be painted anywhere the RAD tool wants to paint it-- + ** even in its own window.<P> + ** The component must hook up with the PropertyEditor and, whenever a + ** change to the value is made, fire a PropertyChangeEvent to the source.<P> + ** @return the custom editor for this property type. + **/ + java.awt.Component getCustomEditor(); + + + /** Adds a property change listener to this PropertyEditor. + ** @param listener the listener to add + **/ + void addPropertyChangeListener(PropertyChangeListener listener); + + /** Removes a property change listener from this PropertyEditor. + ** @param listener the listener to remove + **/ + void removePropertyChangeListener(PropertyChangeListener listener); + + /** Get a Java language-specific String which could be used to create an Object + ** of the specified type. Every PropertyEditor must support this.<P> + ** The reason for this is that while most RAD tools will serialize the Beans + ** and deserialize them at runtime, some RAD tools will generate code that + ** creates the Beans. Examples of Java initialization strings would be:<P> + ** <OL> + ** <LI><CODE>2</CODE></LI> + ** <LI><CODE>"I am a String"</CODE></LI> + ** <LI><CODE>new MyObject(2, "String", new StringBuffer())</CODE></LI> + ** </OL> + ** @return the initialization string for this object in Java. + **/ + String getJavaInitializationString(); } diff --git a/java/beans/PropertyEditorManager.java b/java/beans/PropertyEditorManager.java index 0dd3b176d..253ddafe1 100644 --- a/java/beans/PropertyEditorManager.java +++ b/java/beans/PropertyEditorManager.java @@ -7,7 +7,7 @@ GNU Classpath is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2, or (at your option) any later version. - + GNU Classpath is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU @@ -64,7 +64,7 @@ import java.awt.Font; * package and then in the property editor search path. * * <p>Default property editors are provided for:</p> - * + * * <ol> * <li>boolean, byte, short, int, long, float, and double</li> * <li>java.lang.String</li> @@ -143,13 +143,13 @@ public class PropertyEditorManager return (PropertyEditor)found.newInstance(); } - ClassLoader contextClassLoader - = Thread.currentThread().getContextClassLoader(); + ClassLoader contextClassLoader + = Thread.currentThread().getContextClassLoader(); try { found = Class.forName(editedClass.getName()+"Editor", true, - contextClassLoader); + contextClassLoader); registerEditor(editedClass,found); return (PropertyEditor)found.newInstance(); } @@ -158,9 +158,9 @@ public class PropertyEditorManager } String appendName - = "." - + ClassHelper.getTruncatedClassName(editedClass) - + "Editor"; + = "." + + ClassHelper.getTruncatedClassName(editedClass) + + "Editor"; synchronized(editorSearchPath) { for(int i=0;i<editorSearchPath.length;i++) @@ -168,7 +168,7 @@ public class PropertyEditorManager try { found = Class.forName(editorSearchPath[i] + appendName, - true, contextClassLoader); + true, contextClassLoader); registerEditor(editedClass,found); return (PropertyEditor)found.newInstance(); } @@ -184,7 +184,7 @@ public class PropertyEditorManager catch(IllegalAccessException E) { } - + return null; } diff --git a/java/beans/SimpleBeanInfo.java b/java/beans/SimpleBeanInfo.java index 56b1f7aa7..d5216caf5 100644 --- a/java/beans/SimpleBeanInfo.java +++ b/java/beans/SimpleBeanInfo.java @@ -7,7 +7,7 @@ GNU Classpath is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2, or (at your option) any later version. - + GNU Classpath is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU @@ -65,75 +65,75 @@ import java.net.URL; **/ public class SimpleBeanInfo implements BeanInfo { - /** Force Introspection of the general bean info. - ** @return <CODE>null</CODE>. - **/ - public BeanDescriptor getBeanDescriptor() { - return null; - } - - /** Force Introspection of the events this Bean type - ** fires. - ** @return <CODE>null</CODE> - **/ - public EventSetDescriptor[] getEventSetDescriptors() { - return null; - } - - /** Say that there is no "default" event set. - ** @return <CODE>-1</CODE>. - **/ - public int getDefaultEventIndex() { - return -1; - } - - /** Force Introspection of the Bean properties. - ** @return <CODE>null</CODE>. - **/ - public PropertyDescriptor[] getPropertyDescriptors() { - return null; - } - - /** Say that there is no "default" property. - ** @return <CODE>-1</CODE>. - **/ - public int getDefaultPropertyIndex() { - return -1; - } - - /** Force Introspection of the Bean's methods. - ** @return <CODE>null</CODE>. - **/ - public MethodDescriptor[] getMethodDescriptors() { - return null; - } - - /** Tell the Introspector to go look for other BeanInfo - ** itself. - ** @return <CODE>null</CODE>. - **/ - public BeanInfo[] getAdditionalBeanInfo() { - return null; - } - - /** Say that this Bean has no icons. - ** @param iconType the type of icon - ** @return <CODE>null</CODE>. - **/ - public Image getIcon(int iconType) { - return null; - } - - /** Helper method to load an image using the Bean class - ** getResource() method on the BeanInfo class (using - ** getClass(), since you'll extend this class to get - ** the BeanInfo). Basically it's assumed that the Bean - ** and its BeanInfo are both loaded by the same - ** ClassLoader, generally a reasonable assumption. - ** @param location the URL relative - ** @return the Image in question (possibly <code>null</code>). - **/ - public Image loadImage(String location) + /** Force Introspection of the general bean info. + ** @return <CODE>null</CODE>. + **/ + public BeanDescriptor getBeanDescriptor() { + return null; + } + + /** Force Introspection of the events this Bean type + ** fires. + ** @return <CODE>null</CODE> + **/ + public EventSetDescriptor[] getEventSetDescriptors() { + return null; + } + + /** Say that there is no "default" event set. + ** @return <CODE>-1</CODE>. + **/ + public int getDefaultEventIndex() { + return -1; + } + + /** Force Introspection of the Bean properties. + ** @return <CODE>null</CODE>. + **/ + public PropertyDescriptor[] getPropertyDescriptors() { + return null; + } + + /** Say that there is no "default" property. + ** @return <CODE>-1</CODE>. + **/ + public int getDefaultPropertyIndex() { + return -1; + } + + /** Force Introspection of the Bean's methods. + ** @return <CODE>null</CODE>. + **/ + public MethodDescriptor[] getMethodDescriptors() { + return null; + } + + /** Tell the Introspector to go look for other BeanInfo + ** itself. + ** @return <CODE>null</CODE>. + **/ + public BeanInfo[] getAdditionalBeanInfo() { + return null; + } + + /** Say that this Bean has no icons. + ** @param iconType the type of icon + ** @return <CODE>null</CODE>. + **/ + public Image getIcon(int iconType) { + return null; + } + + /** Helper method to load an image using the Bean class + ** getResource() method on the BeanInfo class (using + ** getClass(), since you'll extend this class to get + ** the BeanInfo). Basically it's assumed that the Bean + ** and its BeanInfo are both loaded by the same + ** ClassLoader, generally a reasonable assumption. + ** @param location the URL relative + ** @return the Image in question (possibly <code>null</code>). + **/ + public Image loadImage(String location) { if (location == null) return null; @@ -141,6 +141,5 @@ public class SimpleBeanInfo implements BeanInfo { if (url == null) return null; return Toolkit.getDefaultToolkit().getImage(url); - } + } } - diff --git a/java/beans/Statement.java b/java/beans/Statement.java index 5ecba37c8..d9cd304da 100644 --- a/java/beans/Statement.java +++ b/java/beans/Statement.java @@ -7,7 +7,7 @@ GNU Classpath is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2, or (at your option) any later version. - + GNU Classpath is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU @@ -100,7 +100,7 @@ public class Statement * <li>Static methods can be executed by providing the class as a * target.</li> * - * <li>The method name new is reserved to call the constructor + * <li>The method name new is reserved to call the constructor * new() will construct an object and return it. Not useful unless * an expression :-)</li> * @@ -123,34 +123,34 @@ public class Statement * declared in the source file.</p> * * @throws Exception if an exception occurs while locating or - * invoking the method. + * invoking the method. */ public void execute() throws Exception { doExecute(); } - - private static Class wrappers[] = + + private static Class wrappers[] = { Boolean.class, Byte.class, Character.class, Double.class, Float.class, Integer.class, Long.class, Short.class }; - private static Class natives[] = + private static Class natives[] = { Boolean.TYPE, Byte.TYPE, Character.TYPE, Double.TYPE, Float.TYPE, Integer.TYPE, Long.TYPE, Short.TYPE }; /** Given a wrapper class, return the native class for it. - * <p>For example, if <code>c</code> is <code>Integer</code>, + * <p>For example, if <code>c</code> is <code>Integer</code>, * <code>Integer.TYPE</code> is returned.</p> */ private Class unwrap(Class c) { for (int i = 0; i < wrappers.length; i++) if (c == wrappers[i]) - return natives[i]; + return natives[i]; return null; } @@ -168,16 +168,16 @@ public class Statement // any type. if (args[i] == null) continue; - + // Treat Integer like int if appropriate - Class nativeType = unwrap(args[i]); - if (nativeType != null && params[i].isPrimitive() - && params[i].isAssignableFrom(nativeType)) - continue; - if (params[i].isAssignableFrom(args[i])) - continue; - - return false; + Class nativeType = unwrap(args[i]); + if (nativeType != null && params[i].isPrimitive() + && params[i].isAssignableFrom(nativeType)) + continue; + if (params[i].isAssignableFrom(args[i])) + continue; + + return false; } return true; } @@ -201,9 +201,9 @@ public class Statement { for (int j=0; j < first.length; j++) { - if (second[j].isAssignableFrom(first[j])) - continue; - return false; + if (second[j].isAssignableFrom(first[j])) + continue; + return false; } return true; } @@ -211,10 +211,10 @@ public class Statement final Object doExecute() throws Exception { Class klazz = (target instanceof Class) - ? (Class) target : target.getClass(); + ? (Class) target : target.getClass(); Object args[] = (arguments == null) ? new Object[0] : arguments; Class argTypes[] = new Class[args.length]; - + // Retrieve type or use null if the argument is null. The null argument // type is later used in compatible(). for (int i = 0; i < args.length; i++) @@ -222,18 +222,18 @@ public class Statement if (target.getClass().isArray()) { - // FIXME: invoke may have to be used. For now, cast to Number - // and hope for the best. If caller didn't behave, we go boom - // and throw the exception. - if (methodName.equals("get") && argTypes.length == 1) - return Array.get(target, ((Number)args[0]).intValue()); - if (methodName.equals("set") && argTypes.length == 2) - { - Object obj = Array.get(target, ((Number)args[0]).intValue()); - Array.set(target, ((Number)args[0]).intValue(), args[1]); - return obj; - } - throw new NoSuchMethodException("No matching method for statement " + toString()); + // FIXME: invoke may have to be used. For now, cast to Number + // and hope for the best. If caller didn't behave, we go boom + // and throw the exception. + if (methodName.equals("get") && argTypes.length == 1) + return Array.get(target, ((Number)args[0]).intValue()); + if (methodName.equals("set") && argTypes.length == 2) + { + Object obj = Array.get(target, ((Number)args[0]).intValue()); + Array.set(target, ((Number)args[0]).intValue(), args[1]); + return obj; + } + throw new NoSuchMethodException("No matching method for statement " + toString()); } // If we already cached the method, just use it. @@ -253,62 +253,62 @@ public class Statement if (methodName.equals("new") && target instanceof Class) { - Constructor ctors[] = klazz.getConstructors(); - for (int i = 0; i < ctors.length; i++) - { - // Skip methods with wrong number of args. - Class ptypes[] = ctors[i].getParameterTypes(); - - if (ptypes.length != args.length) - continue; - - // Check if method matches - if (!compatible(ptypes, argTypes)) - continue; - - // Use method[i] if it is more specific. - // FIXME: should this check both directions and throw if - // neither is more specific? - if (ctor == null) - { - ctor = ctors[i]; - continue; - } - Class mptypes[] = ctor.getParameterTypes(); - if (moreSpecific(ptypes, mptypes)) - ctor = ctors[i]; - } - if (ctor == null) - throw new InstantiationException("No matching constructor for statement " + toString()); - return ctor.newInstance(args); + Constructor ctors[] = klazz.getConstructors(); + for (int i = 0; i < ctors.length; i++) + { + // Skip methods with wrong number of args. + Class ptypes[] = ctors[i].getParameterTypes(); + + if (ptypes.length != args.length) + continue; + + // Check if method matches + if (!compatible(ptypes, argTypes)) + continue; + + // Use method[i] if it is more specific. + // FIXME: should this check both directions and throw if + // neither is more specific? + if (ctor == null) + { + ctor = ctors[i]; + continue; + } + Class mptypes[] = ctor.getParameterTypes(); + if (moreSpecific(ptypes, mptypes)) + ctor = ctors[i]; + } + if (ctor == null) + throw new InstantiationException("No matching constructor for statement " + toString()); + return ctor.newInstance(args); } Method methods[] = klazz.getMethods(); for (int i = 0; i < methods.length; i++) { - // Skip methods with wrong name or number of args. - if (!methods[i].getName().equals(methodName)) - continue; - Class ptypes[] = methods[i].getParameterTypes(); - if (ptypes.length != args.length) - continue; - - // Check if method matches - if (!compatible(ptypes, argTypes)) - continue; - - // Use method[i] if it is more specific. - // FIXME: should this check both directions and throw if - // neither is more specific? - if (method == null) - { - method = methods[i]; - continue; - } - Class mptypes[] = method.getParameterTypes(); - if (moreSpecific(ptypes, mptypes)) - method = methods[i]; + // Skip methods with wrong name or number of args. + if (!methods[i].getName().equals(methodName)) + continue; + Class ptypes[] = methods[i].getParameterTypes(); + if (ptypes.length != args.length) + continue; + + // Check if method matches + if (!compatible(ptypes, argTypes)) + continue; + + // Use method[i] if it is more specific. + // FIXME: should this check both directions and throw if + // neither is more specific? + if (method == null) + { + method = methods[i]; + continue; + } + Class mptypes[] = method.getParameterTypes(); + if (moreSpecific(ptypes, mptypes)) + method = methods[i]; } if (method == null) throw new NoSuchMethodException("No matching method for statement " + toString()); @@ -329,7 +329,7 @@ public class Statement return method.invoke(target, args); } catch(IllegalArgumentException iae){ System.err.println("method: " + method); - + for(int i=0;i<args.length;i++){ System.err.println("args[" + i + "]: " + args[i]); } @@ -337,7 +337,7 @@ public class Statement } } - + /** Return the statement arguments. */ public Object[] getArguments() { return arguments; } @@ -348,19 +348,19 @@ public class Statement /** Return the statement object. */ public Object getTarget() { return target; } - /** - * Returns a string representation of this <code>Statement</code>. - * - * @return A string representation of this <code>Statement</code>. + /** + * Returns a string representation of this <code>Statement</code>. + * + * @return A string representation of this <code>Statement</code>. */ public String toString() { - CPStringBuilder result = new CPStringBuilder(); + CPStringBuilder result = new CPStringBuilder(); String targetName; if (target != null) targetName = target.getClass().getSimpleName(); - else + else targetName = "null"; result.append(targetName); @@ -373,7 +373,7 @@ public class Statement { result.append(sep); result.append( - ( arguments[i] == null ) ? "null" : + ( arguments[i] == null ) ? "null" : ( arguments[i] instanceof String ) ? "\"" + arguments[i] + "\"" : arguments[i].getClass().getSimpleName()); sep = ", "; @@ -382,5 +382,5 @@ public class Statement return result.toString(); } - + } diff --git a/java/beans/VetoableChangeSupport.java b/java/beans/VetoableChangeSupport.java index f2b6a1df8..698e82d8f 100644 --- a/java/beans/VetoableChangeSupport.java +++ b/java/beans/VetoableChangeSupport.java @@ -1,5 +1,5 @@ /* VetoableChangeSupport.java -- support to manage vetoable change listeners - Copyright (C) 1998, 1999, 2000, 2002, 2005, 2006, + Copyright (C) 1998, 1999, 2000, 2002, 2005, 2006, Free Software Foundation, Inc. This file is part of GNU Classpath. diff --git a/java/beans/Visibility.java b/java/beans/Visibility.java index 428f3a207..338060181 100644 --- a/java/beans/Visibility.java +++ b/java/beans/Visibility.java @@ -7,7 +7,7 @@ GNU Classpath is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2, or (at your option) any later version. - + GNU Classpath is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU @@ -54,32 +54,32 @@ package java.beans; */ public interface Visibility { - /** - * Tells whether the Bean can run without a GUI or not. - * @return false if Bean can run without a GUI, else true. - */ - boolean needsGui(); + /** + * Tells whether the Bean can run without a GUI or not. + * @return false if Bean can run without a GUI, else true. + */ + boolean needsGui(); - /** - * Tells whether Bean is trying not to use the GUI. - * If needsGui() is true, this method should always return false. - * @return true if definitely not using GUI, otherwise false. - */ - boolean avoidingGui(); + /** + * Tells whether Bean is trying not to use the GUI. + * If needsGui() is true, this method should always return false. + * @return true if definitely not using GUI, otherwise false. + */ + boolean avoidingGui(); - /** - * Tells the Bean not to use GUI methods. - * If needsGUI() is false, then after this method is called, - * avoidingGui() should return true. - */ - void dontUseGui(); + /** + * Tells the Bean not to use GUI methods. + * If needsGUI() is false, then after this method is called, + * avoidingGui() should return true. + */ + void dontUseGui(); - /** - * Tells the Bean it may use the GUI. - * The Bean is not required to use the GUI in this case, it is - * merely being <EM>permitted</EM> to use it. If needsGui() is - * false, avoidingGui() may return true or false after this method - * is called. - */ - void okToUseGui(); + /** + * Tells the Bean it may use the GUI. + * The Bean is not required to use the GUI in this case, it is + * merely being <EM>permitted</EM> to use it. If needsGui() is + * false, avoidingGui() may return true or false after this method + * is called. + */ + void okToUseGui(); } diff --git a/java/beans/XMLDecoder.java b/java/beans/XMLDecoder.java index 131cf3b04..26896393a 100644 --- a/java/beans/XMLDecoder.java +++ b/java/beans/XMLDecoder.java @@ -55,8 +55,8 @@ import java.util.NoSuchElementException; * An example XML document might look like this: * <code> * <java> - * <string>Hello World</string> - * <int>200</int> + * <string>Hello World</string> + * <int>200</int> * </java> * </code> * <p>To read the <code>String</code> and the <code>Integer</code> instance the following can be used (assume @@ -71,12 +71,12 @@ import java.util.NoSuchElementException; * <p>An owner object can be set using the <code>setOwner</code> method which can then be accessed when * decoding. This feature is only useful if the XML data is aware of the owner object. Such data may * look like this (assume that the owner object is a JFrame instance):</p> - * <code> + * <code> * <java> - * <void method="getOwner"> - * <void method="setVisible"> - * <boolean>true<boolean> - * </void> + * <void method="getOwner"> + * <void method="setVisible"> + * <boolean>true<boolean> + * </void> * </void> * </java> * </code> @@ -98,210 +98,210 @@ import java.util.NoSuchElementException; * the resulting <code>XMLDecoder</code> will be silently (without any exception) useless. Each call * to <code>readObject</code> will return <code>null</code> and never throws an * <code>ArrayIndexOutOfBoundsException</code>.</p> - * + * * @author Robert Schuster * @since 1.4 * @status updated to 1.5 */ public class XMLDecoder { - private Object owner; - - private ExceptionListener exceptionListener; - - private InputStream inputStream; - - private boolean isStreamClosed; - - private ClassLoader classLoader; - - private Iterator iterator; - - /** Creates a XMLDecoder instance that parses the XML data of the given input stream. - * Using this constructor no special ClassLoader, a default ExceptionListener - * and no owner object is used. - * - * @param in InputStream to read XML data from. - */ - public XMLDecoder(InputStream in) - { - this(in, null); - } - - /** Creates a XMLDecoder instance that parses the XML data of the given input stream. - * Using this constructor no special ClassLoader and a default ExceptionListener - * is used. - * - * @param in InputStream to read XML data from. - * @param owner Owner object which can be accessed and modified while parsing. - */ - public XMLDecoder(InputStream in, Object owner) - { - this(in, owner, null); - } - - /** Creates a XMLDecoder instance that parses the XML data of the given input stream. - * If the ExceptionListener argument is null a default implementation is used. - * - * @param in InputStream to read XML data from. - * @param owner Owner object which can be accessed and modified while parsing. - * @param exceptionListener ExceptionListener instance to which exception notifications are send. - */ - public XMLDecoder( - InputStream in, - Object owner, - ExceptionListener exceptionListener) - { - this( - in, - owner, - exceptionListener, - Thread.currentThread().getContextClassLoader()); - } - - /** Creates a XMLDecoder instance that parses the XML data of the given input stream. - * If the ExceptionListener argument is null a default implementation is used. - * - * @param in InputStream to read XML data from. - * @param owner Owner object which can be accessed and modified while parsing. - * @param listener ExceptionListener instance to which exception notifications are send. - * @param cl ClassLoader instance that is used for calls to <code>Class.forName(String, boolean, ClassLoader)</code> - * @since 1.5 - */ - public XMLDecoder( - InputStream in, - Object owner, - ExceptionListener listener, - ClassLoader cl) - { - // initially here was a check for the validity of the InputStream argument but some - // great engineers decided that this API should silently discard this and behave rather - // odd: readObject will always return null ... - inputStream = in; - - setExceptionListener(listener); - - // validity of this object is checked in Class.forName() and therefore may be null - classLoader = cl; - - this.owner = owner; - } - - /** Closes the stream associated with this decoder. This should be done after having read all - * decoded objects. - * <p>See the description of the {@link #readObject()} for the effect caused by <code>close</code>.</p> - */ - public void close() - { - if (isStreamClosed) - { - return; - } - - try - { - inputStream.close(); - isStreamClosed = true; - } - catch (IOException e) - { - // bad style forced by original API design ... - } - } - - /** Returns the ExceptionListener instance associated with this decoder. - * <p>See the description of {@link XMLDecoder} class for more information on the ExceptionListener.</p> - * - * @return Current ExceptionListener of the decoder. - */ - public ExceptionListener getExceptionListener() - { - return exceptionListener; - } - - /** Returns the owner object of the decoder. This method is usually called - * from within the parsed XML data. - * <p>See the description of {@link XMLDecoder} class for more information on the owner object.</p> - * - * @return The owner object of this decoder. - */ - public Object getOwner() - { - return owner; - } - - /** Returns the next available decoded object. - * <p>Note that the actual decoding takes place when the method is called for the first time.</p> - * <p>If the <code>close</code> method was already called a <code>NoSuchElementException</code> - * is thrown.</p> - * <p>If the InputStream instance used in the constructors was <code>null</code> this method - * will always return <code>null</code> itself.</p> - * - * @return The next object in a sequence decoded from XML data. - * @throws ArrayIndexOutOfBoundsException When no more objects are available. - */ - public Object readObject() throws ArrayIndexOutOfBoundsException - { - // note: the RI does it this way ... - if(inputStream == null) { - return null; - } - - // note: the original API documentation says nothing on what to do - // when the stream was closed before readObject is called but it actually - // throws a NoSuchElementException - this behaviour is imitated here - if (isStreamClosed) - { - throw new NoSuchElementException("Cannot read any objects - XMLDecoder was already closed."); - } - - // creates the PersistenceParser (doing the parsing and decoding) and returns its - // Iterator on first invocation - if (iterator == null) - { - iterator = - new PersistenceParser( - inputStream, - exceptionListener, - classLoader, - this) - .iterator(); - } - - // note: done according to the official documentation - if (!iterator.hasNext()) - { - throw new ArrayIndexOutOfBoundsException("No more objects available from this XMLDecoder."); - } - - // returns just the next object if there was no problem - return iterator.next(); - } - - /** Sets the ExceptionListener instance to which notifications of exceptions are send - * while parsing the XML data. - * <p>See the description of {@link XMLDecoder} class for more information on the ExceptionListener.</p> - * - * @param listener - */ - public void setExceptionListener(ExceptionListener listener) - { - // uses a default implementation when null - if (listener == null) - { - listener = DefaultExceptionListener.INSTANCE; - } - exceptionListener = listener; - } - - /** Sets the owner object which can be accessed from the parsed XML data. - * <p>See the description of {@link XMLDecoder} class for more information on the owner object.</p> - * - * @param newOwner - */ - public void setOwner(Object newOwner) - { - owner = newOwner; - } + private Object owner; + + private ExceptionListener exceptionListener; + + private InputStream inputStream; + + private boolean isStreamClosed; + + private ClassLoader classLoader; + + private Iterator iterator; + + /** Creates a XMLDecoder instance that parses the XML data of the given input stream. + * Using this constructor no special ClassLoader, a default ExceptionListener + * and no owner object is used. + * + * @param in InputStream to read XML data from. + */ + public XMLDecoder(InputStream in) + { + this(in, null); + } + + /** Creates a XMLDecoder instance that parses the XML data of the given input stream. + * Using this constructor no special ClassLoader and a default ExceptionListener + * is used. + * + * @param in InputStream to read XML data from. + * @param owner Owner object which can be accessed and modified while parsing. + */ + public XMLDecoder(InputStream in, Object owner) + { + this(in, owner, null); + } + + /** Creates a XMLDecoder instance that parses the XML data of the given input stream. + * If the ExceptionListener argument is null a default implementation is used. + * + * @param in InputStream to read XML data from. + * @param owner Owner object which can be accessed and modified while parsing. + * @param exceptionListener ExceptionListener instance to which exception notifications are send. + */ + public XMLDecoder( + InputStream in, + Object owner, + ExceptionListener exceptionListener) + { + this( + in, + owner, + exceptionListener, + Thread.currentThread().getContextClassLoader()); + } + + /** Creates a XMLDecoder instance that parses the XML data of the given input stream. + * If the ExceptionListener argument is null a default implementation is used. + * + * @param in InputStream to read XML data from. + * @param owner Owner object which can be accessed and modified while parsing. + * @param listener ExceptionListener instance to which exception notifications are send. + * @param cl ClassLoader instance that is used for calls to <code>Class.forName(String, boolean, ClassLoader)</code> + * @since 1.5 + */ + public XMLDecoder( + InputStream in, + Object owner, + ExceptionListener listener, + ClassLoader cl) + { + // initially here was a check for the validity of the InputStream argument but some + // great engineers decided that this API should silently discard this and behave rather + // odd: readObject will always return null ... + inputStream = in; + + setExceptionListener(listener); + + // validity of this object is checked in Class.forName() and therefore may be null + classLoader = cl; + + this.owner = owner; + } + + /** Closes the stream associated with this decoder. This should be done after having read all + * decoded objects. + * <p>See the description of the {@link #readObject()} for the effect caused by <code>close</code>.</p> + */ + public void close() + { + if (isStreamClosed) + { + return; + } + + try + { + inputStream.close(); + isStreamClosed = true; + } + catch (IOException e) + { + // bad style forced by original API design ... + } + } + + /** Returns the ExceptionListener instance associated with this decoder. + * <p>See the description of {@link XMLDecoder} class for more information on the ExceptionListener.</p> + * + * @return Current ExceptionListener of the decoder. + */ + public ExceptionListener getExceptionListener() + { + return exceptionListener; + } + + /** Returns the owner object of the decoder. This method is usually called + * from within the parsed XML data. + * <p>See the description of {@link XMLDecoder} class for more information on the owner object.</p> + * + * @return The owner object of this decoder. + */ + public Object getOwner() + { + return owner; + } + + /** Returns the next available decoded object. + * <p>Note that the actual decoding takes place when the method is called for the first time.</p> + * <p>If the <code>close</code> method was already called a <code>NoSuchElementException</code> + * is thrown.</p> + * <p>If the InputStream instance used in the constructors was <code>null</code> this method + * will always return <code>null</code> itself.</p> + * + * @return The next object in a sequence decoded from XML data. + * @throws ArrayIndexOutOfBoundsException When no more objects are available. + */ + public Object readObject() throws ArrayIndexOutOfBoundsException + { + // note: the RI does it this way ... + if(inputStream == null) { + return null; + } + + // note: the original API documentation says nothing on what to do + // when the stream was closed before readObject is called but it actually + // throws a NoSuchElementException - this behaviour is imitated here + if (isStreamClosed) + { + throw new NoSuchElementException("Cannot read any objects - XMLDecoder was already closed."); + } + + // creates the PersistenceParser (doing the parsing and decoding) and returns its + // Iterator on first invocation + if (iterator == null) + { + iterator = + new PersistenceParser( + inputStream, + exceptionListener, + classLoader, + this) + .iterator(); + } + + // note: done according to the official documentation + if (!iterator.hasNext()) + { + throw new ArrayIndexOutOfBoundsException("No more objects available from this XMLDecoder."); + } + + // returns just the next object if there was no problem + return iterator.next(); + } + + /** Sets the ExceptionListener instance to which notifications of exceptions are send + * while parsing the XML data. + * <p>See the description of {@link XMLDecoder} class for more information on the ExceptionListener.</p> + * + * @param listener + */ + public void setExceptionListener(ExceptionListener listener) + { + // uses a default implementation when null + if (listener == null) + { + listener = DefaultExceptionListener.INSTANCE; + } + exceptionListener = listener; + } + + /** Sets the owner object which can be accessed from the parsed XML data. + * <p>See the description of {@link XMLDecoder} class for more information on the owner object.</p> + * + * @param newOwner + */ + public void setOwner(Object newOwner) + { + owner = newOwner; + } } diff --git a/java/beans/XMLEncoder.java b/java/beans/XMLEncoder.java index 7242d0c69..40cb6dbfb 100644 --- a/java/beans/XMLEncoder.java +++ b/java/beans/XMLEncoder.java @@ -7,7 +7,7 @@ it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2, or (at your option) any later version. - + GNU Classpath is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU @@ -46,7 +46,7 @@ import java.io.OutputStream; * This class uses the {@link PersistenceDelegate} and {@link Encoder} * infrastructure to generate an XML representation of the objects it * serializes. - * + * * @author Robert Schuster (robertschuster@fsfe.org) * @since 1.4 */ @@ -92,11 +92,11 @@ public class XMLEncoder extends Encoder // I needed for a succesfull operation of XMLEncoder. // // The same is true for the writeStatement method. - + // Silently ignore out of bounds calls. if (accessCounter <= 0) return; - + scanEngine.writeExpression(expr); @@ -113,8 +113,8 @@ public class XMLEncoder extends Encoder getExceptionListener().exceptionThrown(e); return; } - - + + newValue = get(value); if (newValue == null) @@ -144,15 +144,15 @@ public class XMLEncoder extends Encoder newArgs[i] = get(args[i]); } } - + Expression newExpr = new Expression(newTarget, expr.getMethodName(), newArgs); - + // Fakes the result of Class.forName(<primitiveType>) to make it possible // to hand such a type to the encoding process. if (value instanceof Class && ((Class) value).isPrimitive()) newExpr.setValue(value); - + // Instantiates the new object. try { @@ -163,15 +163,15 @@ public class XMLEncoder extends Encoder catch (Exception e) { getExceptionListener().exceptionThrown(e); - + // In Statement.writeExpression we had no possibility to flags // an erroneous state to the ScanEngine without behaving different - // to the JDK. + // to the JDK. scanEngine.revoke(); - + return; } - + writeObject(value); } @@ -187,7 +187,7 @@ public class XMLEncoder extends Encoder { // In case of questions have a at the implementation note in // writeExpression. - + scanEngine.writeStatement(stmt); // Silently ignore out of bounds calls. @@ -234,7 +234,7 @@ public class XMLEncoder extends Encoder // In Statement.writeStatement we had no possibility to flags // an erroneous state to the ScanEngine without behaving different - // to the JDK. + // to the JDK. scanEngine.revoke(); return; } @@ -245,15 +245,15 @@ public class XMLEncoder extends Encoder public void writeObject(Object o) { accessCounter++; - + scanEngine.writeObject(o); - + if (get(o) == null) super.writeObject(o); - + accessCounter--; } - + public void setOwner(Object o) { owner = o; diff --git a/java/beans/beancontext/BeanContext.java b/java/beans/beancontext/BeanContext.java index 02f4a1a40..803cb36ff 100644 --- a/java/beans/beancontext/BeanContext.java +++ b/java/beans/beancontext/BeanContext.java @@ -7,7 +7,7 @@ GNU Classpath is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2, or (at your option) any later version. - + GNU Classpath is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU @@ -166,107 +166,107 @@ import java.util.Collection; */ public interface BeanContext - extends Collection, BeanContextChild, Visibility, DesignMode { + extends Collection, BeanContextChild, Visibility, DesignMode { - /** - * The global lock on changing any BeanContext hierarchy. - * It kinda sucks that there is only one lock, since there can be - * multiple hierarchies. Oh well, I didn't design, I just code. - * <P> - * - * Methods that must (or do) synchronize on the global lock: - * <BR> - * <UL> - * <LI> - * Implementors of <CODE>BeanContext.add()</CODE> and <code>addAll()</code> - * </LI> - * </UL> - * @fixme fill in the rest of the methods which use the global lock. - */ - Object globalHierarchyLock = new Object(); + /** + * The global lock on changing any BeanContext hierarchy. + * It kinda sucks that there is only one lock, since there can be + * multiple hierarchies. Oh well, I didn't design, I just code. + * <P> + * + * Methods that must (or do) synchronize on the global lock: + * <BR> + * <UL> + * <LI> + * Implementors of <CODE>BeanContext.add()</CODE> and <code>addAll()</code> + * </LI> + * </UL> + * @fixme fill in the rest of the methods which use the global lock. + */ + Object globalHierarchyLock = new Object(); - /** - * Instantiate a Bean using this Bean's <code>ClassLoader</code> - * and this <code>BeanContext</code> as the parent. - * <P> - * - * This method exists mainly so that <code>BeanContext</code> - * implementations can perform extra actions on Beans that are - * created within them. - * - * @param beanName the name of the bean to instantiate - * @return the created Bean - * - * @see java.beans.Beans#instantiate(java.lang.ClassLoader,java.lang.String) - * @see java.beans.Beans#instantiate(java.lang.ClassLoader,java.lang.String,java.beans.beancontext.BeanContext) - * @exception IOException if there is an I/O problem during - * instantiation. - * @exception ClassNotFoundException if a serialized Bean's class - * is not found. - */ - Object instantiateChild(String beanName) + /** + * Instantiate a Bean using this Bean's <code>ClassLoader</code> + * and this <code>BeanContext</code> as the parent. + * <P> + * + * This method exists mainly so that <code>BeanContext</code> + * implementations can perform extra actions on Beans that are + * created within them. + * + * @param beanName the name of the bean to instantiate + * @return the created Bean + * + * @see java.beans.Beans#instantiate(java.lang.ClassLoader,java.lang.String) + * @see java.beans.Beans#instantiate(java.lang.ClassLoader,java.lang.String,java.beans.beancontext.BeanContext) + * @exception IOException if there is an I/O problem during + * instantiation. + * @exception ClassNotFoundException if a serialized Bean's class + * is not found. + */ + Object instantiateChild(String beanName) throws IOException, ClassNotFoundException; - /** - * Get a resource. The <code>BeanContext</code> will typically - * call <code>ClassLoader.getResource()</code>, but may do it any - * way it wants to. This allows a <code>BeanContext</code> to - * have its own set of resources separate from the rest of the - * system. - * <P> - * - * Beans should call this method on their parent rather than the - * associated <code>ClassLoader</code> method. - * <P> - * - * I am assuming, but am not entirely sure, that if a - * <code>BeanContext</code> cannot find a resource, its - * responsibility is to call the <code>getResource</code> method - * of its parent <code>BeanContext</code>. - * - * @return a URL to the requested resource. - * @param resourceName the name of the resource requested. - * @param requestor a reference to the child requesting the resource. - * @see java.lang.ClassLoader#getResource(java.lang.String) - */ - URL getResource(String resourceName, BeanContextChild requestor); + /** + * Get a resource. The <code>BeanContext</code> will typically + * call <code>ClassLoader.getResource()</code>, but may do it any + * way it wants to. This allows a <code>BeanContext</code> to + * have its own set of resources separate from the rest of the + * system. + * <P> + * + * Beans should call this method on their parent rather than the + * associated <code>ClassLoader</code> method. + * <P> + * + * I am assuming, but am not entirely sure, that if a + * <code>BeanContext</code> cannot find a resource, its + * responsibility is to call the <code>getResource</code> method + * of its parent <code>BeanContext</code>. + * + * @return a URL to the requested resource. + * @param resourceName the name of the resource requested. + * @param requestor a reference to the child requesting the resource. + * @see java.lang.ClassLoader#getResource(java.lang.String) + */ + URL getResource(String resourceName, BeanContextChild requestor); - /** - * Get a resource as a stream. The <code>BeanContext</code> will - * typically call <code>ClassLoader.getResourceAsStream()</code>, - * but may do it any way it wants to. This allows a - * <code>BeanContext</code>'s children to have their own set of - * resources separate from the rest of the system. - * <P> - * - * Beans should call this method on their parent rather than the - * associated <code>ClassLoader</code> method. - * <P> - * - * I am assuming, but am not entirely sure, that if a - * <code>BeanContext</code> cannot find a resource, its - * responsibility is to call the <code>getResourceAsStream</code> - * method of its parent <code>BeanContext</code>. - * - * @return the requested resource as a stream. - * @param resourceName the name of the resource requested. - * @param requestor a reference to the child requesting the resource. - * @see java.lang.ClassLoader#getResourceAsStream(java.lang.String) - */ - InputStream getResourceAsStream(String resourceName, BeanContextChild requestor); + /** + * Get a resource as a stream. The <code>BeanContext</code> will + * typically call <code>ClassLoader.getResourceAsStream()</code>, + * but may do it any way it wants to. This allows a + * <code>BeanContext</code>'s children to have their own set of + * resources separate from the rest of the system. + * <P> + * + * Beans should call this method on their parent rather than the + * associated <code>ClassLoader</code> method. + * <P> + * + * I am assuming, but am not entirely sure, that if a + * <code>BeanContext</code> cannot find a resource, its + * responsibility is to call the <code>getResourceAsStream</code> + * method of its parent <code>BeanContext</code>. + * + * @return the requested resource as a stream. + * @param resourceName the name of the resource requested. + * @param requestor a reference to the child requesting the resource. + * @see java.lang.ClassLoader#getResourceAsStream(java.lang.String) + */ + InputStream getResourceAsStream(String resourceName, BeanContextChild requestor); - /** - * Add a listener on changes to the membership of this - * <code>BeanContext</code> object. - * @param listener the listener to add. - */ - void addBeanContextMembershipListener(BeanContextMembershipListener listener); + /** + * Add a listener on changes to the membership of this + * <code>BeanContext</code> object. + * @param listener the listener to add. + */ + void addBeanContextMembershipListener(BeanContextMembershipListener listener); - /** - * Remove a listener on changes to the membership of this - * <code>BeanContext</code> object. - * @param listener the listener to remove. - */ - void removeBeanContextMembershipListener(BeanContextMembershipListener listener); + /** + * Remove a listener on changes to the membership of this + * <code>BeanContext</code> object. + * @param listener the listener to remove. + */ + void removeBeanContextMembershipListener(BeanContextMembershipListener listener); } diff --git a/java/beans/beancontext/BeanContextChild.java b/java/beans/beancontext/BeanContextChild.java index d1115efac..e2bdcf336 100644 --- a/java/beans/beancontext/BeanContextChild.java +++ b/java/beans/beancontext/BeanContextChild.java @@ -7,7 +7,7 @@ GNU Classpath is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2, or (at your option) any later version. - + GNU Classpath is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU @@ -77,98 +77,98 @@ import java.beans.VetoableChangeListener; */ public interface BeanContextChild { - /** - * Set the parent <code>BeanContext</code>. - * <P> - * - * This method is called from <code>BeanContext.add()</code> and - * should not be called directly. - * <P> - * - * When this Object is being added to a new BeanContext or moved - * from an old one, a non-null value will be passed in. - * <P> - * - * When this Object is being removed from the current - * <code>BeanContext</code>, <code>setBeanContext()</code> will - * receive the parameter <code>null</code>. - * <P> - * - * When being removed from the current <code>BeanContext</code>, - * it is the <code>BeanContextChild</code>'s responsibility to - * release all services it has obtained. - * <P> - * - * This change should generate <code>PropertyChangeEvent</code> - * and <code>VetoableChangeEvent</code>s with the property name - * "beanContext". If the change is vetoed, it must re-throw the - * exception and not change anything. In this way, the parent - * <code>BeanContextChild</code>, who has registered himself with - * you, will have a chance to remove this child from its - * collection. - * <P> - * - * If the Bean does not wish to change the parent or be removed - * from one, it may throw the <code>PropertyVetoException</code>. - * If you veto a <code>setBeanContext(null)</code> call, then you - * should try your hardest to remedy whatever problem is keeping - * you from being removed from the <code>BeanContext</code> so - * that you can <em>not</em> veto it the next time. - * Otherwise, nasty pathological recursion stuff could occur in - * certain situations. - * <P> - * - * If you do veto the change, you must first back out any changes - * you made prior to the veto. Best not to make any such changes - * prior to the veto in the first place. - * <P> - * - * This method is called from <code>BeanContext.add()</code> and - * should not be called directly. - * - * @param parent the new parent for the <code>BeanContextChild</code>, - * or <code>null</code> to signify removal from a tree. - * @exception PropertyVetoException if the - * <code>BeanContextChild</code> implementor does not - * wish to have its parent changed. - */ - void setBeanContext(BeanContext parent) - throws PropertyVetoException; - - /** - * Get the parent <code>BeanContext</code>. - * @return the parent <code>BeanContext</code>. - */ - BeanContext getBeanContext(); - - /** - * Add a listener that will be notified when a specific property changes. - * @param prop the name of the property to listen on - * @param listener the listener to listen on the property. - */ - void addPropertyChangeListener(String prop, PropertyChangeListener listener); - - /** - * Remove a listener to a certain property. - * @param prop the name of the property being listened on - * @param listener the listener listening on the property. - */ - void removePropertyChangeListener(String prop, PropertyChangeListener listener); - - /** - * Add a listener that will be notified when a specific property - * change is requested (a PropertyVetoException may be thrown) as - * well as after the change is successfully made. - * - * @param prop the name of the property to listen on - * @param listener the listener to listen on the property. - */ - void addVetoableChangeListener(String prop, VetoableChangeListener listener); - - /** - * Remove a listener to a certain property. - * @param prop the name of the property being listened on - * @param listener the listener listening on the property. - */ - void removeVetoableChangeListener(String prop, VetoableChangeListener listener); + /** + * Set the parent <code>BeanContext</code>. + * <P> + * + * This method is called from <code>BeanContext.add()</code> and + * should not be called directly. + * <P> + * + * When this Object is being added to a new BeanContext or moved + * from an old one, a non-null value will be passed in. + * <P> + * + * When this Object is being removed from the current + * <code>BeanContext</code>, <code>setBeanContext()</code> will + * receive the parameter <code>null</code>. + * <P> + * + * When being removed from the current <code>BeanContext</code>, + * it is the <code>BeanContextChild</code>'s responsibility to + * release all services it has obtained. + * <P> + * + * This change should generate <code>PropertyChangeEvent</code> + * and <code>VetoableChangeEvent</code>s with the property name + * "beanContext". If the change is vetoed, it must re-throw the + * exception and not change anything. In this way, the parent + * <code>BeanContextChild</code>, who has registered himself with + * you, will have a chance to remove this child from its + * collection. + * <P> + * + * If the Bean does not wish to change the parent or be removed + * from one, it may throw the <code>PropertyVetoException</code>. + * If you veto a <code>setBeanContext(null)</code> call, then you + * should try your hardest to remedy whatever problem is keeping + * you from being removed from the <code>BeanContext</code> so + * that you can <em>not</em> veto it the next time. + * Otherwise, nasty pathological recursion stuff could occur in + * certain situations. + * <P> + * + * If you do veto the change, you must first back out any changes + * you made prior to the veto. Best not to make any such changes + * prior to the veto in the first place. + * <P> + * + * This method is called from <code>BeanContext.add()</code> and + * should not be called directly. + * + * @param parent the new parent for the <code>BeanContextChild</code>, + * or <code>null</code> to signify removal from a tree. + * @exception PropertyVetoException if the + * <code>BeanContextChild</code> implementor does not + * wish to have its parent changed. + */ + void setBeanContext(BeanContext parent) + throws PropertyVetoException; + + /** + * Get the parent <code>BeanContext</code>. + * @return the parent <code>BeanContext</code>. + */ + BeanContext getBeanContext(); + + /** + * Add a listener that will be notified when a specific property changes. + * @param prop the name of the property to listen on + * @param listener the listener to listen on the property. + */ + void addPropertyChangeListener(String prop, PropertyChangeListener listener); + + /** + * Remove a listener to a certain property. + * @param prop the name of the property being listened on + * @param listener the listener listening on the property. + */ + void removePropertyChangeListener(String prop, PropertyChangeListener listener); + + /** + * Add a listener that will be notified when a specific property + * change is requested (a PropertyVetoException may be thrown) as + * well as after the change is successfully made. + * + * @param prop the name of the property to listen on + * @param listener the listener to listen on the property. + */ + void addVetoableChangeListener(String prop, VetoableChangeListener listener); + + /** + * Remove a listener to a certain property. + * @param prop the name of the property being listened on + * @param listener the listener listening on the property. + */ + void removeVetoableChangeListener(String prop, VetoableChangeListener listener); } diff --git a/java/beans/beancontext/BeanContextChildComponentProxy.java b/java/beans/beancontext/BeanContextChildComponentProxy.java index a8d6e3404..cb75d508d 100644 --- a/java/beans/beancontext/BeanContextChildComponentProxy.java +++ b/java/beans/beancontext/BeanContextChildComponentProxy.java @@ -7,7 +7,7 @@ GNU Classpath is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2, or (at your option) any later version. - + GNU Classpath is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU @@ -51,10 +51,10 @@ import java.awt.Component; */ public interface BeanContextChildComponentProxy { - /** - * Get the <code>Component</code> associated with this <code>BeanContextChild</code>. - * @return the <code>Component</code> associated with this - * <code>BeanContextChild</code>. - */ - Component getComponent(); + /** + * Get the <code>Component</code> associated with this <code>BeanContextChild</code>. + * @return the <code>Component</code> associated with this + * <code>BeanContextChild</code>. + */ + Component getComponent(); } diff --git a/java/beans/beancontext/BeanContextChildSupport.java b/java/beans/beancontext/BeanContextChildSupport.java index 4444ad713..8cd887d0c 100644 --- a/java/beans/beancontext/BeanContextChildSupport.java +++ b/java/beans/beancontext/BeanContextChildSupport.java @@ -7,7 +7,7 @@ GNU Classpath is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2, or (at your option) any later version. - + GNU Classpath is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU @@ -64,121 +64,121 @@ public class BeanContextChildSupport { static final long serialVersionUID = 6328947014421475877L; - /** - * The peer on which to perform <code>set</code> actions. - * This is here so that this class can be used as a peer. - * <P> - * - * When extending this class, this variable will be set to - * <code>this</code>. - */ - public BeanContextChild beanContextChildPeer; - - /** - * The parent <code>BeanContext</code>. - */ - protected transient BeanContext beanContext; - - /** - * If <code>setBeanContext()</code> was vetoed once before, this - * is set to <code>true</code> so that the next time, vetoes will - * be ignored. - */ - protected transient boolean rejectedSetBCOnce; - - /** - * Listeners are registered here and events are fired through here. - */ - protected PropertyChangeSupport pcSupport; - - /** - * Listeners are registered here and events are fired through here. - */ - protected VetoableChangeSupport vcSupport; - - /** - * Create a new <code>BeanContextChildSupport</code> with itself as the peer. - * This is meant to be used when you subclass - * <code>BeanContextChildSupport</code> to create your child. - */ - public BeanContextChildSupport() + /** + * The peer on which to perform <code>set</code> actions. + * This is here so that this class can be used as a peer. + * <P> + * + * When extending this class, this variable will be set to + * <code>this</code>. + */ + public BeanContextChild beanContextChildPeer; + + /** + * The parent <code>BeanContext</code>. + */ + protected transient BeanContext beanContext; + + /** + * If <code>setBeanContext()</code> was vetoed once before, this + * is set to <code>true</code> so that the next time, vetoes will + * be ignored. + */ + protected transient boolean rejectedSetBCOnce; + + /** + * Listeners are registered here and events are fired through here. + */ + protected PropertyChangeSupport pcSupport; + + /** + * Listeners are registered here and events are fired through here. + */ + protected VetoableChangeSupport vcSupport; + + /** + * Create a new <code>BeanContextChildSupport</code> with itself as the peer. + * This is meant to be used when you subclass + * <code>BeanContextChildSupport</code> to create your child. + */ + public BeanContextChildSupport() { - this (null); - } - - /** - * Create a new <code>BeanContextChildSupport</code> with the specified peer. - * @param peer the peer to use, or <code>null</code> to specify - * <code>this</code>. - */ - public BeanContextChildSupport (BeanContextChild peer) + this (null); + } + + /** + * Create a new <code>BeanContextChildSupport</code> with the specified peer. + * @param peer the peer to use, or <code>null</code> to specify + * <code>this</code>. + */ + public BeanContextChildSupport (BeanContextChild peer) { - if (peer == null) + if (peer == null) { peer = this; } - beanContextChildPeer = peer; - pcSupport = new PropertyChangeSupport (peer); - vcSupport = new VetoableChangeSupport (peer); - } - - /** - * Set the parent <code>BeanContext</code>. - * <P> - * - * When this Object is being added to a new BeanContext or moved - * from an old one, a non-null value will be passed in. - * <P> - * - * When this Object is being removed from the current - * <code>BeanContext</code>, <code>setBeanContext()</code> will - * receive the parameter <code>null</code>. - * <P> - * - * Order of events: - * <OL> - * <LI> - * If the new <code>BeanContext</code> is the same as the old - * one, nothing happens. - * </LI> - * <LI> - * If the change has not been rejected or vetoed before, call - * <code>validatePendingSetBeanContext()</code>. If this call - * returns <code>false</code>, the change is rejected and a - * <code>PropertyVetoException</code> is thrown. - * </LI> - * <LI> - * If the change has not been rejected or vetoed before, - * <code>VetoableChangeEvent</code>s are fired with the name - * <code>"beanContext"</code>, using the - * <code>fireVetoableChange()</code> method. If a veto - * occurs, reversion events are fired using the same method, - * the change is rejected, and the veto is rethrown. - * </LI> - * <LI> - * <code>releaseBeanContextResources()</code> is called. - * </LI> - * <LI> - * The change is made. - * </LI> - * <LI> - * <code>PropertyChangeEvent</code>s are fired using the - * <code>firePropertyChange()</code> method. - * </LI> - * <LI> - * <code>initializeBeanContextResources()</code> is called. - * </LI> - * </OL> - * <P> - * - * @param newBeanContext the new parent for the - * <code>BeanContextChild</code>, or <code>null</code> to - * signify removal from a tree. - * @exception PropertyVetoException if the - * <code>BeanContextChild</code> implementor does not - * wish to have its parent changed. - */ + beanContextChildPeer = peer; + pcSupport = new PropertyChangeSupport (peer); + vcSupport = new VetoableChangeSupport (peer); + } + + /** + * Set the parent <code>BeanContext</code>. + * <P> + * + * When this Object is being added to a new BeanContext or moved + * from an old one, a non-null value will be passed in. + * <P> + * + * When this Object is being removed from the current + * <code>BeanContext</code>, <code>setBeanContext()</code> will + * receive the parameter <code>null</code>. + * <P> + * + * Order of events: + * <OL> + * <LI> + * If the new <code>BeanContext</code> is the same as the old + * one, nothing happens. + * </LI> + * <LI> + * If the change has not been rejected or vetoed before, call + * <code>validatePendingSetBeanContext()</code>. If this call + * returns <code>false</code>, the change is rejected and a + * <code>PropertyVetoException</code> is thrown. + * </LI> + * <LI> + * If the change has not been rejected or vetoed before, + * <code>VetoableChangeEvent</code>s are fired with the name + * <code>"beanContext"</code>, using the + * <code>fireVetoableChange()</code> method. If a veto + * occurs, reversion events are fired using the same method, + * the change is rejected, and the veto is rethrown. + * </LI> + * <LI> + * <code>releaseBeanContextResources()</code> is called. + * </LI> + * <LI> + * The change is made. + * </LI> + * <LI> + * <code>PropertyChangeEvent</code>s are fired using the + * <code>firePropertyChange()</code> method. + * </LI> + * <LI> + * <code>initializeBeanContextResources()</code> is called. + * </LI> + * </OL> + * <P> + * + * @param newBeanContext the new parent for the + * <code>BeanContextChild</code>, or <code>null</code> to + * signify removal from a tree. + * @exception PropertyVetoException if the + * <code>BeanContextChild</code> implementor does not + * wish to have its parent changed. + */ public void setBeanContext(BeanContext newBeanContext) throws PropertyVetoException { @@ -195,7 +195,7 @@ public class BeanContextChildSupport throw new PropertyVetoException ("validatePendingSetBeanContext() rejected change", new PropertyChangeEvent(beanContextChildPeer, "beanContext", beanContext, newBeanContext)); } - + try { fireVetoableChange ("beanContext", beanContext, newBeanContext); @@ -207,175 +207,175 @@ public class BeanContextChildSupport } } - releaseBeanContextResources (); + releaseBeanContextResources (); - beanContext = newBeanContext; - rejectedSetBCOnce = false; + beanContext = newBeanContext; + rejectedSetBCOnce = false; - firePropertyChange ("beanContext", beanContext, newBeanContext); + firePropertyChange ("beanContext", beanContext, newBeanContext); - initializeBeanContextResources (); - } - } + initializeBeanContextResources (); + } + } - /** - * Get the parent <code>BeanContext</code>. - * @return the parent <code>BeanContext</code>. - */ - public BeanContext getBeanContext() + /** + * Get the parent <code>BeanContext</code>. + * @return the parent <code>BeanContext</code>. + */ + public BeanContext getBeanContext() { - return beanContext; - } - - /** - * Get the peer (or <code>this</code> if there is no peer). - * @return the peer, or <code>this</code> if there is no peer. - */ - public BeanContextChild getBeanContextChildPeer() { - return beanContextChildPeer; - } - - /** - * Determine whether there is a peer. - * This is true iff <code>getBeanContextChildPeer() == this</code>. - * @return whether there is a peer. - */ - public boolean isDelegated() { - return beanContextChildPeer == this; - } - - /** - * Add a listener that will be notified when a specific property changes. - * @param propertyName the name of the property to listen on. - * @param listener the listener to listen on the property. - */ - public void addPropertyChangeListener(String propertyName, PropertyChangeListener listener) { - pcSupport.addPropertyChangeListener(propertyName, listener); - } - - /** - * Remove a listener to a certain property. - * - * @param propertyName the name of the property being listened on. - * @param listener the listener listening on the property. - */ - public void removePropertyChangeListener(String propertyName, PropertyChangeListener listener) { - pcSupport.removePropertyChangeListener(propertyName, listener); - } - - /** - * Add a listener that will be notified when a specific property - * change is requested (a PropertyVetoException may be thrown) as - * well as after the change is successfully made. - * - * @param propertyName the name of the property to listen on. - * @param listener the listener to listen on the property. - */ - public void addVetoableChangeListener(String propertyName, VetoableChangeListener listener) { - vcSupport.addVetoableChangeListener(propertyName, listener); - } - - /** - * Remove a listener to a certain property. - * - * @param propertyName the name of the property being listened on - * @param listener the listener listening on the property. - */ - public void removeVetoableChangeListener(String propertyName, VetoableChangeListener listener) { - vcSupport.removeVetoableChangeListener(propertyName, listener); - } - - /** - * Fire a property change. - * - * @param propertyName the name of the property that changed - * @param oldVal the old value of the property - * @param newVal the new value of the property - */ - public void firePropertyChange(String propertyName, Object oldVal, Object newVal) { - pcSupport.firePropertyChange(propertyName, oldVal, newVal); - } - - /** - * Fire a vetoable property change. - * - * @param propertyName the name of the property that changed - * @param oldVal the old value of the property - * @param newVal the new value of the property - * @exception PropertyVetoException if the change is vetoed. - */ - public void fireVetoableChange(String propertyName, Object oldVal, Object newVal) + return beanContext; + } + + /** + * Get the peer (or <code>this</code> if there is no peer). + * @return the peer, or <code>this</code> if there is no peer. + */ + public BeanContextChild getBeanContextChildPeer() { + return beanContextChildPeer; + } + + /** + * Determine whether there is a peer. + * This is true iff <code>getBeanContextChildPeer() == this</code>. + * @return whether there is a peer. + */ + public boolean isDelegated() { + return beanContextChildPeer == this; + } + + /** + * Add a listener that will be notified when a specific property changes. + * @param propertyName the name of the property to listen on. + * @param listener the listener to listen on the property. + */ + public void addPropertyChangeListener(String propertyName, PropertyChangeListener listener) { + pcSupport.addPropertyChangeListener(propertyName, listener); + } + + /** + * Remove a listener to a certain property. + * + * @param propertyName the name of the property being listened on. + * @param listener the listener listening on the property. + */ + public void removePropertyChangeListener(String propertyName, PropertyChangeListener listener) { + pcSupport.removePropertyChangeListener(propertyName, listener); + } + + /** + * Add a listener that will be notified when a specific property + * change is requested (a PropertyVetoException may be thrown) as + * well as after the change is successfully made. + * + * @param propertyName the name of the property to listen on. + * @param listener the listener to listen on the property. + */ + public void addVetoableChangeListener(String propertyName, VetoableChangeListener listener) { + vcSupport.addVetoableChangeListener(propertyName, listener); + } + + /** + * Remove a listener to a certain property. + * + * @param propertyName the name of the property being listened on + * @param listener the listener listening on the property. + */ + public void removeVetoableChangeListener(String propertyName, VetoableChangeListener listener) { + vcSupport.removeVetoableChangeListener(propertyName, listener); + } + + /** + * Fire a property change. + * + * @param propertyName the name of the property that changed + * @param oldVal the old value of the property + * @param newVal the new value of the property + */ + public void firePropertyChange(String propertyName, Object oldVal, Object newVal) { + pcSupport.firePropertyChange(propertyName, oldVal, newVal); + } + + /** + * Fire a vetoable property change. + * + * @param propertyName the name of the property that changed + * @param oldVal the old value of the property + * @param newVal the new value of the property + * @exception PropertyVetoException if the change is vetoed. + */ + public void fireVetoableChange(String propertyName, Object oldVal, Object newVal) throws PropertyVetoException { - vcSupport.fireVetoableChange(propertyName, oldVal, newVal); - } - - /** - * Called by <code>BeanContextServices.revokeService()</code> to indicate that a service has been revoked. - * If you have a reference to such a service, it should be - * discarded and may no longer function properly. - * <code>getService()</code> will no longer work on the specified - * service class after this event has been fired. - * <P> - * - * <EM>This method is meant to be overriden.</EM> - * <code>BeanContextChildSupport</code>'s implementation does - * nothing. - * - * @param event the service revoked event. - * @see java.beans.beancontext.BeanContextServices#revokeService(java.lang.Class,java.beans.beancontext.BeanContextServiceProvider,boolean) - */ - public void serviceRevoked(BeanContextServiceRevokedEvent event) { - } - - /** - * Called by <code>BeanContextServices</code> whenever a service is made available. - * <P> - * - * <EM>This method is meant to be overriden.</EM> - * <code>BeanContextChildSupport</code>'s implementation does - * nothing. - * - * @param event the service revoked event, with useful information - * about the new service. - */ - public void serviceAvailable(BeanContextServiceAvailableEvent event) { - } - - /** - * Called by <code>setBeanContext()</code> to determine whether the set should be rejected. - * <P> - * - * <EM>This method is meant to be overriden.</EM> - * <code>BeanContextChildSupport</code>'s implementation simply - * returns <code>true</code>. - * - * @param newBeanContext the new parent. - * @return whether to allow the parent to be changed to the new - * value. - */ - public boolean validatePendingSetBeanContext(BeanContext newBeanContext) { - return true; - } - - /** - * Called by <code>setBeanContext()</code> to release resources of a what will soon no longer be the parent. - * <P> - * - * <EM>This method is meant to be overriden.</EM> - * <code>BeanContextChildSupport</code>'s implementation does - * nothing. - */ - protected void releaseBeanContextResources() { - } - - /** - * Called by <code>setBeanContext()</code> to grab resources when the parent has been set. - * <P> - * - * <EM>This method is meant to be overriden.</EM> - * <code>BeanContextChildSupport</code>'s implementation does - * nothing. - */ - protected void initializeBeanContextResources() { - } + vcSupport.fireVetoableChange(propertyName, oldVal, newVal); + } + + /** + * Called by <code>BeanContextServices.revokeService()</code> to indicate that a service has been revoked. + * If you have a reference to such a service, it should be + * discarded and may no longer function properly. + * <code>getService()</code> will no longer work on the specified + * service class after this event has been fired. + * <P> + * + * <EM>This method is meant to be overriden.</EM> + * <code>BeanContextChildSupport</code>'s implementation does + * nothing. + * + * @param event the service revoked event. + * @see java.beans.beancontext.BeanContextServices#revokeService(java.lang.Class,java.beans.beancontext.BeanContextServiceProvider,boolean) + */ + public void serviceRevoked(BeanContextServiceRevokedEvent event) { + } + + /** + * Called by <code>BeanContextServices</code> whenever a service is made available. + * <P> + * + * <EM>This method is meant to be overriden.</EM> + * <code>BeanContextChildSupport</code>'s implementation does + * nothing. + * + * @param event the service revoked event, with useful information + * about the new service. + */ + public void serviceAvailable(BeanContextServiceAvailableEvent event) { + } + + /** + * Called by <code>setBeanContext()</code> to determine whether the set should be rejected. + * <P> + * + * <EM>This method is meant to be overriden.</EM> + * <code>BeanContextChildSupport</code>'s implementation simply + * returns <code>true</code>. + * + * @param newBeanContext the new parent. + * @return whether to allow the parent to be changed to the new + * value. + */ + public boolean validatePendingSetBeanContext(BeanContext newBeanContext) { + return true; + } + + /** + * Called by <code>setBeanContext()</code> to release resources of a what will soon no longer be the parent. + * <P> + * + * <EM>This method is meant to be overriden.</EM> + * <code>BeanContextChildSupport</code>'s implementation does + * nothing. + */ + protected void releaseBeanContextResources() { + } + + /** + * Called by <code>setBeanContext()</code> to grab resources when the parent has been set. + * <P> + * + * <EM>This method is meant to be overriden.</EM> + * <code>BeanContextChildSupport</code>'s implementation does + * nothing. + */ + protected void initializeBeanContextResources() { + } } diff --git a/java/beans/beancontext/BeanContextContainerProxy.java b/java/beans/beancontext/BeanContextContainerProxy.java index 3df91038b..962cb5fc9 100644 --- a/java/beans/beancontext/BeanContextContainerProxy.java +++ b/java/beans/beancontext/BeanContextContainerProxy.java @@ -7,7 +7,7 @@ GNU Classpath is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2, or (at your option) any later version. - + GNU Classpath is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU @@ -54,10 +54,10 @@ import java.awt.Container; */ public interface BeanContextContainerProxy { - /** - * Get the <code>Container</code> associated with this <code>BeanContext</code>. - * @return the <code>Container</code> associated with this - * <code>BeanContext</code>. - */ - Container getContainer(); + /** + * Get the <code>Container</code> associated with this <code>BeanContext</code>. + * @return the <code>Container</code> associated with this + * <code>BeanContext</code>. + */ + Container getContainer(); } diff --git a/java/beans/beancontext/BeanContextEvent.java b/java/beans/beancontext/BeanContextEvent.java index f326541b0..959d54e58 100644 --- a/java/beans/beancontext/BeanContextEvent.java +++ b/java/beans/beancontext/BeanContextEvent.java @@ -7,7 +7,7 @@ GNU Classpath is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2, or (at your option) any later version. - + GNU Classpath is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU @@ -50,7 +50,7 @@ import java.util.EventObject; public abstract class BeanContextEvent extends EventObject { private static final long serialVersionUID = 7267998073569045052L; - + /** * The <code>BeanContext</code> that most recently passed this * event on. diff --git a/java/beans/beancontext/BeanContextMembershipEvent.java b/java/beans/beancontext/BeanContextMembershipEvent.java index 9560889f8..77b1be43e 100644 --- a/java/beans/beancontext/BeanContextMembershipEvent.java +++ b/java/beans/beancontext/BeanContextMembershipEvent.java @@ -7,7 +7,7 @@ GNU Classpath is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2, or (at your option) any later version. - + GNU Classpath is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU @@ -55,60 +55,60 @@ public class BeanContextMembershipEvent extends BeanContextEvent { private static final long serialVersionUID = 3499346510334590959L; /** - * The children that were added or removed. - */ - protected Collection children; - - /** - * Create a new membership event. - * @param context the event source. - * @param children the children added to or removed from the source. - */ - public BeanContextMembershipEvent(BeanContext context, Collection children) { - super(context); - this.children = children; - } - - /** - * Create a new membership event. - * @param context the event source. - * @param children the children added to or removed from the source. - */ - public BeanContextMembershipEvent(BeanContext context, Object[] children) { - super(context); - this.children = Arrays.asList(children); - } - - /** - * The number of children removed or added. - * @return the number of children removed or added. - */ - public int size() { - return children.size(); - } - - /** - * An iterator that will step through all the children. - * @return an iterator over all the children. - */ - public Iterator iterator() { - return children.iterator(); - } - - /** - * An array of the children. - * @return an array of the children. - */ - public Object[] toArray() { - return children.toArray(); - } - - /** - * Tell whether the <code>Object</code> is one of the children added or removed. - * @param child the child to check. - * @return whether the <code>Object</code> is added or removed. - */ - public boolean contains(Object child) { - return children.contains(child); - } + * The children that were added or removed. + */ + protected Collection children; + + /** + * Create a new membership event. + * @param context the event source. + * @param children the children added to or removed from the source. + */ + public BeanContextMembershipEvent(BeanContext context, Collection children) { + super(context); + this.children = children; + } + + /** + * Create a new membership event. + * @param context the event source. + * @param children the children added to or removed from the source. + */ + public BeanContextMembershipEvent(BeanContext context, Object[] children) { + super(context); + this.children = Arrays.asList(children); + } + + /** + * The number of children removed or added. + * @return the number of children removed or added. + */ + public int size() { + return children.size(); + } + + /** + * An iterator that will step through all the children. + * @return an iterator over all the children. + */ + public Iterator iterator() { + return children.iterator(); + } + + /** + * An array of the children. + * @return an array of the children. + */ + public Object[] toArray() { + return children.toArray(); + } + + /** + * Tell whether the <code>Object</code> is one of the children added or removed. + * @param child the child to check. + * @return whether the <code>Object</code> is added or removed. + */ + public boolean contains(Object child) { + return children.contains(child); + } } diff --git a/java/beans/beancontext/BeanContextMembershipListener.java b/java/beans/beancontext/BeanContextMembershipListener.java index d39c36c4b..cdb47c811 100644 --- a/java/beans/beancontext/BeanContextMembershipListener.java +++ b/java/beans/beancontext/BeanContextMembershipListener.java @@ -7,7 +7,7 @@ GNU Classpath is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2, or (at your option) any later version. - + GNU Classpath is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU @@ -50,21 +50,21 @@ import java.util.EventListener; */ public interface BeanContextMembershipListener extends EventListener { - /** - * When beans are added to a <code>BeanContext</code>, - * this method is called to fire the event. - * - * @param event the event, including which children were added. - * @see java.beans.beancontext.BeanContext#add(java.lang.Object) - */ - void childrenAdded(BeanContextMembershipEvent event); + /** + * When beans are added to a <code>BeanContext</code>, + * this method is called to fire the event. + * + * @param event the event, including which children were added. + * @see java.beans.beancontext.BeanContext#add(java.lang.Object) + */ + void childrenAdded(BeanContextMembershipEvent event); - /** - * When beans are removed from a <code>BeanContext</code>, - * this method is called to fire the event. - * - * @param event the event, including which children were removed. - * @see java.beans.beancontext.BeanContext#remove(java.lang.Object) - */ - void childrenRemoved(BeanContextMembershipEvent event); + /** + * When beans are removed from a <code>BeanContext</code>, + * this method is called to fire the event. + * + * @param event the event, including which children were removed. + * @see java.beans.beancontext.BeanContext#remove(java.lang.Object) + */ + void childrenRemoved(BeanContextMembershipEvent event); } diff --git a/java/beans/beancontext/BeanContextProxy.java b/java/beans/beancontext/BeanContextProxy.java index 49dd7a77f..53632e86b 100644 --- a/java/beans/beancontext/BeanContextProxy.java +++ b/java/beans/beancontext/BeanContextProxy.java @@ -7,7 +7,7 @@ GNU Classpath is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2, or (at your option) any later version. - + GNU Classpath is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU @@ -54,12 +54,12 @@ package java.beans.beancontext; */ public interface BeanContextProxy { - /** - * Return the <code>BeanContextChild</code> associated with this - * <code>Object</code>. - * - * @return the <code>BeanContextChild</code> associated with this - * <code>Object</code>. - */ - BeanContextChild getBeanContextProxy(); + /** + * Return the <code>BeanContextChild</code> associated with this + * <code>Object</code>. + * + * @return the <code>BeanContextChild</code> associated with this + * <code>Object</code>. + */ + BeanContextChild getBeanContextProxy(); } diff --git a/java/beans/beancontext/BeanContextServiceAvailableEvent.java b/java/beans/beancontext/BeanContextServiceAvailableEvent.java index 6dc2c38ab..a2bdcdde7 100644 --- a/java/beans/beancontext/BeanContextServiceAvailableEvent.java +++ b/java/beans/beancontext/BeanContextServiceAvailableEvent.java @@ -7,7 +7,7 @@ GNU Classpath is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2, or (at your option) any later version. - + GNU Classpath is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU @@ -52,46 +52,46 @@ public class BeanContextServiceAvailableEvent extends BeanContextEvent { private static final long serialVersionUID = -5333985775656400778L; /** - * The <code>Class</code> representing the service which is now - * available. - */ - protected Class serviceClass; - - /** - * Create a new service available event. - * @param services the <code>BeanContextServices</code> through - * which the service is available. This is also the source - * of the event. - * @param serviceClass the service class that is now available. - */ - public BeanContextServiceAvailableEvent(BeanContextServices services, Class serviceClass) { - super(services); - this.serviceClass = serviceClass; - } - - /** - * Get the current service selectors of the service class. - * This is identical to <code>getSourceAsBeanContextServices().getCurrentServiceSelectors(getServiceClass())</code> - * @return the current service selectors of the service class. - */ - public Iterator getCurrentServiceSelectors() { - return getSourceAsBeanContextServices().getCurrentServiceSelectors(serviceClass); - } - - /** - * Get the newly available service class. - * @return the service class. - */ - public Class getServiceClass() { - return serviceClass; - } - - /** - * Get the <code>BeanContextServices</code> through which the new service is available. - * @return the <code>BeanContextServices</code> through which the - * new service is available. - */ - public BeanContextServices getSourceAsBeanContextServices() { - return (BeanContextServices)getSource(); - } + * The <code>Class</code> representing the service which is now + * available. + */ + protected Class serviceClass; + + /** + * Create a new service available event. + * @param services the <code>BeanContextServices</code> through + * which the service is available. This is also the source + * of the event. + * @param serviceClass the service class that is now available. + */ + public BeanContextServiceAvailableEvent(BeanContextServices services, Class serviceClass) { + super(services); + this.serviceClass = serviceClass; + } + + /** + * Get the current service selectors of the service class. + * This is identical to <code>getSourceAsBeanContextServices().getCurrentServiceSelectors(getServiceClass())</code> + * @return the current service selectors of the service class. + */ + public Iterator getCurrentServiceSelectors() { + return getSourceAsBeanContextServices().getCurrentServiceSelectors(serviceClass); + } + + /** + * Get the newly available service class. + * @return the service class. + */ + public Class getServiceClass() { + return serviceClass; + } + + /** + * Get the <code>BeanContextServices</code> through which the new service is available. + * @return the <code>BeanContextServices</code> through which the + * new service is available. + */ + public BeanContextServices getSourceAsBeanContextServices() { + return (BeanContextServices)getSource(); + } } diff --git a/java/beans/beancontext/BeanContextServiceProvider.java b/java/beans/beancontext/BeanContextServiceProvider.java index c09b5815f..7475a61bd 100644 --- a/java/beans/beancontext/BeanContextServiceProvider.java +++ b/java/beans/beancontext/BeanContextServiceProvider.java @@ -7,7 +7,7 @@ GNU Classpath is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2, or (at your option) any later version. - + GNU Classpath is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU @@ -60,79 +60,79 @@ import java.util.Iterator; */ public interface BeanContextServiceProvider { - /** - * Get a service. - * Called from <code>BeanContextServices.getService()</code>. - * - * <p>If the requested service class is not available, or if this - * <code>BeanContextServiceProvider</code> chooses not honor the - * request for some reason, then this method will return - * <code>null</code>.</p> - * - * This method may throw unchecked exceptions, so watch out. - * - * @param services the <code>BeanContextServices</code> that wants - * to get the service. Only weak references to this will - * be retained, and it will never be changed, only queried - * in a read-only manner. - * @param requestor the actual requestor of the service. Only - * weak references to this will be retained, and it will - * never be changed, only queried in a read-only manner. - * @param serviceClass the <code>Class</code> of the service being - * requested. - * @param serviceSelector a parameter to customize the service - * returned with. - * @return an instance of <code>serviceClass</code> (such that - * <code>instanceof</code> serviceClass is true), or - * <code>null</code>. - * @see java.beans.beancontext.BeanContextServices#getService(java.beans.beancontext.BeanContextChild,java.lang.Object,java.lang.Class,java.lang.Object,java.beans.beancontext.BeanContextServiceRevokedListener) - */ - Object getService(BeanContextServices services, Object requestor, Class serviceClass, Object serviceSelector); + /** + * Get a service. + * Called from <code>BeanContextServices.getService()</code>. + * + * <p>If the requested service class is not available, or if this + * <code>BeanContextServiceProvider</code> chooses not honor the + * request for some reason, then this method will return + * <code>null</code>.</p> + * + * This method may throw unchecked exceptions, so watch out. + * + * @param services the <code>BeanContextServices</code> that wants + * to get the service. Only weak references to this will + * be retained, and it will never be changed, only queried + * in a read-only manner. + * @param requestor the actual requestor of the service. Only + * weak references to this will be retained, and it will + * never be changed, only queried in a read-only manner. + * @param serviceClass the <code>Class</code> of the service being + * requested. + * @param serviceSelector a parameter to customize the service + * returned with. + * @return an instance of <code>serviceClass</code> (such that + * <code>instanceof</code> serviceClass is true), or + * <code>null</code>. + * @see java.beans.beancontext.BeanContextServices#getService(java.beans.beancontext.BeanContextChild,java.lang.Object,java.lang.Class,java.lang.Object,java.beans.beancontext.BeanContextServiceRevokedListener) + */ + Object getService(BeanContextServices services, Object requestor, Class serviceClass, Object serviceSelector); - /** - * Release the service. - * <P> - * - * Called by <code>BeanContextServices.releaseService()</code>. - * <P> - * - * Most <code>BeanContextServiceProvider</code>s won't have to do - * anything here. - * - * @param services the <code>BeanContextServices</code> that wants - * to release the service. Only weak references to this will - * be retained, and it will never be changed, only queried - * in a read-only manner. - * @param requestor the original requestor of the service. - * @param service the service to relinquish - * @see java.beans.beancontext.BeanContextServices#releaseService(java.beans.beancontext.BeanContextChild,java.lang.Object,java.lang.Object) - */ - void releaseService(BeanContextServices services, Object requestor, Object service); + /** + * Release the service. + * <P> + * + * Called by <code>BeanContextServices.releaseService()</code>. + * <P> + * + * Most <code>BeanContextServiceProvider</code>s won't have to do + * anything here. + * + * @param services the <code>BeanContextServices</code> that wants + * to release the service. Only weak references to this will + * be retained, and it will never be changed, only queried + * in a read-only manner. + * @param requestor the original requestor of the service. + * @param service the service to relinquish + * @see java.beans.beancontext.BeanContextServices#releaseService(java.beans.beancontext.BeanContextChild,java.lang.Object,java.lang.Object) + */ + void releaseService(BeanContextServices services, Object requestor, Object service); - /** - * Get a list of valid service selectors for the specified service class. - * This method is called from - * <code>BeanContextServices.getCurrentServiceSelectors()</code>. - * <P> - * - * If the specified service class does not have a finite number of - * valid service selectors, it should return <code>null</code>. - * If it takes a general <code>Integer</code> parameter, for - * example, you may as well return <code>null</code> or the poor - * soul who called this method will be iterating all day. - * <P> - * - * If it has no valid service selectors, it should still return an empty - * <code>Iterator</code>. - * - * @param services the <code>BeanContextServices</code> that wants - * to get the service selectors. Only weak references to this will - * be retained, and it will never be changed, only queried - * in a read-only manner. - * @param serviceClass the service class to get selectors for. - * @return a list of valid service selectors for the service - * class, or <code>null</code>. - * @see java.beans.beancontext.BeanContextServices#getCurrentServiceSelectors(java.lang.Class) - */ - Iterator getCurrentServiceSelectors(BeanContextServices services, Class serviceClass); + /** + * Get a list of valid service selectors for the specified service class. + * This method is called from + * <code>BeanContextServices.getCurrentServiceSelectors()</code>. + * <P> + * + * If the specified service class does not have a finite number of + * valid service selectors, it should return <code>null</code>. + * If it takes a general <code>Integer</code> parameter, for + * example, you may as well return <code>null</code> or the poor + * soul who called this method will be iterating all day. + * <P> + * + * If it has no valid service selectors, it should still return an empty + * <code>Iterator</code>. + * + * @param services the <code>BeanContextServices</code> that wants + * to get the service selectors. Only weak references to this will + * be retained, and it will never be changed, only queried + * in a read-only manner. + * @param serviceClass the service class to get selectors for. + * @return a list of valid service selectors for the service + * class, or <code>null</code>. + * @see java.beans.beancontext.BeanContextServices#getCurrentServiceSelectors(java.lang.Class) + */ + Iterator getCurrentServiceSelectors(BeanContextServices services, Class serviceClass); } diff --git a/java/beans/beancontext/BeanContextServiceProviderBeanInfo.java b/java/beans/beancontext/BeanContextServiceProviderBeanInfo.java index 690b94e2c..78bfc200d 100644 --- a/java/beans/beancontext/BeanContextServiceProviderBeanInfo.java +++ b/java/beans/beancontext/BeanContextServiceProviderBeanInfo.java @@ -7,7 +7,7 @@ GNU Classpath is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2, or (at your option) any later version. - + GNU Classpath is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU @@ -52,9 +52,9 @@ import java.beans.BeanInfo; * @since JDK1.2 */ public interface BeanContextServiceProviderBeanInfo extends BeanInfo { - /** - * Get <code>BeanInfo</code>s for all of the service classes of this <code>BeanInfoServiceProvider</code>. - * @return <code>BeanInfo</code>s for all provided service classes. - */ - BeanInfo[] getServicesBeanInfo(); + /** + * Get <code>BeanInfo</code>s for all of the service classes of this <code>BeanInfoServiceProvider</code>. + * @return <code>BeanInfo</code>s for all provided service classes. + */ + BeanInfo[] getServicesBeanInfo(); } diff --git a/java/beans/beancontext/BeanContextServiceRevokedEvent.java b/java/beans/beancontext/BeanContextServiceRevokedEvent.java index 1f5ebd3cd..b4f2fa856 100644 --- a/java/beans/beancontext/BeanContextServiceRevokedEvent.java +++ b/java/beans/beancontext/BeanContextServiceRevokedEvent.java @@ -7,7 +7,7 @@ GNU Classpath is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2, or (at your option) any later version. - + GNU Classpath is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU @@ -50,63 +50,63 @@ public class BeanContextServiceRevokedEvent extends BeanContextEvent { private static final long serialVersionUID = -1295543154724961754L; /** - * The <code>Class</code> representing the service which is now - * available. - */ - protected Class serviceClass; - private boolean invalidateRefs; - - /** - * Create a new service revoked event. - * @param services the <code>BeanContextServices</code> through - * which the service was available. This is also the source - * of the event. - * @param serviceClass the service class that is now revoked. - * @param revokeNow whether the revocation is immediate for all - * classes or just a suggestion. - */ - public BeanContextServiceRevokedEvent(BeanContextServices services, Class serviceClass, boolean revokeNow) { - super(services); - this.serviceClass = serviceClass; - invalidateRefs = revokeNow; - } - - /** - * Get the revoked service class. - * @return the service class. - */ - public Class getServiceClass() { - return serviceClass; - } - - /** - * Tell whether the revoked service class is the same as the specified class. - * Identical to <code>getServiceClass().equals(c)</code>. - * @param c the class to compare. - * @return whether the clases are equal. - */ - public boolean isServiceClass(Class c) { - return serviceClass.equals(c); - } - - /** - * Get the <code>BeanContextServices</code> through which the service was available. - * @return the <code>BeanContextServices</code> through which the - * service was available. - */ - public BeanContextServices getSourceAsBeanContextServices() { - return (BeanContextServices)getSource(); - } - - /** - * Tell whether current instances of the revoked service are usable or not. - * This is determined by whether the service was revoked - * immediately. - * - * @return whether current instances of the revoked service are - * usable. - */ - public boolean isCurrentServiceInvalidNow() { - return invalidateRefs; - } + * The <code>Class</code> representing the service which is now + * available. + */ + protected Class serviceClass; + private boolean invalidateRefs; + + /** + * Create a new service revoked event. + * @param services the <code>BeanContextServices</code> through + * which the service was available. This is also the source + * of the event. + * @param serviceClass the service class that is now revoked. + * @param revokeNow whether the revocation is immediate for all + * classes or just a suggestion. + */ + public BeanContextServiceRevokedEvent(BeanContextServices services, Class serviceClass, boolean revokeNow) { + super(services); + this.serviceClass = serviceClass; + invalidateRefs = revokeNow; + } + + /** + * Get the revoked service class. + * @return the service class. + */ + public Class getServiceClass() { + return serviceClass; + } + + /** + * Tell whether the revoked service class is the same as the specified class. + * Identical to <code>getServiceClass().equals(c)</code>. + * @param c the class to compare. + * @return whether the clases are equal. + */ + public boolean isServiceClass(Class c) { + return serviceClass.equals(c); + } + + /** + * Get the <code>BeanContextServices</code> through which the service was available. + * @return the <code>BeanContextServices</code> through which the + * service was available. + */ + public BeanContextServices getSourceAsBeanContextServices() { + return (BeanContextServices)getSource(); + } + + /** + * Tell whether current instances of the revoked service are usable or not. + * This is determined by whether the service was revoked + * immediately. + * + * @return whether current instances of the revoked service are + * usable. + */ + public boolean isCurrentServiceInvalidNow() { + return invalidateRefs; + } } diff --git a/java/beans/beancontext/BeanContextServiceRevokedListener.java b/java/beans/beancontext/BeanContextServiceRevokedListener.java index 101e6e191..11b83dd65 100644 --- a/java/beans/beancontext/BeanContextServiceRevokedListener.java +++ b/java/beans/beancontext/BeanContextServiceRevokedListener.java @@ -7,7 +7,7 @@ GNU Classpath is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2, or (at your option) any later version. - + GNU Classpath is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU @@ -48,15 +48,15 @@ import java.util.EventListener; */ public interface BeanContextServiceRevokedListener extends EventListener { - /** - * Called by <code>BeanContextServices.revokeService()</code> to indicate that a service has been revoked. - * If you have a reference to such a service, it should be - * discarded and may no longer function properly. - * <code>getService()</code> will no longer work on the specified - * service class after this event has been fired. - * - * @param event the service revoked event. - * @see java.beans.beancontext.BeanContextServices#revokeService(java.lang.Class,java.beans.beancontext.BeanContextServiceProvider,boolean) - */ - void serviceRevoked(BeanContextServiceRevokedEvent event); + /** + * Called by <code>BeanContextServices.revokeService()</code> to indicate that a service has been revoked. + * If you have a reference to such a service, it should be + * discarded and may no longer function properly. + * <code>getService()</code> will no longer work on the specified + * service class after this event has been fired. + * + * @param event the service revoked event. + * @see java.beans.beancontext.BeanContextServices#revokeService(java.lang.Class,java.beans.beancontext.BeanContextServiceProvider,boolean) + */ + void serviceRevoked(BeanContextServiceRevokedEvent event); } diff --git a/java/beans/beancontext/BeanContextServices.java b/java/beans/beancontext/BeanContextServices.java index cb1950360..787618ad5 100644 --- a/java/beans/beancontext/BeanContextServices.java +++ b/java/beans/beancontext/BeanContextServices.java @@ -7,7 +7,7 @@ GNU Classpath is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2, or (at your option) any later version. - + GNU Classpath is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU diff --git a/java/beans/beancontext/BeanContextServicesListener.java b/java/beans/beancontext/BeanContextServicesListener.java index becc7cdb6..2081080dd 100644 --- a/java/beans/beancontext/BeanContextServicesListener.java +++ b/java/beans/beancontext/BeanContextServicesListener.java @@ -7,7 +7,7 @@ GNU Classpath is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2, or (at your option) any later version. - + GNU Classpath is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU @@ -46,11 +46,11 @@ package java.beans.beancontext; */ public interface BeanContextServicesListener extends BeanContextServiceRevokedListener { - /** - * Called by <code>BeanContextServices</code> whenever a service is made available. - * - * @param event the service revoked event, with useful information - * about the new service. - */ - void serviceAvailable(BeanContextServiceAvailableEvent event); + /** + * Called by <code>BeanContextServices</code> whenever a service is made available. + * + * @param event the service revoked event, with useful information + * about the new service. + */ + void serviceAvailable(BeanContextServiceAvailableEvent event); } diff --git a/java/beans/beancontext/BeanContextServicesSupport.java b/java/beans/beancontext/BeanContextServicesSupport.java index 725c2d468..30b4a6fbd 100644 --- a/java/beans/beancontext/BeanContextServicesSupport.java +++ b/java/beans/beancontext/BeanContextServicesSupport.java @@ -66,7 +66,7 @@ public class BeanContextServicesSupport implements BeanContextServices { private static final long serialVersionUID = -8494482757288719206L; - + protected class BCSSChild extends BeanContextSupport.BCSChild { @@ -103,7 +103,7 @@ public class BeanContextServicesSupport Object serviceSelector) { return provider.getService(bcs, requestor, serviceClass, - serviceSelector); + serviceSelector); } public void releaseService (BeanContextServices bcs, @@ -116,7 +116,7 @@ public class BeanContextServicesSupport public void serviceRevoked (BeanContextServiceRevokedEvent bcsre) { if (provider instanceof BeanContextServiceRevokedListener) - ((BeanContextServiceRevokedListener) provider).serviceRevoked(bcsre); + ((BeanContextServiceRevokedListener) provider).serviceRevoked(bcsre); } } @@ -130,7 +130,7 @@ public class BeanContextServicesSupport private Class serviceClass; private BCSSServiceProvider(Class serviceClass, - BeanContextServiceProvider provider) + BeanContextServiceProvider provider) { this.serviceClass = serviceClass; serviceProvider = provider; @@ -167,10 +167,10 @@ public class BeanContextServicesSupport public boolean equals(Object obj) { if (obj instanceof Request) - { - Request req = (Request) obj; - return req.getRequestor().equals(requestor); - } + { + Request req = (Request) obj; + return req.getRequestor().equals(requestor); + } return false; } @@ -194,7 +194,7 @@ public class BeanContextServicesSupport private BeanContextServiceRevokedListener listener; public ServiceRequest(Object requestor, - BeanContextServiceRevokedListener listener) + BeanContextServiceRevokedListener listener) { super(requestor); this.listener = listener; @@ -203,11 +203,11 @@ public class BeanContextServicesSupport public boolean equals(Object obj) { if (obj instanceof ServiceRequest) - { - ServiceRequest sr = (ServiceRequest) obj; - return (super.equals(obj) && - sr.getListener().equals(listener)); - } + { + ServiceRequest sr = (ServiceRequest) obj; + return (super.equals(obj) && + sr.getListener().equals(listener)); + } return false; } @@ -238,11 +238,11 @@ public class BeanContextServicesSupport public boolean equals(Object obj) { if (obj instanceof ServiceLease) - { - ServiceLease sl = (ServiceLease) obj; - return (super.equals(obj) && - sl.getService().equals(service)); - } + { + ServiceLease sl = (ServiceLease) obj; + return (super.equals(obj) && + sl.getService().equals(service)); + } return false; } @@ -257,7 +257,7 @@ public class BeanContextServicesSupport * and revocation notifications. */ protected transient ArrayList bcsListeners; - + protected transient BCSSProxyServiceProvider proxy; /** @@ -297,7 +297,7 @@ public class BeanContextServicesSupport /** * Construct a {@link BeanContextServicesSupport} instance. - * + * * @param peer the bean context services peer (<code>null</code> permitted). */ public BeanContextServicesSupport (BeanContextServices peer) @@ -307,9 +307,9 @@ public class BeanContextServicesSupport /** * Construct a {@link BeanContextServicesSupport} instance. - * + * * @param peer the bean context peer (<code>null</code> permitted). - * @param locale the locale (<code>null</code> permitted, equivalent to + * @param locale the locale (<code>null</code> permitted, equivalent to * the default locale). */ public BeanContextServicesSupport(BeanContextServices peer, Locale locale) @@ -319,9 +319,9 @@ public class BeanContextServicesSupport /** * Construct a {@link BeanContextServicesSupport} instance. - * + * * @param peer the bean context peer (<code>null</code> permitted). - * @param locale the locale (<code>null</code> permitted, equivalent to + * @param locale the locale (<code>null</code> permitted, equivalent to * the default locale). * @param dtime a flag indicating whether or not the bean context is in * design time mode. @@ -334,9 +334,9 @@ public class BeanContextServicesSupport /** * Construct a {@link BeanContextServicesSupport} instance. - * + * * @param peer the bean context peer (<code>null</code> permitted). - * @param locale the locale (<code>null</code> permitted, equivalent to + * @param locale the locale (<code>null</code> permitted, equivalent to * the default locale). * @param dtime a flag indicating whether or not the bean context is in * design time mode. @@ -347,7 +347,7 @@ public class BeanContextServicesSupport { super(peer, locale, dtime, visible); } - + /** * Adds a new listener for service availability and * revocation events. @@ -403,21 +403,21 @@ public class BeanContextServicesSupport { synchronized (globalHierarchyLock) { - synchronized (services) - { - if (services.containsKey(serviceClass)) - return false; - services.put(serviceClass, - createBCSSServiceProvider(serviceClass, bcsp)); - if (bcsp instanceof Serializable) - ++serializable; - if (fireEvent) - fireServiceAdded(serviceClass); - return true; - } + synchronized (services) + { + if (services.containsKey(serviceClass)) + return false; + services.put(serviceClass, + createBCSSServiceProvider(serviceClass, bcsp)); + if (bcsp instanceof Serializable) + ++serializable; + if (fireEvent) + fireServiceAdded(serviceClass); + return true; + } } } - + /** * Deserializes any service providers which are serializable. This * method is called by the <code>readObject</code> method of @@ -436,8 +436,8 @@ public class BeanContextServicesSupport serializable = ois.readInt(); for (int a = 0; a < serializable; ++a) { - BCSSServiceProvider bcsssp = (BCSSServiceProvider) ois.readObject(); - addService(bcsssp.getServiceClass(), bcsssp.getServiceProvider()); + BCSSServiceProvider bcsssp = (BCSSServiceProvider) ois.readObject(); + addService(bcsssp.getServiceClass(), bcsssp.getServiceProvider()); } } @@ -451,19 +451,19 @@ public class BeanContextServicesSupport * @param oos the stream to which data is being serialized. * @throws IOException if an I/O error occurs. */ - protected void bcsPreSerializationHook (ObjectOutputStream oos) + protected void bcsPreSerializationHook (ObjectOutputStream oos) throws IOException { oos.writeInt(serializable); synchronized (services) { - Iterator i = services.values().iterator(); - while (i.hasNext()) - { - BCSSServiceProvider bcsssp = (BCSSServiceProvider) i.next(); - if (bcsssp.getServiceProvider() instanceof Serializable) - oos.writeObject(bcsssp); - } + Iterator i = services.values().iterator(); + while (i.hasNext()) + { + BCSSServiceProvider bcsssp = (BCSSServiceProvider) i.next(); + if (bcsssp.getServiceProvider() instanceof Serializable) + oos.writeObject(bcsssp); + } } } @@ -476,17 +476,17 @@ public class BeanContextServicesSupport * * @param child the child being removed. * @param bcsc the support object for the child. - */ + */ protected void childJustRemovedHook (Object child, BeanContextSupport.BCSChild bcsc) { if (child instanceof BeanContextChild) { - BeanContextChild bcchild = (BeanContextChild) child; - Iterator childServices = ((List) serviceUsers.get(bcchild)).iterator(); - while (childServices.hasNext()) - releaseService(bcchild, this, childServices.next()); - serviceUsers.remove(bcchild); + BeanContextChild bcchild = (BeanContextChild) child; + Iterator childServices = ((List) serviceUsers.get(bcchild)).iterator(); + while (childServices.hasNext()) + releaseService(bcchild, this, childServices.next()); + serviceUsers.remove(bcchild); } } @@ -570,16 +570,16 @@ public class BeanContextServicesSupport = (BeanContextServicesListener) bcsListeners.get(i); bcsl.serviceRevoked(event); } - List requests = (List) serviceRequests.get(event.getServiceClass()); - if (requests != null) - { - Iterator i = requests.iterator(); - while (i.hasNext()) - { - ServiceRequest r = (ServiceRequest) i.next(); - r.getListener().serviceRevoked(event); - } - } + List requests = (List) serviceRequests.get(event.getServiceClass()); + if (requests != null) + { + Iterator i = requests.iterator(); + while (i.hasNext()) + { + ServiceRequest r = (ServiceRequest) i.next(); + r.getListener().serviceRevoked(event); + } + } } } @@ -609,20 +609,20 @@ public class BeanContextServicesSupport } /** - * Returns <code>child</code> as an instance of - * {@link BeanContextServicesListener}, or <code>null</code> if + * Returns <code>child</code> as an instance of + * {@link BeanContextServicesListener}, or <code>null</code> if * <code>child</code> does not implement that interface. - * + * * @param child the child (<code>null</code> permitted). - * + * * @return The child cast to {@link BeanContextServicesListener}. */ protected static final BeanContextServicesListener getChildBeanContextServicesListener(Object child) { - if (child instanceof BeanContextServicesListener) + if (child instanceof BeanContextServicesListener) return (BeanContextServicesListener) child; - else + else return null; } @@ -636,10 +636,10 @@ public class BeanContextServicesSupport { synchronized (globalHierarchyLock) { - synchronized (services) - { - return services.keySet().iterator(); - } + synchronized (services) + { + return services.keySet().iterator(); + } } } @@ -660,16 +660,16 @@ public class BeanContextServicesSupport { synchronized (globalHierarchyLock) { - synchronized (services) - { - BeanContextServiceProvider bcsp - = ((BCSSServiceProvider) - services.get(serviceClass)).getServiceProvider(); - if (bcsp == null) - return null; - else - return bcsp.getCurrentServiceSelectors(this, serviceClass); - } + synchronized (services) + { + BeanContextServiceProvider bcsp + = ((BCSSServiceProvider) + services.get(serviceClass)).getServiceProvider(); + if (bcsp == null) + return null; + else + return bcsp.getCurrentServiceSelectors(this, serviceClass); + } } } @@ -699,47 +699,47 @@ public class BeanContextServicesSupport { synchronized (globalHierarchyLock) { - synchronized (services) - { - Object service; - BeanContextServiceProvider provider = ((BCSSServiceProvider) - services.get(serviceClass)).getServiceProvider(); - if (provider != null) - { - service = provider.getService(this, requestor, serviceClass, - serviceSelector); - List childServices = (List) serviceUsers.get(child); - if (childServices == null) - { - childServices = new ArrayList(); - serviceUsers.put(child, childServices); - } - childServices.add(serviceClass); - } - else - { - BeanContextServices peer = getBeanContextServicesPeer(); - if (peer != null) - service = peer.getService(child, requestor, serviceClass, - serviceSelector, bcsrl); - else - service = null; - } - if (service != null) - { - ServiceRequest request = new ServiceRequest(requestor, bcsrl); - Set requests = (Set) serviceRequests.get(serviceClass); - if (requests == null) - { - requests = new HashSet(); - serviceRequests.put(serviceClass, requests); - } - requests.add(request); - ServiceLease lease = new ServiceLease(requestor, service); - serviceLeases.put(lease, provider); - } - return service; - } + synchronized (services) + { + Object service; + BeanContextServiceProvider provider = ((BCSSServiceProvider) + services.get(serviceClass)).getServiceProvider(); + if (provider != null) + { + service = provider.getService(this, requestor, serviceClass, + serviceSelector); + List childServices = (List) serviceUsers.get(child); + if (childServices == null) + { + childServices = new ArrayList(); + serviceUsers.put(child, childServices); + } + childServices.add(serviceClass); + } + else + { + BeanContextServices peer = getBeanContextServicesPeer(); + if (peer != null) + service = peer.getService(child, requestor, serviceClass, + serviceSelector, bcsrl); + else + service = null; + } + if (service != null) + { + ServiceRequest request = new ServiceRequest(requestor, bcsrl); + Set requests = (Set) serviceRequests.get(serviceClass); + if (requests == null) + { + requests = new HashSet(); + serviceRequests.put(serviceClass, requests); + } + requests.add(request); + ServiceLease lease = new ServiceLease(requestor, service); + serviceLeases.put(lease, provider); + } + return service; + } } } @@ -753,10 +753,10 @@ public class BeanContextServicesSupport { synchronized (globalHierarchyLock) { - synchronized (services) - { - return services.containsKey(serviceClass); - } + synchronized (services) + { + return services.containsKey(serviceClass); + } } } @@ -784,7 +784,7 @@ public class BeanContextServicesSupport * Relinquishes any resources obtained from the parent context. * Specifically, those services obtained from the parent are revoked. * Subclasses may override this method to deallocate resources - * from the nesting bean context. + * from the nesting bean context. */ protected void releaseBeanContextResources() { @@ -806,21 +806,21 @@ public class BeanContextServicesSupport { synchronized (globalHierarchyLock) { - synchronized (services) - { - ServiceLease lease = new ServiceLease(requestor, service); - BeanContextServiceProvider provider = (BeanContextServiceProvider) - serviceLeases.get(lease); - if (provider != null) - provider.releaseService(this, requestor, service); - else - { - BeanContextServices peer = getBeanContextServicesPeer(); - if (peer != null) - peer.releaseService(child, requestor, service); - } - serviceLeases.remove(lease); - } + synchronized (services) + { + ServiceLease lease = new ServiceLease(requestor, service); + BeanContextServiceProvider provider = (BeanContextServiceProvider) + serviceLeases.get(lease); + if (provider != null) + provider.releaseService(this, requestor, service); + else + { + BeanContextServices peer = getBeanContextServicesPeer(); + if (peer != null) + peer.releaseService(child, requestor, service); + } + serviceLeases.remove(lease); + } } } @@ -829,7 +829,7 @@ public class BeanContextServicesSupport { synchronized (bcsListeners) { - bcsListeners.remove(listener); + bcsListeners.remove(listener); } } @@ -850,13 +850,13 @@ public class BeanContextServicesSupport { synchronized (globalHierarchyLock) { - synchronized (services) - { - fireServiceRevoked(serviceClass, revokeCurrentServicesNow); - services.remove(serviceClass); - if (bcsp instanceof Serializable) - --serializable; - } + synchronized (services) + { + fireServiceRevoked(serviceClass, revokeCurrentServicesNow); + services.remove(serviceClass); + if (bcsp instanceof Serializable) + --serializable; + } } } diff --git a/java/beans/beancontext/BeanContextSupport.java b/java/beans/beancontext/BeanContextSupport.java index 7572af3f0..fdae387d4 100644 --- a/java/beans/beancontext/BeanContextSupport.java +++ b/java/beans/beancontext/BeanContextSupport.java @@ -188,7 +188,7 @@ public class BeanContextSupport extends BeanContextChildSupport /** * Construct a BeanContextSupport instance. - * + * * @param peer the bean context peer (<code>null</code> permitted). */ public BeanContextSupport(BeanContext peer) @@ -198,9 +198,9 @@ public class BeanContextSupport extends BeanContextChildSupport /** * Construct a BeanContextSupport instance. - * + * * @param peer the bean context peer (<code>null</code> permitted). - * @param locale the locale (<code>null</code> permitted, equivalent to + * @param locale the locale (<code>null</code> permitted, equivalent to * the default locale). */ public BeanContextSupport (BeanContext peer, Locale locale) @@ -210,9 +210,9 @@ public class BeanContextSupport extends BeanContextChildSupport /** * Construct a BeanContextSupport instance. - * + * * @param peer the bean context peer (<code>null</code> permitted). - * @param locale the locale (<code>null</code> permitted, equivalent to + * @param locale the locale (<code>null</code> permitted, equivalent to * the default locale). * @param dtime a flag indicating whether or not the bean context is in * design time mode. @@ -224,9 +224,9 @@ public class BeanContextSupport extends BeanContextChildSupport /** * Construct a BeanContextSupport instance. - * + * * @param peer the bean context peer (<code>null</code> permitted). - * @param locale the locale (<code>null</code> permitted, equivalent to + * @param locale the locale (<code>null</code> permitted, equivalent to * the default locale). * @param dtime a flag indicating whether or not the bean context is in * design time mode. @@ -248,7 +248,7 @@ public class BeanContextSupport extends BeanContextChildSupport * <p> * Add a child to the bean context. A child can be a simple * <code>Object</code>, a <code>BeanContextChild</code> - * or another <code>BeanContext</code>. + * or another <code>BeanContext</code>. * </p> * <p> * The children of a <code>BeanContext</code> form a set. As @@ -272,7 +272,7 @@ public class BeanContextSupport extends BeanContextChildSupport * then its ability to use a GUI is set based on that of * this context. * </p> - * <p> + * <p> * A <code>BeanContextMembershipEvent</code> is fired when the * child is successfully added to the bean context. * </p> @@ -290,55 +290,55 @@ public class BeanContextSupport extends BeanContextChildSupport { synchronized (globalHierarchyLock) { - if (targetChild == null) - throw new IllegalArgumentException(); - - BCSChild child; - synchronized (children) - { - if (children.containsKey(targetChild) - || ! validatePendingAdd(targetChild)) - return false; - child = createBCSChild(targetChild, beanContextChildPeer); - children.put(targetChild, child); - } - synchronized (targetChild) - { - BeanContextChild bcChild = null; - if (targetChild instanceof BeanContextChild) - bcChild = (BeanContextChild) targetChild; - if (targetChild instanceof BeanContextProxy) - bcChild = ((BeanContextProxy) targetChild).getBeanContextProxy(); - if (bcChild != null) - try - { - bcChild.setBeanContext(this); - bcChild.addVetoableChangeListener("beanContext", this); - bcChild.addPropertyChangeListener("beanContext", this); - } - catch (PropertyVetoException e) - { - synchronized (children) - { - children.remove(targetChild); - } - throw new IllegalStateException("The child refused to " + - "associate itself with " + - "this context.", e); - } - if (targetChild instanceof Visibility) - { - Visibility visibleChild = (Visibility) targetChild; - if (okToUseGui) - visibleChild.okToUseGui(); - else - visibleChild.dontUseGui(); - } - childJustAddedHook(targetChild, child); - } - fireChildrenAdded(new BeanContextMembershipEvent(this, - new Object[]{ targetChild })); - return true; + if (targetChild == null) + throw new IllegalArgumentException(); + + BCSChild child; + synchronized (children) + { + if (children.containsKey(targetChild) + || ! validatePendingAdd(targetChild)) + return false; + child = createBCSChild(targetChild, beanContextChildPeer); + children.put(targetChild, child); + } + synchronized (targetChild) + { + BeanContextChild bcChild = null; + if (targetChild instanceof BeanContextChild) + bcChild = (BeanContextChild) targetChild; + if (targetChild instanceof BeanContextProxy) + bcChild = ((BeanContextProxy) targetChild).getBeanContextProxy(); + if (bcChild != null) + try + { + bcChild.setBeanContext(this); + bcChild.addVetoableChangeListener("beanContext", this); + bcChild.addPropertyChangeListener("beanContext", this); + } + catch (PropertyVetoException e) + { + synchronized (children) + { + children.remove(targetChild); + } + throw new IllegalStateException("The child refused to " + + "associate itself with " + + "this context.", e); + } + if (targetChild instanceof Visibility) + { + Visibility visibleChild = (Visibility) targetChild; + if (okToUseGui) + visibleChild.okToUseGui(); + else + visibleChild.dontUseGui(); + } + childJustAddedHook(targetChild, child); + } + fireChildrenAdded(new BeanContextMembershipEvent(this, + new Object[]{ targetChild })); + return true; } } @@ -415,7 +415,7 @@ public class BeanContextSupport extends BeanContextChildSupport /** * Called when a child is deserialized. - * + * * @param child the deserialized child. * @param bcsc the deserialized context wrapper for the child. */ @@ -489,16 +489,16 @@ public class BeanContextSupport extends BeanContextChildSupport } /** - * Deserializes objects (written by {@link #serialize(ObjectOutputStream, + * Deserializes objects (written by {@link #serialize(ObjectOutputStream, * Collection)}) and adds them to the specified collection. - * + * * @param ois the input stream (<code>null</code> not permitted). * @param coll the collection to add the objects to (<code>null</code> not * permitted). - * + * * @throws ClassNotFoundException * @throws IOException - * + * * @see #serialize(ObjectOutputStream, Collection) */ protected final void deserialize (ObjectInputStream ois, Collection coll) @@ -548,9 +548,9 @@ public class BeanContextSupport extends BeanContextChildSupport /** * Returns the bean context peer. - * + * * @return The bean context peer. - * + * * @see BeanContextChildSupport#beanContextChildPeer */ public BeanContext getBeanContextPeer() @@ -560,11 +560,11 @@ public class BeanContextSupport extends BeanContextChildSupport /** * Returns the {@link BeanContextChild} implementation for the given child. - * + * * @param child the child (<code>null</code> permitted). - * + * * @return The bean context child. - * + * * @throws IllegalArgumentException if <code>child</code> implements both * the {@link BeanContextChild} and {@link BeanContextProxy} interfaces. */ @@ -573,7 +573,7 @@ public class BeanContextSupport extends BeanContextChildSupport if (child == null) return null; if (child instanceof BeanContextChild && child instanceof BeanContextProxy) - throw new IllegalArgumentException("Child cannot implement " + throw new IllegalArgumentException("Child cannot implement " + "BeanContextChild and BeanContextProxy simultaneously."); if (child instanceof BeanContextChild) return (BeanContextChild) child; @@ -583,89 +583,89 @@ public class BeanContextSupport extends BeanContextChildSupport } /** - * Returns <code>child</code> as an instance of - * {@link BeanContextMembershipListener}, or <code>null</code> if + * Returns <code>child</code> as an instance of + * {@link BeanContextMembershipListener}, or <code>null</code> if * <code>child</code> does not implement that interface. - * + * * @param child the child (<code>null</code> permitted). - * + * * @return The child cast to {@link BeanContextMembershipListener}. */ - protected static final BeanContextMembershipListener + protected static final BeanContextMembershipListener getChildBeanContextMembershipListener(Object child) { - if (child instanceof BeanContextMembershipListener) + if (child instanceof BeanContextMembershipListener) return (BeanContextMembershipListener) child; - else + else return null; } /** - * Returns <code>child</code> as an instance of + * Returns <code>child</code> as an instance of * {@link PropertyChangeListener}, or <code>null</code> if <code>child</code> * does not implement that interface. - * + * * @param child the child (<code>null</code> permitted). - * + * * @return The child cast to {@link PropertyChangeListener}. */ protected static final PropertyChangeListener getChildPropertyChangeListener( Object child) { - if (child instanceof PropertyChangeListener) + if (child instanceof PropertyChangeListener) return (PropertyChangeListener) child; - else + else return null; } /** - * Returns <code>child</code> as an instance of {@link Serializable}, or - * <code>null</code> if <code>child</code> does not implement that + * Returns <code>child</code> as an instance of {@link Serializable}, or + * <code>null</code> if <code>child</code> does not implement that * interface. - * + * * @param child the child (<code>null</code> permitted). - * + * * @return The child cast to {@link Serializable}. */ protected static final Serializable getChildSerializable(Object child) { - if (child instanceof Serializable) + if (child instanceof Serializable) return (Serializable) child; - else + else return null; } /** - * Returns <code>child</code> as an instance of + * Returns <code>child</code> as an instance of * {@link VetoableChangeListener}, or <code>null</code> if <code>child</code> * does not implement that interface. - * + * * @param child the child (<code>null</code> permitted). - * + * * @return The child cast to {@link VetoableChangeListener}. */ protected static final VetoableChangeListener getChildVetoableChangeListener( Object child) { - if (child instanceof VetoableChangeListener) + if (child instanceof VetoableChangeListener) return (VetoableChangeListener) child; - else + else return null; } /** * Returns <code>child</code> as an instance of {@link Visibility}, or * <code>null</code> if <code>child</code> does not implement that interface. - * + * * @param child the child (<code>null</code> permitted). - * + * * @return The child cast to {@link Visibility}. */ protected static final Visibility getChildVisibility(Object child) { - if (child instanceof Visibility) + if (child instanceof Visibility) return (Visibility) child; - else + else return null; } @@ -715,11 +715,11 @@ public class BeanContextSupport extends BeanContextChildSupport } /** - * Returns <code>true</code> if the <code>BeanContext</code> is in + * Returns <code>true</code> if the <code>BeanContext</code> is in * design time mode, and <code>false</code> if it is in runtime mode. - * + * * @return A boolean. - * + * * @see #setDesignTime(boolean) */ public boolean isDesignTime() @@ -810,15 +810,15 @@ public class BeanContextSupport extends BeanContextChildSupport Iterator i = temp.iterator(); synchronized (globalHierarchyLock) { - synchronized (children) - { - while (i.hasNext()) - { - BCSChild bcs = (BCSChild) i.next(); - childDeserializedHook(bcs.getTargetChild(), bcs); - children.put(bcs.getTargetChild(), bcs); - } - } + synchronized (children) + { + while (i.hasNext()) + { + BCSChild bcs = (BCSChild) i.next(); + childDeserializedHook(bcs.getTargetChild(), bcs); + children.put(bcs.getTargetChild(), bcs); + } + } } } @@ -854,7 +854,7 @@ public class BeanContextSupport extends BeanContextChildSupport * <code>PropertyChangeListener</code> and * <code>VetoableChangeListener</code> for "beanContext" events. * </p> - * <p> + * <p> * A <code>BeanContextMembershipEvent</code> is fired when the * child is successfully removed from the bean context. * </p> @@ -874,47 +874,47 @@ public class BeanContextSupport extends BeanContextChildSupport { synchronized (globalHierarchyLock) { - if (targetChild == null) - throw new IllegalArgumentException(); - - BCSChild child; - synchronized (children) - { - if (!children.containsKey(targetChild) - || !validatePendingRemove(targetChild)) - return false; - child = (BCSChild) children.remove(targetChild); - } - synchronized (targetChild) - { - BeanContextChild bcChild = null; - if (targetChild instanceof BeanContextChild) - bcChild = (BeanContextChild) targetChild; - if (targetChild instanceof BeanContextProxy) - bcChild = ((BeanContextProxy) targetChild).getBeanContextProxy(); - if (bcChild != null) - try - { - if (callChildSetBC) - bcChild.setBeanContext(null); - bcChild.removeVetoableChangeListener("beanContext", this); - bcChild.removePropertyChangeListener("beanContext", this); - } - catch (PropertyVetoException e) - { - synchronized (children) - { - children.put(targetChild, child); - } - throw new IllegalStateException("The child refused to " + - "disassociate itself with " + - "this context.", e); - } - childJustRemovedHook(targetChild, child); - } - fireChildrenRemoved(new BeanContextMembershipEvent(this, - new Object[]{ targetChild })); - return true; + if (targetChild == null) + throw new IllegalArgumentException(); + + BCSChild child; + synchronized (children) + { + if (!children.containsKey(targetChild) + || !validatePendingRemove(targetChild)) + return false; + child = (BCSChild) children.remove(targetChild); + } + synchronized (targetChild) + { + BeanContextChild bcChild = null; + if (targetChild instanceof BeanContextChild) + bcChild = (BeanContextChild) targetChild; + if (targetChild instanceof BeanContextProxy) + bcChild = ((BeanContextProxy) targetChild).getBeanContextProxy(); + if (bcChild != null) + try + { + if (callChildSetBC) + bcChild.setBeanContext(null); + bcChild.removeVetoableChangeListener("beanContext", this); + bcChild.removePropertyChangeListener("beanContext", this); + } + catch (PropertyVetoException e) + { + synchronized (children) + { + children.put(targetChild, child); + } + throw new IllegalStateException("The child refused to " + + "disassociate itself with " + + "this context.", e); + } + childJustRemovedHook(targetChild, child); + } + fireChildrenRemoved(new BeanContextMembershipEvent(this, + new Object[]{ targetChild })); + return true; } } @@ -940,14 +940,14 @@ public class BeanContextSupport extends BeanContextChildSupport /** * Writes the items in the collection to the specified output stream. Items - * in the collection that are not instances of {@link Serializable} + * in the collection that are not instances of {@link Serializable} * (this includes <code>null</code>) are simply ignored. - * + * * @param oos the output stream (<code>null</code> not permitted). * @param coll the collection (<code>null</code> not permitted). - * + * * @throws IOException - * + * * @see #deserialize(ObjectInputStream, Collection) */ protected final void serialize(ObjectOutputStream oos, Collection coll) @@ -969,15 +969,15 @@ public class BeanContextSupport extends BeanContextChildSupport } /** - * Sets the flag that indicates whether or not the + * Sets the flag that indicates whether or not the * <code>BeanContext</code> is in design mode. If the flag changes * value, a {@link PropertyChangeEvent} (with the property name 'designMode') * is sent to registered listeners. Note that the property name used here * does NOT match the specification in the {@link DesignMode} interface, we * match the reference implementation instead - see bug parade entry 4295174. - * + * * @param dtime the new value for the flag. - * + * * @see #isDesignTime() */ public void setDesignTime(boolean dtime) @@ -1011,7 +1011,7 @@ public class BeanContextSupport extends BeanContextChildSupport /** * Returns an array containing the children of this <code>BeanContext</code>. - * + * * @return An array containing the children. */ public Object[] toArray() @@ -1023,11 +1023,11 @@ public class BeanContextSupport extends BeanContextChildSupport } /** - * Populates, then returns, the supplied array with the children of this - * <code>BeanContext</code>. If the array is too short to hold the - * children, a new array is allocated and returned. If the array is too + * Populates, then returns, the supplied array with the children of this + * <code>BeanContext</code>. If the array is too short to hold the + * children, a new array is allocated and returned. If the array is too * long, it is padded with <code>null</code> items at the end. - * + * * @param array an array to populate (<code>null</code> not permitted). */ public Object[] toArray(Object[] array) @@ -1072,7 +1072,7 @@ public class BeanContextSupport extends BeanContextChildSupport { synchronized (children) { - serialize(oos, children.values()); + serialize(oos, children.values()); } } |