diff options
author | mark <mark@138bc75d-0d04-0410-961f-82ee72b054a4> | 2006-05-18 17:29:21 +0000 |
---|---|---|
committer | mark <mark@138bc75d-0d04-0410-961f-82ee72b054a4> | 2006-05-18 17:29:21 +0000 |
commit | 64089cc9f030d8ef7972adb5d117e0b23f47d62b (patch) | |
tree | 9f9c470de62ee62fba1331a396450d728d2b1fad /libjava/classpath/java/beans/beancontext/BeanContextSupport.java | |
parent | 96034e28360d660d7a7708807fcbc4b519574d8e (diff) | |
download | ppe42-gcc-64089cc9f030d8ef7972adb5d117e0b23f47d62b.tar.gz ppe42-gcc-64089cc9f030d8ef7972adb5d117e0b23f47d62b.zip |
Imported GNU Classpath 0.90
* scripts/makemake.tcl: LocaleData.java moved to gnu/java/locale.
* sources.am: Regenerated.
* gcj/javaprims.h: Regenerated.
* Makefile.in: Regenerated.
* gcj/Makefile.in: Regenerated.
* include/Makefile.in: Regenerated.
* testsuite/Makefile.in: Regenerated.
* gnu/java/lang/VMInstrumentationImpl.java: New override.
* gnu/java/net/local/LocalSocketImpl.java: Likewise.
* gnu/classpath/jdwp/VMMethod.java: Likewise.
* gnu/classpath/jdwp/VMVirtualMachine.java: Update to latest
interface.
* java/lang/Thread.java: Add UncaughtExceptionHandler.
* java/lang/reflect/Method.java: Implements GenericDeclaration and
isSynthetic(),
* java/lang/reflect/Field.java: Likewise.
* java/lang/reflect/Constructor.java
* java/lang/Class.java: Implements Type, GenericDeclaration,
getSimpleName() and getEnclosing*() methods.
* java/lang/Class.h: Add new public methods.
* java/lang/Math.java: Add signum(), ulp() and log10().
* java/lang/natMath.cc (log10): New function.
* java/security/VMSecureRandom.java: New override.
* java/util/logging/Logger.java: Updated to latest classpath
version.
* java/util/logging/LogManager.java: New override.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@113887 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'libjava/classpath/java/beans/beancontext/BeanContextSupport.java')
-rw-r--r-- | libjava/classpath/java/beans/beancontext/BeanContextSupport.java | 222 |
1 files changed, 177 insertions, 45 deletions
diff --git a/libjava/classpath/java/beans/beancontext/BeanContextSupport.java b/libjava/classpath/java/beans/beancontext/BeanContextSupport.java index 60ccc3af3e4..f3d5ff6098d 100644 --- a/libjava/classpath/java/beans/beancontext/BeanContextSupport.java +++ b/libjava/classpath/java/beans/beancontext/BeanContextSupport.java @@ -38,6 +38,9 @@ exception statement from your version. */ package java.beans.beancontext; +import gnu.classpath.NotImplementedException; + +import java.beans.DesignMode; import java.beans.PropertyChangeEvent; import java.beans.PropertyChangeListener; import java.beans.PropertyVetoException; @@ -64,15 +67,19 @@ public class BeanContextSupport extends BeanContextChildSupport VetoableChangeListener { private static final long serialVersionUID = -4879613978649577204L; - + + // This won't show up in japi, but we mark it as a stub anyway, + // so that searches for NotImplementedException will find it. private void readObject (ObjectInputStream s) - throws ClassNotFoundException, IOException + throws ClassNotFoundException, IOException, NotImplementedException { throw new Error ("Not implemented"); } + // This won't show up in japi, but we mark it as a stub anyway, + // so that searches for NotImplementedException will find it. private void writeObject (ObjectOutputStream s) - throws ClassNotFoundException, IOException + throws ClassNotFoundException, IOException, NotImplementedException { throw new Error ("Not implemented"); } @@ -80,18 +87,34 @@ public class BeanContextSupport extends BeanContextChildSupport protected class BCSChild implements Serializable { private static final long serialVersionUID = -5815286101609939109L; + + private Object targetChild; + private Object peer; + + BCSChild(Object targetChild, Object peer) + { + this.targetChild = targetChild; + this.peer = peer; + } } protected static final class BCSIterator implements Iterator { + private Iterator child; + + BCSIterator(Iterator child) + { + this.child = child; + } + public boolean hasNext () { - throw new Error ("Not implemented"); + return child.hasNext(); } public Object next () { - throw new Error ("Not implemented"); + return child.next(); } public void remove () @@ -148,7 +171,9 @@ public class BeanContextSupport extends BeanContextChildSupport public BeanContextSupport (BeanContext peer, Locale lcle, boolean dtime, boolean visible) { - locale = lcle; + super(peer); + + locale = lcle == null ? Locale.getDefault() : lcle; designTime = dtime; okToUseGui = visible; @@ -160,150 +185,214 @@ public class BeanContextSupport extends BeanContextChildSupport if (targetChild == null) throw new IllegalArgumentException(); - if (children.containsKey(targetChild)) - return false; - - // FIXME: The second argument is surely wrong. - children.put(targetChild, targetChild); + BCSChild child; + synchronized (children) + { + if (children.containsKey(targetChild) + || ! validatePendingAdd(targetChild)) + return false; + child = createBCSChild(targetChild, beanContextChildPeer); + children.put(targetChild, child); + } + synchronized (targetChild) + { + childJustAddedHook(targetChild, child); + } + fireChildrenAdded(new BeanContextMembershipEvent(this, + new Object[] { targetChild })); return true; } public boolean addAll (Collection c) { + // Intentionally throws an exception. throw new UnsupportedOperationException(); } public void addBeanContextMembershipListener (BeanContextMembershipListener listener) { - if (! bcmListeners.contains(listener)) - bcmListeners.add(listener); + synchronized (bcmListeners) + { + if (! bcmListeners.contains(listener)) + bcmListeners.add(listener); + } } public boolean avoidingGui () + throws NotImplementedException { throw new Error ("Not implemented"); } protected Iterator bcsChildren () { - throw new Error ("Not implemented"); + synchronized (children) + { + return new BCSIterator(children.values().iterator()); + } } protected void bcsPreDeserializationHook (ObjectInputStream ois) - throws ClassNotFoundException, IOException + throws ClassNotFoundException, IOException, NotImplementedException { throw new Error ("Not implemented"); } protected void bcsPreSerializationHook (ObjectOutputStream oos) - throws IOException + throws IOException, NotImplementedException { throw new Error ("Not implemented"); } protected void childDeserializedHook (Object child, BeanContextSupport.BCSChild bcsc) + throws NotImplementedException { throw new Error ("Not implemented"); } protected void childJustAddedHook (Object child, BeanContextSupport.BCSChild bcsc) { - throw new Error ("Not implemented"); + // Do nothing in the base class. } protected void childJustRemovedHook (Object child, BeanContextSupport.BCSChild bcsc) { - throw new Error ("Not implemented"); + // Do nothing in the base class. } protected static final boolean classEquals (Class first, Class second) { - throw new Error ("Not implemented"); + // Lame function! + return (first == second || first.getName().equals(second.getName())); } public void clear () { + // This is the right thing to do. + // The JDK docs are really bad here. throw new UnsupportedOperationException(); } public boolean contains (Object o) { - throw new Error ("Not implemented"); + synchronized (children) + { + return children.containsKey(o); + } } public boolean containsAll (Collection c) { - throw new Error ("Not implemented"); + synchronized (children) + { + Iterator it = c.iterator(); + while (it.hasNext()) + if (! children.containsKey(it.next())) + return false; + } + return true; } public boolean containsKey (Object o) { - throw new Error ("Not implemented"); + synchronized (children) + { + return children.containsKey(o); + } } protected final Object[] copyChildren () { - throw new Error ("Not implemented"); + synchronized (children) + { + return children.keySet().toArray(); + } } protected BeanContextSupport.BCSChild createBCSChild (Object targetChild, Object peer) { - throw new Error ("Not implemented"); + return new BCSChild(targetChild, peer); } protected final void deserialize (ObjectInputStream ois, Collection coll) - throws ClassNotFoundException, IOException + throws ClassNotFoundException, IOException, NotImplementedException { throw new Error ("Not implemented"); } public void dontUseGui () + throws NotImplementedException { throw new Error ("Not implemented"); } protected final void fireChildrenAdded (BeanContextMembershipEvent bcme) { - throw new Error ("Not implemented"); + synchronized (bcmListeners) + { + Iterator it = bcmListeners.iterator(); + while (it.hasNext()) + { + BeanContextMembershipListener l + = (BeanContextMembershipListener) it.next(); + l.childrenAdded(bcme); + } + } } protected final void fireChildrenRemoved (BeanContextMembershipEvent bcme) { - throw new Error ("Not implemented"); + synchronized (bcmListeners) + { + Iterator it = bcmListeners.iterator(); + while (it.hasNext()) + { + BeanContextMembershipListener l + = (BeanContextMembershipListener) it.next(); + l.childrenRemoved(bcme); + } + } } public BeanContext getBeanContextPeer () + throws NotImplementedException { throw new Error ("Not implemented"); } protected static final BeanContextChild getChildBeanContextChild (Object child) + throws NotImplementedException { throw new Error ("Not implemented"); } protected static final BeanContextMembershipListener getChildBeanContextMembershipListener (Object child) + throws NotImplementedException { throw new Error ("Not implemented"); } protected static final PropertyChangeListener getChildPropertyChangeListener (Object child) + throws NotImplementedException { throw new Error ("Not implemented"); } protected static final Serializable getChildSerializable (Object child) + throws NotImplementedException { throw new Error ("Not implemented"); } protected static final VetoableChangeListener getChildVetoableChangeListener (Object child) + throws NotImplementedException { throw new Error ("Not implemented"); } protected static final Visibility getChildVisibility (Object child) + throws NotImplementedException { throw new Error ("Not implemented"); } @@ -315,12 +404,20 @@ public class BeanContextSupport extends BeanContextChildSupport public URL getResource (String name, BeanContextChild bcc) { - throw new Error ("Not implemented"); + if (! contains(bcc)) + throw new IllegalArgumentException("argument not a child"); + ClassLoader loader = bcc.getClass().getClassLoader(); + return (loader == null ? ClassLoader.getSystemResource(name) + : loader.getResource(name)); } public InputStream getResourceAsStream (String name, BeanContextChild bcc) { - throw new Error ("Not implemented"); + if (! contains(bcc)) + throw new IllegalArgumentException("argument not a child"); + ClassLoader loader = bcc.getClass().getClassLoader(); + return (loader == null ? ClassLoader.getSystemResourceAsStream(name) + : loader.getResourceAsStream(name)); } protected void initialize () @@ -330,48 +427,58 @@ public class BeanContextSupport extends BeanContextChildSupport } public Object instantiateChild (String beanName) - throws IOException, ClassNotFoundException + throws IOException, ClassNotFoundException, NotImplementedException { throw new Error ("Not implemented"); } public boolean isDesignTime () { - throw new Error ("Not implemented"); + return designTime; } public boolean isEmpty () { - throw new Error ("Not implemented"); + synchronized (children) + { + return children.isEmpty(); + } } public boolean isSerializing () + throws NotImplementedException { throw new Error ("Not implemented"); } public Iterator iterator () { - return children.keySet().iterator(); + synchronized (children) + { + return children.keySet().iterator(); + } } public boolean needsGui () + throws NotImplementedException { throw new Error ("Not implemented"); } public void okToUseGui () + throws NotImplementedException { throw new Error ("Not implemented"); } public void propertyChange (PropertyChangeEvent pce) + throws NotImplementedException { throw new Error ("Not implemented"); } public final void readChildren (ObjectInputStream ois) - throws IOException, ClassNotFoundException + throws IOException, ClassNotFoundException, NotImplementedException { throw new Error ("Not implemented"); } @@ -382,6 +489,7 @@ public class BeanContextSupport extends BeanContextChildSupport } protected boolean remove (Object targetChild, boolean callChildSetBC) + throws NotImplementedException { if (targetChild == null) throw new IllegalArgumentException(); @@ -391,69 +499,93 @@ public class BeanContextSupport extends BeanContextChildSupport public boolean removeAll (Collection c) { + // Intentionally throws an exception. throw new UnsupportedOperationException(); } public void removeBeanContextMembershipListener (BeanContextMembershipListener bcml) { - throw new Error ("Not implemented"); + synchronized (bcmListeners) + { + bcmListeners.remove(bcml); + } } public boolean retainAll (Collection c) { + // Intentionally throws an exception. throw new UnsupportedOperationException(); } protected final void serialize (ObjectOutputStream oos, Collection coll) - throws IOException + throws IOException, NotImplementedException { throw new Error ("Not implemented"); } public void setDesignTime (boolean dtime) { - throw new Error ("Not implemented"); + boolean save = designTime; + designTime = dtime; + firePropertyChange(DesignMode.PROPERTYNAME, Boolean.valueOf(save), + Boolean.valueOf(dtime)); } public void setLocale (Locale newLocale) throws PropertyVetoException { - throw new Error ("Not implemented"); + if (newLocale == null || locale == newLocale) + return; + fireVetoableChange("locale", locale, newLocale); + Locale oldLocale = locale; + locale = newLocale; + firePropertyChange("locale", oldLocale, newLocale); } public int size () { - throw new Error ("Not implemented"); + synchronized (children) + { + return children.size(); + } } public Object[] toArray () { - return children.keySet().toArray(); + synchronized (children) + { + return children.keySet().toArray(); + } } public Object[] toArray(Object[] array) + throws NotImplementedException { - return children.keySet().toArray(array); + // This implementation is incorrect, I think. + synchronized (children) + { + return children.keySet().toArray(array); + } } protected boolean validatePendingAdd (Object targetChild) { - throw new Error ("Not implemented"); + return true; } protected boolean validatePendingRemove (Object targetChild) { - throw new Error ("Not implemented"); + return true; } public void vetoableChange (PropertyChangeEvent pce) - throws PropertyVetoException + throws PropertyVetoException, NotImplementedException { throw new Error ("Not implemented"); } public final void writeChildren (ObjectOutputStream oos) - throws IOException + throws IOException, NotImplementedException { throw new Error ("Not implemented"); } |