You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@harmony.apache.org by ge...@apache.org on 2006/03/20 17:31:33 UTC
svn commit: r387239 [5/21] - in
/incubator/harmony/enhanced/classlib/trunk/modules/regex-beans-math: ./
Harmony/ doc/ doc/images/ make/ src/ src/common/ src/common/javasrc/
src/common/javasrc/java/ src/common/javasrc/java/applet/
src/common/javasrc/jav...
Added: incubator/harmony/enhanced/classlib/trunk/modules/regex-beans-math/src/common/javasrc/java/beans/PropertyEditorSupport.java
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/classlib/trunk/modules/regex-beans-math/src/common/javasrc/java/beans/PropertyEditorSupport.java?rev=387239&view=auto
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/regex-beans-math/src/common/javasrc/java/beans/PropertyEditorSupport.java (added)
+++ incubator/harmony/enhanced/classlib/trunk/modules/regex-beans-math/src/common/javasrc/java/beans/PropertyEditorSupport.java Mon Mar 20 08:31:09 2006
@@ -0,0 +1,160 @@
+/*
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/**
+ * @author Maxim V. Berkultsev
+ * @version $Revision: 1.3.6.3 $
+ */
+package java.beans;
+
+import java.awt.Component;
+import java.awt.Graphics;
+import java.awt.Rectangle;
+import java.util.ArrayList;
+import java.util.Iterator;
+
+/**
+ * @author Maxim V. Berkultsev
+ * @version $Revision: 1.3.6.3 $
+ */
+
+public class PropertyEditorSupport implements PropertyEditor {
+
+ Object source = null;
+ ArrayList listeners = new ArrayList();
+ Object oldValue = null;
+ Object newValue = null;
+
+ /**
+ * @com.intel.drl.spec_ref
+ */
+ protected PropertyEditorSupport(Object source) {
+ this.source = source;
+ }
+
+ /**
+ * @com.intel.drl.spec_ref
+ */
+ protected PropertyEditorSupport() {
+ }
+
+ /**
+ * @com.intel.drl.spec_ref
+ */
+ public void paintValue(Graphics gfx, Rectangle box) {
+ }
+
+ /**
+ * @com.intel.drl.spec_ref
+ */
+ public void setAsText(String text) throws IllegalArgumentException {
+ setValue(text);
+ }
+
+ /**
+ * @com.intel.drl.spec_ref
+ */
+ public String[] getTags() {
+ return null;
+ }
+
+ /**
+ * @com.intel.drl.spec_ref
+ */
+ public String getJavaInitializationString() {
+ return "<Unknown>";
+ }
+
+ /**
+ * @com.intel.drl.spec_ref
+ */
+ public String getAsText() {
+ return (String) newValue;
+ }
+
+ /**
+ * @com.intel.drl.spec_ref
+ */
+ public void setValue(Object value) {
+ this.oldValue = this.newValue;
+ this.newValue = value;
+ firePropertyChange();
+ }
+
+ /**
+ * @com.intel.drl.spec_ref
+ */
+ public Object getValue() {
+ return newValue;
+ }
+
+ /**
+ * @com.intel.drl.spec_ref
+ */
+ public synchronized void removePropertyChangeListener(
+ PropertyChangeListener listener) {
+ if(listeners != null) {
+ listeners.remove(listener);
+ }
+ }
+
+ /**
+ * @com.intel.drl.spec_ref
+ */
+ public synchronized void addPropertyChangeListener(
+ PropertyChangeListener listener) {
+ if (listener != null) {
+ listeners.add(listener);
+ }
+ }
+
+ /**
+ * @com.intel.drl.spec_ref
+ */
+ public Component getCustomEditor() {
+ return null;
+ }
+
+ /**
+ * @com.intel.drl.spec_ref
+ */
+ public boolean supportsCustomEditor() {
+ return false;
+ }
+
+ /**
+ * @com.intel.drl.spec_ref
+ */
+ public boolean isPaintable() {
+ return false;
+ }
+
+ /**
+ * @com.intel.drl.spec_ref
+ */
+ public void firePropertyChange() {
+ if(listeners.size() > 0) {
+ PropertyChangeEvent event = new PropertyChangeEvent(
+ source, null, oldValue, newValue);
+ Iterator iterator = listeners.iterator();
+ while (iterator.hasNext()) {
+ PropertyChangeListener listener =
+ (PropertyChangeListener) iterator.next();
+ listener.propertyChange(event);
+ }
+ }
+ }
+}
Added: incubator/harmony/enhanced/classlib/trunk/modules/regex-beans-math/src/common/javasrc/java/beans/PropertyVetoException.java
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/classlib/trunk/modules/regex-beans-math/src/common/javasrc/java/beans/PropertyVetoException.java?rev=387239&view=auto
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/regex-beans-math/src/common/javasrc/java/beans/PropertyVetoException.java (added)
+++ incubator/harmony/enhanced/classlib/trunk/modules/regex-beans-math/src/common/javasrc/java/beans/PropertyVetoException.java Mon Mar 20 08:31:09 2006
@@ -0,0 +1,47 @@
+/*
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/**
+ * @author Maxim V. Berkultsev
+ * @version $Revision: 1.2.6.3 $
+ */
+package java.beans;
+
+/**
+ * @author Maxim V. Berkultsev
+ * @version $Revision: 1.2.6.3 $
+ */
+
+public class PropertyVetoException extends Exception {
+
+ private String message;
+ private PropertyChangeEvent event;
+
+ /**
+ * @com.intel.drl.spec_ref
+ */
+ public PropertyVetoException(String message, PropertyChangeEvent event) {
+ this.message = message;
+ this.event = event;
+ }
+
+ /**
+ * @com.intel.drl.spec_ref
+ */
+ public PropertyChangeEvent getPropertyChangeEvent() {
+ return event;
+ }
+}
Added: incubator/harmony/enhanced/classlib/trunk/modules/regex-beans-math/src/common/javasrc/java/beans/SimpleBeanInfo.java
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/classlib/trunk/modules/regex-beans-math/src/common/javasrc/java/beans/SimpleBeanInfo.java?rev=387239&view=auto
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/regex-beans-math/src/common/javasrc/java/beans/SimpleBeanInfo.java (added)
+++ incubator/harmony/enhanced/classlib/trunk/modules/regex-beans-math/src/common/javasrc/java/beans/SimpleBeanInfo.java Mon Mar 20 08:31:09 2006
@@ -0,0 +1,142 @@
+/*
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/**
+ * @author Maxim V. Berkultsev
+ * @version $Revision: 1.4.6.3 $
+ */
+package java.beans;
+
+import java.awt.Image;
+import java.awt.Toolkit;
+import java.io.FileInputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.ArrayList;
+import java.util.Iterator;
+
+/**
+ * @author Maxim V. Berkultsev
+ * @version $Revision: 1.4.6.3 $
+ */
+
+public class SimpleBeanInfo implements BeanInfo {
+
+ /**
+ * @com.intel.drl.spec_ref
+ */
+ public SimpleBeanInfo() {
+ }
+
+ /**
+ * @com.intel.drl.spec_ref
+ */
+ public Image loadImage(String resourceName) {
+ byte[] result = null;
+ InputStream is = FileInputStream.class.getResourceAsStream(
+ resourceName);
+
+ if(is != null) {
+ ArrayList byteArrayList = new ArrayList();
+
+ byte b;
+ try {
+ while((b = (byte) is.read()) != -1) {
+ byteArrayList.add(new Byte(b));
+ }
+
+ result = new byte[byteArrayList.size()];
+
+ Iterator i = byteArrayList.iterator();
+ int idx = 0;
+ while(i.hasNext()) {
+ result[idx++] = ((Byte) i.next()).byteValue();
+ }
+
+ } catch (IOException ioe) {
+ byteArrayList.clear();
+ System.out.println(ioe.getClass() + ": " + ioe.getMessage());
+ } finally {
+ try {
+ is.close();
+ } catch (IOException ioe) {
+ System.out.println(ioe.getClass() + ": "
+ + ioe.getMessage());
+ }
+ }
+
+ return Toolkit.getDefaultToolkit().createImage(result);
+ } else {
+ return null;
+ }
+ }
+
+ /**
+ * @com.intel.drl.spec_ref
+ */
+ public PropertyDescriptor[] getPropertyDescriptors() {
+ return null;
+ }
+
+ /**
+ * @com.intel.drl.spec_ref
+ */
+ public MethodDescriptor[] getMethodDescriptors() {
+ return null;
+ }
+
+ /**
+ * @com.intel.drl.spec_ref
+ */
+ public EventSetDescriptor[] getEventSetDescriptors() {
+ return null;
+ }
+
+ /**
+ * @com.intel.drl.spec_ref
+ */
+ public BeanInfo[] getAdditionalBeanInfo() {
+ return null;
+ }
+
+ /**
+ * @com.intel.drl.spec_ref
+ */
+ public BeanDescriptor getBeanDescriptor() {
+ return null;
+ }
+
+ /**
+ * @com.intel.drl.spec_ref
+ */
+ public Image getIcon(int iconKind) {
+ return null;
+ }
+
+ /**
+ * @com.intel.drl.spec_ref
+ */
+ public int getDefaultPropertyIndex() {
+ return -1;
+ }
+
+ /**
+ * @com.intel.drl.spec_ref
+ */
+ public int getDefaultEventIndex() {
+ return -1;
+ }
+}
Added: incubator/harmony/enhanced/classlib/trunk/modules/regex-beans-math/src/common/javasrc/java/beans/Statement.java
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/classlib/trunk/modules/regex-beans-math/src/common/javasrc/java/beans/Statement.java?rev=387239&view=auto
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/regex-beans-math/src/common/javasrc/java/beans/Statement.java (added)
+++ incubator/harmony/enhanced/classlib/trunk/modules/regex-beans-math/src/common/javasrc/java/beans/Statement.java Mon Mar 20 08:31:09 2006
@@ -0,0 +1,391 @@
+/*
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/**
+ * @author Maxim V. Berkultsev
+ * @version $Revision: 1.18.6.3 $
+ */
+package java.beans;
+
+import java.lang.reflect.Array;
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
+import java.lang.reflect.Constructor;
+import java.lang.reflect.Modifier;
+
+import java.security.AccessController;
+import java.security.PrivilegedAction;
+import java.util.StringTokenizer;
+
+/**
+ * @author Maxim V. Berkultsev
+ * @version $Revision: 1.18.6.3 $
+ */
+
+public class Statement {
+
+ private Object target;
+ private String methodName;
+ private Object[] arguments;
+
+ /**
+ * @com.intel.drl.spec_ref
+ */
+ public Statement(Object target, String methodName, Object[] arguments) {
+ this.target = target;
+ this.methodName = methodName;
+ this.arguments = arguments;
+ }
+
+ /**
+ * @com.intel.drl.spec_ref
+ */
+ public String toString() {
+ String targetVar = convertClassName(target.getClass());
+
+ String argumentsVar = "";
+ if(arguments.length > 0) {
+ argumentsVar = convertClassName(arguments[0].getClass());
+ }
+ for(int i = 1; i < arguments.length; ++i) {
+ argumentsVar = argumentsVar + "," + convertClassName(
+ arguments[0].getClass());
+ }
+ return targetVar + "." + methodName + "(" + argumentsVar + ")";
+ }
+
+ /**
+ * @com.intel.drl.spec_ref
+ */
+ public String getMethodName() {
+ return methodName;
+ }
+
+ /**
+ * @com.intel.drl.spec_ref
+ */
+ public Object[] getArguments() {
+ return arguments;
+ }
+
+ /**
+ * @com.intel.drl.spec_ref
+ */
+ public Object getTarget() {
+ return target;
+ }
+
+ /**
+ * @com.intel.drl.spec_ref
+ */
+ public void execute() throws Exception {
+ invokeMethod();
+ }
+
+ Object invokeMethod() throws Exception {
+ Object result = null;
+
+ try {
+ if(target.getClass().isArray()) {
+ Method method = findArrayMethod();
+ Object[] ama = getArrayMethodArguments();
+ result = method.invoke(null, ama);
+ } else if(methodName.equals("new")) {
+ if(target instanceof Class) {
+ Class type = (Class) target;
+ if(type.isArray()) {
+ Class componentType = type.getComponentType();
+ int length = ((Integer) arguments[0]).intValue();
+ result = Array.newInstance(componentType, length);
+ } else {
+ Constructor constructor = findConstructor();
+ result = constructor.newInstance(arguments);
+ }
+ } else {
+ Constructor constructor = findConstructor();
+ result = constructor.newInstance(arguments);
+ }
+ } else if(target instanceof Class) {
+ Method method = findStaticMethod();
+ result = method.invoke(null, arguments);
+ } else {
+ final Method method = findMethod();
+
+ AccessController.doPrivileged(new PrivilegedAction() {
+ public Object run() {
+ method.setAccessible(true);
+ return null;
+ }
+ });
+ result = method.invoke(target, arguments);
+ }
+ } catch (InvocationTargetException ite) {
+ Throwable t = ite.getCause();
+ throw (t != null) && (t instanceof Exception) ? (Exception) t : ite;
+ }
+ return result;
+ }
+
+ private Method findArrayMethod() throws NoSuchMethodException {
+ if(!methodName.equals("set") && !methodName.equals("get")) {
+ throw new NoSuchMethodException("Unknown method name for array");
+ } else if(methodName.equals("get") && (arguments.length != 1) ) {
+ throw new NoSuchMethodException(
+ "Illegal number of arguments in array getter");
+ } else if(methodName.equals("set") && (arguments.length != 2) ) {
+ throw new NoSuchMethodException(
+ "Illegal number of arguments in array setter");
+ } else if(arguments[0].getClass() != Integer.class) {
+ throw new NoSuchMethodException(
+ "First parameter in array getter(setter) is not of "
+ + "Integer type");
+ }
+
+ Class[] argClasses = methodName.equals("get") ?
+ new Class[] { Object.class, int.class } :
+ new Class[] { Object.class, int.class, Object.class };
+
+ return Array.class.getMethod(methodName, argClasses );
+ }
+
+ private Object[] getArrayMethodArguments() {
+ Object[] args = new Object[arguments.length + 1];
+ args[0] = target;
+ for(int i = 0; i < arguments.length; ++i) {
+ args[i + 1] = arguments[i];
+ }
+ return args;
+ }
+
+ private Constructor findConstructor() throws NoSuchMethodException {
+ Class[] argClasses = getClasses();
+ Class targetClass = (Class) target;
+
+ Constructor result = null;
+
+ Constructor[] constructors = targetClass.getConstructors();
+ for(int i = 0; i < constructors.length; ++i) {
+ Constructor constructor = constructors[i];
+ Class[] parameterTypes = constructor.getParameterTypes();
+
+ if(parameterTypes.length == argClasses.length) {
+ boolean found = true;
+
+ for(int j = 0; j < parameterTypes.length; ++j) {
+ boolean argIsNull = argClasses[j] == null;
+ boolean argIsPrimitiveWrapper = isPrimitiveWrapper(
+ argClasses[j], parameterTypes[j]);
+ boolean paramIsPrimitive =
+ parameterTypes[j].isPrimitive();
+ boolean paramIsAssignable = argIsNull ? false
+ : parameterTypes[j].isAssignableFrom(
+ argClasses[j]);
+
+ if(!argIsNull && !paramIsAssignable
+ && !argIsPrimitiveWrapper
+ || argIsNull && paramIsPrimitive) {
+ found = false;
+ break;
+ }
+ }
+
+ if(found) {
+ result = constructor;
+ break;
+ }
+ }
+ }
+
+ if(result == null) {
+ throw new NoSuchMethodException(
+ "No constructor for class " + targetClass.getName()
+ + " found");
+ }
+
+ return result;
+ }
+
+ private Method findStaticMethod() throws NoSuchMethodException {
+ Class[] argClasses = getClasses();
+ Class targetClass = (Class) target;
+
+ Method result = null;
+
+ Method[] methods = targetClass.getMethods();
+ for(int i = 0; i < methods.length; ++i) {
+ Method method = methods[i];
+ if(!method.getName().equals(methodName) || !Modifier.isStatic(
+ method.getModifiers())) {
+ continue;
+ }
+ Class[] parameterTypes = method.getParameterTypes();
+ if(parameterTypes.length == argClasses.length) {
+ boolean found = true;
+
+ for(int j = 0; j < parameterTypes.length; ++j) {
+ boolean argIsNull = (argClasses[j] == null);
+ boolean argIsPrimitiveWrapper = isPrimitiveWrapper(
+ argClasses[j], parameterTypes[j]);
+ boolean paramIsPrimitive = parameterTypes[j].isPrimitive();
+ boolean paramIsAssignable = argIsNull ? false
+ : parameterTypes[j].isAssignableFrom(argClasses[j]);
+
+ if(!argIsNull && !paramIsAssignable
+ && !argIsPrimitiveWrapper
+ || argIsNull && paramIsPrimitive) {
+ found = false;
+ break;
+ }
+ }
+
+ if(found) {
+ result = method;
+ break;
+ }
+ }
+ }
+
+ if(result == null) {
+ throw new NoSuchMethodException("No method with name " + methodName
+ + " is found");
+ }
+
+ return result;
+ }
+
+ private Method findMethod() throws NoSuchMethodException {
+ Class[] argClasses = getClasses();
+ Class targetClass = target.getClass();
+
+ Method result = null;
+
+ Method[] methods = targetClass.getMethods();
+ for(int i = 0; i < methods.length; ++i) {
+ Method method = methods[i];
+
+ if(method.getName().equals(methodName)) {
+ Class[] parameterTypes = method.getParameterTypes();
+
+ if(parameterTypes.length == argClasses.length) {
+ boolean found = true;
+
+ for(int j = 0; j < parameterTypes.length; ++j) {
+ boolean argIsNull = argClasses[j] == null;
+ boolean argIsPrimitiveWrapper = isPrimitiveWrapper(
+ argClasses[j], parameterTypes[j]);
+ boolean paramIsPrimitive =
+ parameterTypes[j].isPrimitive();
+ boolean paramIsAssignable = argIsNull ? false
+ : parameterTypes[j].isAssignableFrom(
+ argClasses[j]);
+
+ if(!argIsNull && !paramIsAssignable
+ && !argIsPrimitiveWrapper
+ || argIsNull && paramIsPrimitive) {
+ found = false;
+ break;
+ }
+ }
+
+ if(found) {
+ result = method;
+ break;
+ }
+ }
+ }
+ }
+
+ if(result == null) {
+ throw new NoSuchMethodException("No method with name " + methodName
+ + " is found");
+ }
+
+ return result;
+ }
+
+ private boolean areAllParamsDefined(Class[] argClasses) {
+ boolean result = true;
+ for(int i = 0; i < argClasses.length; ++i) {
+ if(argClasses[i] == null) {
+ result = false;
+ break;
+ }
+ }
+ return result;
+ }
+
+ private static boolean isPrimitiveWrapper(Class wrapper, Class base) {
+ return
+ (base == boolean.class) && (wrapper == Boolean.class) ||
+ (base == byte.class) && (wrapper == Byte.class) ||
+ (base == char.class) && (wrapper == Character.class) ||
+ (base == short.class) && (wrapper == Short.class) ||
+ (base == int.class) && (wrapper == Integer.class) ||
+ (base == long.class) && (wrapper == Long.class) ||
+ (base == float.class) && (wrapper == Float.class) ||
+ (base == double.class) && (wrapper == Double.class);
+ }
+
+ static String convertClassName(Class type) {
+ Class componentType = type.getComponentType();
+ Class resultType = (componentType == null) ? type : componentType;
+ StringTokenizer st = new StringTokenizer(resultType.getName(), ".");
+ String result = st.hasMoreElements() ? (String) st.nextElement() : null;
+ if(result == null) return result;
+ while(st.hasMoreElements()) {
+ result += "_" + (String) st.nextElement();
+ }
+ if(componentType != null) {
+ result += "_array";
+ }
+ return result;
+ }
+
+ private Class[] getClasses() {
+ Class[] result = new Class[arguments.length];
+ for(int i = 0; i < arguments.length; ++i) {
+ result[i] = (arguments[i] == null) ? null : arguments[i].getClass();
+ }
+ return result;
+ }
+
+ public boolean equals(Object o) {
+ if(o instanceof Statement) {
+ Statement s = (Statement) o;
+
+ Object[] otherArguments = s.getArguments();
+ boolean argsEqual = (otherArguments.length == arguments.length);
+ if(argsEqual) {
+ for(int i = 0; i < arguments.length; ++i) {
+ if(otherArguments[i] != arguments[i]) {
+ argsEqual = false;
+ break;
+ }
+ }
+ }
+
+ if(!argsEqual) {
+ return false;
+ } else {
+ return (s.getTarget() == this.getTarget() &&
+ s.getMethodName().equals(this.getMethodName()));
+ }
+
+ } else {
+ return false;
+ }
+ }
+}
Added: incubator/harmony/enhanced/classlib/trunk/modules/regex-beans-math/src/common/javasrc/java/beans/VetoableChangeListener.java
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/classlib/trunk/modules/regex-beans-math/src/common/javasrc/java/beans/VetoableChangeListener.java?rev=387239&view=auto
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/regex-beans-math/src/common/javasrc/java/beans/VetoableChangeListener.java (added)
+++ incubator/harmony/enhanced/classlib/trunk/modules/regex-beans-math/src/common/javasrc/java/beans/VetoableChangeListener.java Mon Mar 20 08:31:09 2006
@@ -0,0 +1,37 @@
+/*
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/**
+ * @author Maxim V. Berkultsev
+ * @version $Revision: 1.3.6.3 $
+ */
+package java.beans;
+
+import java.util.EventListener;
+
+/**
+ * @author Maxim V. Berkultsev
+ * @version $Revision: 1.3.6.3 $
+ */
+
+public interface VetoableChangeListener extends EventListener {
+
+ /**
+ * @com.intel.drl.spec_ref
+ */
+ public void vetoableChange(PropertyChangeEvent evt)
+ throws PropertyVetoException;
+}
Added: incubator/harmony/enhanced/classlib/trunk/modules/regex-beans-math/src/common/javasrc/java/beans/VetoableChangeListenerProxy.java
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/classlib/trunk/modules/regex-beans-math/src/common/javasrc/java/beans/VetoableChangeListenerProxy.java?rev=387239&view=auto
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/regex-beans-math/src/common/javasrc/java/beans/VetoableChangeListenerProxy.java (added)
+++ incubator/harmony/enhanced/classlib/trunk/modules/regex-beans-math/src/common/javasrc/java/beans/VetoableChangeListenerProxy.java Mon Mar 20 08:31:09 2006
@@ -0,0 +1,60 @@
+/*
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/**
+ * @author Maxim V. Berkultsev
+ * @version $Revision: 1.3.6.3 $
+ */
+package java.beans;
+
+import java.util.EventListenerProxy;
+
+/**
+ * @author Maxim V. Berkultsev
+ * @version $Revision: 1.3.6.3 $
+ */
+
+public class VetoableChangeListenerProxy extends EventListenerProxy
+ implements VetoableChangeListener {
+
+ private String propertyName;
+
+ /**
+ * @com.intel.drl.spec_ref
+ */
+ public VetoableChangeListenerProxy(
+ String propertyName, VetoableChangeListener listener) {
+ super(listener);
+ this.propertyName = propertyName;
+ }
+
+ /**
+ * @com.intel.drl.spec_ref
+ */
+ public String getPropertyName() {
+ return propertyName;
+ }
+
+ /**
+ * @com.intel.drl.spec_ref
+ */
+ public void vetoableChange(PropertyChangeEvent evt)
+ throws PropertyVetoException {
+ VetoableChangeListener listener =
+ (VetoableChangeListener) getListener();
+ if(listener != null) listener.vetoableChange(evt);
+ }
+}
Added: incubator/harmony/enhanced/classlib/trunk/modules/regex-beans-math/src/common/javasrc/java/beans/VetoableChangeSupport.java
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/classlib/trunk/modules/regex-beans-math/src/common/javasrc/java/beans/VetoableChangeSupport.java?rev=387239&view=auto
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/regex-beans-math/src/common/javasrc/java/beans/VetoableChangeSupport.java (added)
+++ incubator/harmony/enhanced/classlib/trunk/modules/regex-beans-math/src/common/javasrc/java/beans/VetoableChangeSupport.java Mon Mar 20 08:31:09 2006
@@ -0,0 +1,357 @@
+/*
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/**
+ * @author Maxim V. Berkultsev
+ * @version $Revision: 1.8.2.3 $
+ */
+package java.beans;
+
+import java.io.IOException;
+import java.io.ObjectInputStream;
+import java.io.ObjectOutputStream;
+import java.io.Serializable;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.Hashtable;
+import java.util.Iterator;
+
+/**
+ * @author Maxim V. Berkultsev
+ * @version $Revision: 1.8.2.3 $
+ */
+
+public class VetoableChangeSupport implements Serializable {
+
+ private static final long serialVersionUID = -5090210921595982017l;
+
+ private transient Object sourceBean;
+ private transient ArrayList allVetoableChangeListeners = new ArrayList();
+ private transient HashMap selectedVetoableChangeListeners = new HashMap();
+
+ // fields for serialization compatibility
+ private Hashtable children;
+ private Object source;
+ private int vetoableChangeSupportSerializedDataVersion = 1;
+
+ /**
+ * @com.intel.drl.spec_ref
+ */
+ public VetoableChangeSupport(Object sourceBean) {
+ this.sourceBean = sourceBean;
+ }
+
+ /**
+ * @com.intel.drl.spec_ref
+ */
+ public void fireVetoableChange(
+ String propertyName, Object oldValue, Object newValue) throws PropertyVetoException {
+ PropertyChangeEvent event = createPropertyChangeEvent(propertyName,
+ oldValue, newValue);
+ doFirePropertyChange(event);
+ }
+
+ /**
+ * @com.intel.drl.spec_ref
+ */
+ public synchronized void removeVetoableChangeListener(
+ String propertyName, VetoableChangeListener listener) {
+ if ( (propertyName != null) && (listener != null) ) {
+ ArrayList listeners =
+ (ArrayList) selectedVetoableChangeListeners.get(propertyName);
+
+ if(listeners != null) {
+ listeners.remove(listener);
+ }
+ }
+ }
+
+ /**
+ * @com.intel.drl.spec_ref
+ */
+ public synchronized void addVetoableChangeListener(
+ String propertyName, VetoableChangeListener listener) {
+ if(propertyName == null) {
+ throw new NullPointerException("propertyName is null");
+ } else if(listener != null) {
+ ArrayList listeners =
+ (ArrayList) selectedVetoableChangeListeners.get(propertyName);
+
+ if (listeners == null) {
+ listeners = new ArrayList();
+ selectedVetoableChangeListeners.put(propertyName, listeners);
+ }
+
+ listeners.add(listener);
+ }
+ }
+
+ /**
+ * @com.intel.drl.spec_ref
+ */
+ public synchronized VetoableChangeListener[] getVetoableChangeListeners(
+ String propertyName) {
+ ArrayList listeners = null;
+
+ if (propertyName != null) {
+ listeners = (ArrayList) selectedVetoableChangeListeners.get(
+ propertyName);
+ }
+
+ return (listeners == null) ? new VetoableChangeListener[] {} :
+ getAsVetoableChangeListenerArray(listeners);
+
+ }
+
+ /**
+ * @com.intel.drl.spec_ref
+ */
+ public void fireVetoableChange(
+ String propertyName,
+ boolean oldValue,
+ boolean newValue) throws PropertyVetoException {
+ PropertyChangeEvent event = createPropertyChangeEvent(
+ propertyName, oldValue, newValue);
+ doFirePropertyChange(event);
+ }
+
+ /**
+ * @com.intel.drl.spec_ref
+ */
+ public void fireVetoableChange(
+ String propertyName,
+ int oldValue,
+ int newValue) throws PropertyVetoException {
+ PropertyChangeEvent event = createPropertyChangeEvent(
+ propertyName, oldValue, newValue);
+ doFirePropertyChange(event);
+ }
+
+ /**
+ * @com.intel.drl.spec_ref
+ */
+ public synchronized boolean hasListeners(String propertyName) {
+ boolean result = allVetoableChangeListeners.size() > 0;
+ if (!result && propertyName != null) {
+ ArrayList listeners =
+ (ArrayList) selectedVetoableChangeListeners.get(propertyName);
+ if (listeners != null) {
+ result = listeners.size() > 0;
+ }
+ }
+ return result;
+ }
+
+ /**
+ * @com.intel.drl.spec_ref
+ */
+ public synchronized void removeVetoableChangeListener(
+ VetoableChangeListener listener) {
+ if (listener != null) {
+ Iterator iterator = allVetoableChangeListeners.iterator();
+ while (iterator.hasNext()) {
+ VetoableChangeListener pcl =
+ (VetoableChangeListener) iterator.next();
+ if (pcl == listener) {
+ iterator.remove();
+ break;
+ }
+ }
+ }
+ }
+
+ /**
+ * @com.intel.drl.spec_ref
+ */
+ public synchronized void addVetoableChangeListener(
+ VetoableChangeListener listener) {
+ if (listener != null) {
+ allVetoableChangeListeners.add(listener);
+ }
+ }
+
+ /**
+ * @com.intel.drl.spec_ref
+ */
+ public synchronized VetoableChangeListener[] getVetoableChangeListeners() {
+ ArrayList result = new ArrayList(allVetoableChangeListeners);
+
+ Iterator keysIterator =
+ selectedVetoableChangeListeners.keySet().iterator();
+ while (keysIterator.hasNext()) {
+ String propertyName = (String) keysIterator.next();
+
+ ArrayList selectedListeners =
+ (ArrayList) selectedVetoableChangeListeners.get(propertyName);
+ if(selectedListeners != null) {
+
+ Iterator i = selectedListeners.iterator();
+ while(i.hasNext()) {
+ VetoableChangeListener listener =
+ (VetoableChangeListener) i.next();
+ result.add(new VetoableChangeListenerProxy(
+ propertyName, listener));
+ }
+
+ }
+
+ }
+
+ return getAsVetoableChangeListenerArray(result);
+ }
+
+ /**
+ * @com.intel.drl.spec_ref
+ */
+ private void writeObject(ObjectOutputStream oos) throws IOException {
+ ArrayList allSerializedVetoableChangeListeners = new ArrayList();
+ Iterator i = allVetoableChangeListeners.iterator();
+ while(i.hasNext()) {
+ VetoableChangeListener vcl = (VetoableChangeListener) i.next();
+ if(vcl instanceof Serializable) {
+ allSerializedVetoableChangeListeners.add(vcl);
+ }
+ }
+
+ HashMap selectedSerializedVetoableChangeListeners = new HashMap();
+ Iterator keyIterator =
+ selectedVetoableChangeListeners.keySet().iterator();
+ while(keyIterator.hasNext()) {
+ String propertyName = (String) keyIterator.next();
+ ArrayList keyValues =
+ (ArrayList) selectedVetoableChangeListeners.get(propertyName);
+ if(keyValues != null) {
+ ArrayList serializedVetoableChangeListeners = new ArrayList();
+
+ Iterator j = keyValues.iterator();
+ while(j.hasNext()) {
+ PropertyChangeListener pcl =
+ (PropertyChangeListener) j.next();
+ if(pcl instanceof Serializable) {
+ serializedVetoableChangeListeners.add(pcl);
+ }
+ }
+
+ if(!serializedVetoableChangeListeners.isEmpty()) {
+ selectedSerializedVetoableChangeListeners.put(
+ propertyName, serializedVetoableChangeListeners);
+ }
+
+ }
+ }
+
+ children = new Hashtable(selectedSerializedVetoableChangeListeners);
+ children.put("", allSerializedVetoableChangeListeners);
+ oos.writeObject(children);
+
+ Object source = null;
+ if((sourceBean != null) && (sourceBean instanceof Serializable)) {
+ source = sourceBean;
+ }
+ oos.writeObject(source);
+
+ oos.writeInt(vetoableChangeSupportSerializedDataVersion);
+ }
+
+ /**
+ * @com.intel.drl.spec_ref
+ */
+ private void readObject(ObjectInputStream ois)
+ throws IOException, ClassNotFoundException {
+ allVetoableChangeListeners = (ArrayList) ois.readObject();
+ selectedVetoableChangeListeners = (HashMap) ois.readObject();
+
+ children = (Hashtable) ois.readObject();
+
+ selectedVetoableChangeListeners = new HashMap(children);
+ allVetoableChangeListeners =
+ (ArrayList) selectedVetoableChangeListeners.remove("");
+ if(allVetoableChangeListeners == null) {
+ allVetoableChangeListeners = new ArrayList();
+ }
+
+ sourceBean = ois.readObject();
+ vetoableChangeSupportSerializedDataVersion = ois.readInt();
+ }
+
+ /**
+ * @com.intel.drl.spec_ref
+ */
+ public void fireVetoableChange(PropertyChangeEvent event)
+ throws PropertyVetoException {
+ doFirePropertyChange(event);
+ }
+
+ private PropertyChangeEvent createPropertyChangeEvent(
+ String propertyName, Object oldValue, Object newValue) {
+ return new PropertyChangeEvent(sourceBean, propertyName, oldValue,
+ newValue);
+ }
+
+ private PropertyChangeEvent createPropertyChangeEvent(
+ String propertyName, boolean oldValue, boolean newValue) {
+ return new PropertyChangeEvent(sourceBean, propertyName,
+ new Boolean(oldValue), new Boolean(newValue));
+ }
+
+ private PropertyChangeEvent createPropertyChangeEvent(
+ String propertyName, int oldValue, int newValue) {
+ return new PropertyChangeEvent(sourceBean, propertyName,
+ new Integer(oldValue), new Integer(newValue));
+ }
+
+ private void doFirePropertyChange(PropertyChangeEvent event)
+ throws PropertyVetoException {
+ String propertyName = event.getPropertyName();
+ Object oldValue = event.getOldValue();
+ Object newValue = event.getNewValue();
+
+ if (newValue != null && oldValue != null && newValue.equals(oldValue)) {
+ return;
+ }
+
+ Iterator iterator = allVetoableChangeListeners.iterator();
+ while (iterator.hasNext()) {
+ VetoableChangeListener listener =
+ (VetoableChangeListener) iterator.next();
+ listener.vetoableChange(event);
+ }
+
+ ArrayList listeners = (ArrayList) selectedVetoableChangeListeners.get(
+ propertyName);
+ if (listeners != null) {
+ iterator = listeners.iterator();
+ while (iterator.hasNext()) {
+ VetoableChangeListener listener =
+ (VetoableChangeListener) iterator.next();
+ listener.vetoableChange(event);
+ }
+ }
+ }
+
+ private static VetoableChangeListener[] getAsVetoableChangeListenerArray(
+ ArrayList listeners) {
+ Object[] objects = listeners.toArray();
+ VetoableChangeListener[] arrayResult =
+ new VetoableChangeListener[objects.length];
+
+ for(int i = 0; i < objects.length; ++i) {
+ arrayResult[i] = (VetoableChangeListener) objects[i];
+ }
+
+ return arrayResult;
+ }
+}
Added: incubator/harmony/enhanced/classlib/trunk/modules/regex-beans-math/src/common/javasrc/java/beans/Visibility.java
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/classlib/trunk/modules/regex-beans-math/src/common/javasrc/java/beans/Visibility.java?rev=387239&view=auto
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/regex-beans-math/src/common/javasrc/java/beans/Visibility.java (added)
+++ incubator/harmony/enhanced/classlib/trunk/modules/regex-beans-math/src/common/javasrc/java/beans/Visibility.java Mon Mar 20 08:31:09 2006
@@ -0,0 +1,49 @@
+/*
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/**
+ * @author Maxim V. Berkultsev
+ * @version $Revision: 1.2.6.3 $
+ */
+package java.beans;
+
+/**
+ * @author Maxim V. Berkultsev
+ * @version $Revision: 1.2.6.3 $
+ */
+
+public interface Visibility {
+
+ /**
+ * @com.intel.drl.spec_ref
+ */
+ public boolean needsGui();
+
+ /**
+ * @com.intel.drl.spec_ref
+ */
+ public boolean avoidingGui();
+
+ /**
+ * @com.intel.drl.spec_ref
+ */
+ public void okToUseGui();
+
+ /**
+ * @com.intel.drl.spec_ref
+ */
+ public void dontUseGui();
+}
Added: incubator/harmony/enhanced/classlib/trunk/modules/regex-beans-math/src/common/javasrc/java/beans/XMLDecoder.java
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/classlib/trunk/modules/regex-beans-math/src/common/javasrc/java/beans/XMLDecoder.java?rev=387239&view=auto
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/regex-beans-math/src/common/javasrc/java/beans/XMLDecoder.java (added)
+++ incubator/harmony/enhanced/classlib/trunk/modules/regex-beans-math/src/common/javasrc/java/beans/XMLDecoder.java Mon Mar 20 08:31:09 2006
@@ -0,0 +1,149 @@
+/*
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/**
+ * @author Maxim V. Berkultsev
+ * @version $Revision: 1.14.6.4 $
+ */
+package java.beans;
+
+import java.io.InputStream;
+import java.io.IOException;
+import java.util.Iterator;
+import java.util.NoSuchElementException;
+import java.util.Vector;
+
+import org.xml.sax.helpers.XMLReaderFactory;
+import org.xml.sax.XMLReader;
+import org.xml.sax.InputSource;
+import org.xml.sax.SAXException;
+
+import org.apache.harmony.beans.Handler;
+
+/**
+ * @author Maxim V. Berkultsev
+ * @version $Revision: 1.14.6.4 $
+ */
+
+public class XMLDecoder {
+
+ private InputStream is = null;
+ private Object owner = null;
+ private ExceptionListener exceptionListener = null;
+
+ private Vector objects = new Vector();
+ private Iterator iterator = null;
+
+ /**
+ * @com.intel.drl.spec_ref
+ */
+ public XMLDecoder(
+ InputStream is, Object owner, ExceptionListener exceptionListener) {
+ this.is = is;
+ this.owner = owner;
+ this.exceptionListener = exceptionListener;
+ }
+
+ /**
+ * @com.intel.drl.spec_ref
+ */
+ public XMLDecoder(InputStream is, Object owner) {
+ this.is = is;
+ this.owner = owner;
+ }
+
+ /**
+ * @com.intel.drl.spec_ref
+ */
+ public XMLDecoder(InputStream is) { this.is = is; }
+
+ /**
+ * @com.intel.drl.spec_ref
+ */
+ public void setOwner(Object owner) { this.owner = owner; }
+
+ /**
+ * @com.intel.drl.spec_ref
+ */
+ public Object readObject() {
+ try {
+ if(iterator == null) {
+ initialize();
+ }
+ return iterator.next();
+ } catch (NoSuchElementException nsee) {
+ throw new ArrayIndexOutOfBoundsException();
+ }
+ }
+
+ /**
+ * @com.intel.drl.spec_ref
+ */
+ public Object getOwner() { return owner; }
+
+ /**
+ * @com.intel.drl.spec_ref
+ */
+ public void setExceptionListener(ExceptionListener exceptionListener) {
+ this.exceptionListener = exceptionListener;
+ }
+
+ /**
+ * @com.intel.drl.spec_ref
+ */
+ public ExceptionListener getExceptionListener() {
+ return exceptionListener;
+ }
+
+ /**
+ * @com.intel.drl.spec_ref
+ */
+ public void close() {
+ try {
+ is.close();
+ } catch (IOException ioe) {
+ handleException(ioe);
+ }
+ }
+
+ private void handleException(Exception e) {
+ if(exceptionListener != null) {
+ exceptionListener.exceptionThrown(e);
+ }
+ }
+
+ private void initialize() {
+ try {
+ String saxParserClassName = System.getProperty(
+ "org.xml.sax.driver");
+ if(saxParserClassName == null) {
+ saxParserClassName = "org.apache.xerces.parsers.SAXParser";
+ }
+ XMLReader xmlReader = XMLReaderFactory.createXMLReader(
+ saxParserClassName);
+ xmlReader.setContentHandler(new Handler(this, objects));
+ xmlReader.parse(new InputSource(is));
+ } catch (SAXException saxe) {
+ saxe.printStackTrace();
+ handleException(saxe);
+ } catch (IOException ioe) {
+ ioe.printStackTrace();
+ handleException(ioe);
+ } finally {
+ iterator = objects.iterator();
+ }
+ }
+}
Added: incubator/harmony/enhanced/classlib/trunk/modules/regex-beans-math/src/common/javasrc/java/beans/XMLEncoder.java
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/classlib/trunk/modules/regex-beans-math/src/common/javasrc/java/beans/XMLEncoder.java?rev=387239&view=auto
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/regex-beans-math/src/common/javasrc/java/beans/XMLEncoder.java (added)
+++ incubator/harmony/enhanced/classlib/trunk/modules/regex-beans-math/src/common/javasrc/java/beans/XMLEncoder.java Mon Mar 20 08:31:09 2006
@@ -0,0 +1,484 @@
+/*
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/**
+ * @author Maxim V. Berkultsev
+ * @version $Revision: 1.13.6.4 $
+ */
+package java.beans;
+
+import java.io.IOException;
+import java.io.OutputStream;
+import java.util.Enumeration;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.Vector;
+
+import org.apache.harmony.beans.ObjectNode;
+
+/**
+ * @author Maxim V. Berkultsev
+ * @version $Revision: 1.13.6.4 $
+ */
+
+public class XMLEncoder extends Encoder {
+
+ private OutputStream out;
+ private Object owner;
+ private Vector printed = new Vector();
+
+ /**
+ * @com.intel.drl.spec_ref
+ */
+ public XMLEncoder(OutputStream out) {
+ this.out = out;
+ this.owner = null;
+ }
+
+ /**
+ * @com.intel.drl.spec_ref
+ */
+ public void writeObject(Object object) {
+ super.writeObject(object);
+ }
+
+ /**
+ * @com.intel.drl.spec_ref
+ */
+ public void setOwner(Object owner) {
+ this.owner = owner;
+ }
+
+ /**
+ * @com.intel.drl.spec_ref
+ */
+ public Object getOwner() {
+ return owner;
+ }
+
+ /**
+ * @com.intel.drl.spec_ref
+ */
+ public void writeStatement(Statement oldStm) {
+ super.writeStatement(oldStm);
+ }
+
+ /**
+ * @com.intel.drl.spec_ref
+ */
+ public void writeExpression(Expression oldExp) {
+ super.writeExpression(oldExp);
+ }
+
+ /**
+ * @com.intel.drl.spec_ref
+ */
+ public void flush() {
+ writeAll();
+ }
+
+ /**
+ * @com.intel.drl.spec_ref
+ */
+ public void close() {
+ try {
+ flush();
+ out.close();
+ } catch (Exception e) {
+ getExceptionListener().exceptionThrown(e);
+ }
+ }
+
+ private void writeAll() {
+ printed.clear();
+ NameMaker.clear();
+
+ Tag mainTag = new Tag("java");
+ mainTag.addAttr("version", System.getProperty("java.version"));
+ mainTag.addAttr("class", "java.beans.XMLDecoder");
+
+ printBytes(0, "<?xml version=\"1.0\" encoding=\"UTF-8\"?>");
+ printBytes(0, mainTag.toStringOnOpen());
+
+ Enumeration e = roots.elements();
+ while(e.hasMoreElements()) {
+ Object object = (Object) e.nextElement();
+ if(object != null) {
+ ObjectNode node = (ObjectNode) nodes.get(object);
+ printObjectTag(0, object, node);
+ } else {
+ printNullTag(0);
+ }
+ }
+
+ printBytes(0, mainTag.toStringOnClose());
+ }
+
+ private void printObjectTag(int tabCount, Object object, ObjectNode node) {
+ Class nodeType = null;
+ try {
+ nodeType = node.getObjectType();
+ } catch (Exception e) {
+ getExceptionListener().exceptionThrown(e);
+ getExceptionListener().exceptionThrown(new Exception(
+ "skipping expression " + node.getInitializer() + "..."));
+ return;
+ }
+
+ if(isPrimitive(nodeType) || isString(nodeType) || isClass(nodeType)) {
+ String tagName = getPrimitiveName(nodeType);
+ Object arg = node.getObjectArguments()[0];
+ Tag tag = new Tag(tagName, arg.toString());
+ printBytes(tabCount, tag.toString());
+ } else if(isArray(nodeType)) {
+ Object[] args = node.getObjectArguments();
+
+ Tag tag = new Tag("array");
+
+ tag.addAttr("class", object.getClass().getComponentType().getName());
+ tag.addAttr("length", ((Integer) args[0]).toString());
+
+ printBytes(tabCount, tag.toStringOnOpen());
+
+ Enumeration e = node.statements();
+ while(e.hasMoreElements()) {
+ Statement s = (Statement) e.nextElement();
+ printVoidTag(++tabCount, s);
+ --tabCount;
+ }
+
+ printBytes(tabCount, tag.toStringOnClose());
+ } else {
+ Tag tag = new Tag("object");
+
+ boolean objectPrinted = false;
+ //System.out.println("--->");
+ //System.out.println("node.getInitializer().getMethodName() = " + node.getInitializer().getMethodName());
+ //System.out.println("node.getReferencesNumber() = " + node.getReferencesNumber());
+ //System.out.println("node.getReferencedExpressionsNumber() = " + node.getReferencedExpressionsNumber());
+
+ boolean isReferenced = node.getReferencesNumber() > 0;
+
+ if(!isReferenced) {
+ Enumeration referencedExpressions = node.referencedExpressions();
+ while(referencedExpressions.hasMoreElements()) {
+ Expression expr =
+ (Expression) referencedExpressions.nextElement();
+
+ //System.out.println("expr.getMethodName() = "
+ // + expr.getMethodName());
+ }
+ }
+
+ //System.out.println("<---");
+
+ // check if the object presents references
+ if(isReferenced) {
+ if(printed.contains(node)) {
+ String nodeId = node.getId();
+
+ if(nodeId != null) {
+ tag.addAttr("idref", node.getId());
+ }
+
+ objectPrinted = true;
+ } else { // if(printed.contains(node) == false
+ try {
+ Class type = node.getObjectType();
+
+ if(type != null) {
+ // check if it is necessary to assign
+ // and display *id* attribute to the object
+ if(isReferenced) {
+ String objectName = NameMaker.getInstanceName(
+ type);
+
+ node.setId(objectName);
+ tag.addAttr("id", objectName);
+ }
+ }
+ } catch (Exception e) {
+ getExceptionListener().exceptionThrown(e);
+ }
+ }
+ }
+
+ if(!objectPrinted) {
+ try {
+ tag.addAttr("class", node.getObjectType().getName());
+ } catch (Exception e) {
+ getExceptionListener().exceptionThrown(e);
+ }
+ }
+
+ printBytes(tabCount, tag.toStringOnOpen());
+
+ if(!objectPrinted) {
+ printed.add(node);
+
+ Object[] arguments = node.getObjectArguments();
+ for(int i = 0; i < arguments.length; ++i) {
+ if(arguments[i] != null) {
+ ObjectNode succNode = (ObjectNode) nodes.get(
+ arguments[i]);
+ printObjectTag(++tabCount, arguments[i], succNode);
+ } else {
+ printNullTag(++tabCount);
+ }
+
+ --tabCount;
+ }
+
+ Enumeration e1 = node.expressions();
+ while(e1.hasMoreElements()) {
+ Expression e = (Expression) e1.nextElement();
+
+ printVoidTag(++tabCount, e);
+ --tabCount;
+ }
+
+ Enumeration e2 = node.statements();
+ while(e2.hasMoreElements()) {
+ Statement s = (Statement) e2.nextElement();
+
+ printVoidTag(++tabCount, s);
+ --tabCount;
+ }
+
+ }
+
+ printBytes(tabCount, tag.toStringOnClose());
+ } // if node is of non-trivial type
+ }
+
+ private void printVoidTag(int tabCount, Expression expr) {
+ Object exprValue = null;
+ try {
+ exprValue = expr.getValue();
+
+ // find out, if this object is already printed
+ Enumeration enumeration = printed.elements();
+ while(enumeration.hasMoreElements()) {
+ ObjectNode node = (ObjectNode) enumeration.nextElement();
+ if(node.getObjectValue() == exprValue) {
+ return;
+ }
+ }
+
+ ObjectNode node = (ObjectNode) nodes.get(exprValue);
+
+ // find out, if this object has no references to be printed
+ // System.out.println("---- node.getReferencesNumber() = " + node.getReferencesNumber());
+ // System.out.println("---- node.getReferencedExpressionsNumber() = " + node.getReferencedExpressionsNumber());
+
+ if(node.getReferencesNumber() == 0) {
+ return;
+ }
+
+ Tag tag = new Tag("void");
+
+ String objectName = NameMaker.getInstanceName(exprValue.getClass());
+
+ node.setId(objectName);
+ tag.addAttr("id", objectName);
+
+ String methodName = expr.getMethodName();
+ Object[] args = expr.getArguments();
+ if(methodName.startsWith("get")
+ && (args.length == 0 || args.length == 1
+ && args[0].getClass() == Integer.class)
+ || methodName.startsWith("set")
+ && (args.length == 1 || args.length == 2
+ && args[0].getClass() == Integer.class))
+ {
+ String propertyName = methodName.substring(3);
+ if(propertyName.length() > 0) {
+ tag.addAttr("property", Introspector.decapitalize(
+ propertyName));
+ }
+
+ if(methodName.startsWith("get") && args.length == 1 ||
+ methodName.startsWith("set") && args.length == 2)
+ {
+ tag.addAttr("index", args[0].toString());
+ }
+ } else {
+ tag.addAttr("method", expr.getMethodName());
+ }
+
+ printBytes(tabCount, tag.toStringOnOpen());
+
+ for(int i = tag.hasAttr("index") ? 1 : 0; i < args.length; ++i) {
+ if(args[i] != null) {
+ ObjectNode node2 = (ObjectNode) nodes.get(args[i]);
+ printObjectTag(++tabCount, args[i], node2);
+ } else {
+ printNullTag(++tabCount);
+ }
+
+ --tabCount;
+ }
+
+ printBytes(tabCount, tag.toStringOnClose());
+
+ printed.add(node);
+ } catch (Exception e) {
+ //TODO - signal problem with expr.getValue()
+ }
+
+ }
+
+ private void printVoidTag(int tabCount, Statement stat) {
+ Tag tag = new Tag("void");
+
+ String methodName = stat.getMethodName();
+ Object[] args = stat.getArguments();
+ if(methodName.startsWith("get")
+ && (args.length == 0 || args.length == 1
+ && args[0].getClass() == Integer.class)
+ || methodName.startsWith("set")
+ && (args.length == 1 || args.length == 2
+ && args[0].getClass() == Integer.class))
+ {
+ String propertyName = methodName.substring(3);
+ if(propertyName.length() > 0) {
+ tag.addAttr("property", Introspector.decapitalize(
+ propertyName));
+ }
+
+ if(methodName.startsWith("get") && args.length == 1 ||
+ methodName.startsWith("set") && args.length == 2)
+ {
+ tag.addAttr("index", args[0].toString());
+ }
+ } else {
+ tag.addAttr("method", stat.getMethodName());
+ }
+
+ printBytes(tabCount, tag.toStringOnOpen());
+
+ for(int i = tag.hasAttr("index") ? 1 : 0; i < args.length; ++i) {
+ if(args[i] != null) {
+ ObjectNode node = (ObjectNode) nodes.get(args[i]);
+ printObjectTag(++tabCount, args[i], node);
+ } else {
+ printNullTag(++tabCount);
+ }
+
+ --tabCount;
+ }
+
+ printBytes(tabCount, tag.toStringOnClose());
+ }
+
+ private void printNullTag(int tabCount) {
+ printBytes(tabCount, "<null/>");
+ }
+
+ private void printBytes(int tabCount, String s) {
+ try {
+ String result = "";
+ for(int i = 0; i < tabCount; ++i) result += '\t';
+ result = result + s + "\n";
+ out.write(result.getBytes("UTF-8"));
+ } catch (IOException ioe) {
+ ExceptionListener listener = getExceptionListener();
+ if(listener != null) {
+ listener.exceptionThrown(ioe);
+ }
+ }
+ }
+
+ class Tag {
+ String name;
+ HashMap attrs;
+ String characters;
+
+ public Tag(String name) {
+ this.name = name;
+ this.attrs = new HashMap();
+ this.characters = null;
+ }
+
+ public Tag(String name, String characters) {
+ this.name = name;
+ this.attrs = new HashMap();
+ this.characters = characters;
+ }
+
+ public boolean hasAttr(String attrName) {
+ return attrs.get(attrName) != null;
+ }
+
+ public void addAttr(String attrName, String attrValue) {
+ attrs.put(attrName, attrValue);
+ }
+
+ public String toStringOnOpen() {
+ String result = "<" + name;
+ Iterator i = attrs.keySet().iterator();
+ while(i.hasNext()) {
+ String attrName = (String) i.next();
+ String attrValue = (String) attrs.get(attrName);
+ result +=" " + attrName + "=\"" + attrValue + "\"";
+ }
+ result += ">";
+ return result;
+ }
+
+ public String toStringOnClose() {
+ return "</" + name + ">";
+ }
+
+ public String toStringOnCharacters() {
+ return characters;
+ }
+
+ public String toString() {
+ return toStringOnOpen() + toStringOnCharacters()
+ + toStringOnClose();
+ }
+
+ }
+
+}
+
+class NameMaker {
+ private static HashMap numOfExemplars = new HashMap();
+
+ public static void clear() {
+ numOfExemplars.clear();
+ }
+
+ public static String getInstanceName(Class type) {
+ String result = null;
+
+ String fullName = type.getName();
+ String shortName = fullName.substring(fullName.lastIndexOf(".") + 1);
+
+ Integer iNum = (Integer) numOfExemplars.get(shortName);
+
+ if(iNum == null) {
+ numOfExemplars.put(shortName, new Integer(0));
+ result = shortName + "0";
+ } else {
+ int newValue = iNum.intValue() + 1;
+ result = shortName + Integer.toString(newValue);
+ numOfExemplars.put(shortName, new Integer(newValue));
+ }
+ return result;
+ }
+}
Added: incubator/harmony/enhanced/classlib/trunk/modules/regex-beans-math/src/common/javasrc/java/beans/beancontext/BeanContext.java
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/classlib/trunk/modules/regex-beans-math/src/common/javasrc/java/beans/beancontext/BeanContext.java?rev=387239&view=auto
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/regex-beans-math/src/common/javasrc/java/beans/beancontext/BeanContext.java (added)
+++ incubator/harmony/enhanced/classlib/trunk/modules/regex-beans-math/src/common/javasrc/java/beans/beancontext/BeanContext.java Mon Mar 20 08:31:09 2006
@@ -0,0 +1,73 @@
+/*
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/**
+ * @author Sergei A. Krivenko
+ * @version $Revision: 1.3.4.3 $
+ */
+package java.beans.beancontext;
+
+import java.beans.DesignMode;
+import java.beans.Visibility;
+
+import java.io.IOException;
+import java.io.InputStream;
+
+import java.net.URL;
+
+import java.util.Collection;
+
+/**
+ * @author Sergei A. Krivenko
+ * @version $Revision: 1.3.4.3 $
+ */
+
+public interface BeanContext extends BeanContextChild, Collection, DesignMode,
+ Visibility {
+
+ /** @todo: find out what it should be initialized to **/
+ public static final Object globalHierarchyLock = new Object();
+
+ /**
+ * @com.intel.drl.spec_ref
+ */
+ public void addBeanContextMembershipListener(
+ BeanContextMembershipListener bcml);
+
+ /**
+ * @com.intel.drl.spec_ref
+ */
+ public URL getResource(String name, BeanContextChild bcc)
+ throws IllegalArgumentException;
+
+ /**
+ * @com.intel.drl.spec_ref
+ */
+ public InputStream getResourceAsStream(String name, BeanContextChild bcc)
+ throws IllegalArgumentException;
+
+ /**
+ * @com.intel.drl.spec_ref
+ */
+ public Object instantiateChild(String beanName)
+ throws IOException, ClassNotFoundException;
+
+ /**
+ * @com.intel.drl.spec_ref
+ */
+ public void removeBeanContextMembershipListener(
+ BeanContextMembershipListener bcml);
+}
Added: incubator/harmony/enhanced/classlib/trunk/modules/regex-beans-math/src/common/javasrc/java/beans/beancontext/BeanContextChild.java
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/classlib/trunk/modules/regex-beans-math/src/common/javasrc/java/beans/beancontext/BeanContextChild.java?rev=387239&view=auto
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/regex-beans-math/src/common/javasrc/java/beans/beancontext/BeanContextChild.java (added)
+++ incubator/harmony/enhanced/classlib/trunk/modules/regex-beans-math/src/common/javasrc/java/beans/beancontext/BeanContextChild.java Mon Mar 20 08:31:09 2006
@@ -0,0 +1,67 @@
+/*
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/**
+ * @author Sergei A. Krivenko
+ * @version $Revision: 1.2.4.3 $
+ */
+package java.beans.beancontext;
+
+import java.beans.PropertyChangeListener;
+import java.beans.PropertyVetoException;
+import java.beans.VetoableChangeListener;
+
+/**
+ * @author Sergei A. Krivenko
+ * @version $Revision: 1.2.4.3 $
+ */
+
+public interface BeanContextChild {
+
+ /**
+ * @com.intel.drl.spec_ref
+ */
+ public void addPropertyChangeListener(String name,
+ PropertyChangeListener pcl);
+
+ /**
+ * @com.intel.drl.spec_ref
+ */
+ public void addVetoableChangeListener(String name,
+ VetoableChangeListener vcl);
+
+ /**
+ * @com.intel.drl.spec_ref
+ */
+ public BeanContext getBeanContext();
+
+ /**
+ * @com.intel.drl.spec_ref
+ */
+ public void removePropertyChangeListener(String name,
+ PropertyChangeListener pcl);
+
+ /**
+ * @com.intel.drl.spec_ref
+ */
+ public void removeVetoableChangeListener(String name,
+ VetoableChangeListener vcl);
+
+ /**
+ * @com.intel.drl.spec_ref
+ */
+ public void setBeanContext(BeanContext bc) throws PropertyVetoException;
+}
Added: incubator/harmony/enhanced/classlib/trunk/modules/regex-beans-math/src/common/javasrc/java/beans/beancontext/BeanContextChildComponentProxy.java
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/classlib/trunk/modules/regex-beans-math/src/common/javasrc/java/beans/beancontext/BeanContextChildComponentProxy.java?rev=387239&view=auto
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/regex-beans-math/src/common/javasrc/java/beans/beancontext/BeanContextChildComponentProxy.java (added)
+++ incubator/harmony/enhanced/classlib/trunk/modules/regex-beans-math/src/common/javasrc/java/beans/beancontext/BeanContextChildComponentProxy.java Mon Mar 20 08:31:09 2006
@@ -0,0 +1,36 @@
+/*
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/**
+ * @author Sergei A. Krivenko
+ * @version $Revision: 1.2.4.3 $
+ */
+package java.beans.beancontext;
+
+import java.awt.Component;
+
+/**
+ * @author Sergei A. Krivenko
+ * @version $Revision: 1.2.4.3 $
+ */
+
+public interface BeanContextChildComponentProxy {
+
+ /**
+ * @com.intel.drl.spec_ref
+ */
+ public Component getComponent();
+}
Added: incubator/harmony/enhanced/classlib/trunk/modules/regex-beans-math/src/common/javasrc/java/beans/beancontext/BeanContextChildSupport.java
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/classlib/trunk/modules/regex-beans-math/src/common/javasrc/java/beans/beancontext/BeanContextChildSupport.java?rev=387239&view=auto
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/regex-beans-math/src/common/javasrc/java/beans/beancontext/BeanContextChildSupport.java (added)
+++ incubator/harmony/enhanced/classlib/trunk/modules/regex-beans-math/src/common/javasrc/java/beans/beancontext/BeanContextChildSupport.java Mon Mar 20 08:31:09 2006
@@ -0,0 +1,279 @@
+/*
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/**
+ * @author Sergei A. Krivenko
+ * @version $Revision: 1.7.4.3 $
+ */
+package java.beans.beancontext;
+
+import java.beans.PropertyChangeEvent;
+import java.beans.PropertyChangeListener;
+import java.beans.PropertyChangeSupport;
+import java.beans.PropertyVetoException;
+import java.beans.VetoableChangeListener;
+import java.beans.VetoableChangeSupport;
+
+import java.io.IOException;
+import java.io.ObjectInputStream;
+import java.io.ObjectOutputStream;
+import java.io.Serializable;
+
+/**
+ * @author Sergei A. Krivenko
+ * @version $Revision: 1.7.4.3 $
+ */
+
+public class BeanContextChildSupport
+ implements BeanContextChild, BeanContextServicesListener, Serializable {
+
+ private static final long serialVersionUID = 6328947014421475877L;
+ static final String BEAN_CONTEXT = "beanContext";
+
+ /**
+ *
+ */
+ protected transient BeanContext beanContext;
+
+ /**
+ * @serial
+ */
+ public BeanContextChild beanContextChildPeer;
+
+ /**
+ * @serial
+ */
+ protected PropertyChangeSupport pcSupport;
+
+ /**
+ *
+ */
+ protected transient boolean rejectedSetBCOnce;
+
+ /**
+ * @serial
+ */
+ protected VetoableChangeSupport vcSupport;
+
+ /**
+ *
+ */
+ public BeanContextChildSupport() {
+
+ // This class implements the JavaBean component itself
+ this(null);
+ }
+
+ /**
+ * @com.intel.drl.spec_ref
+ */
+ public BeanContextChildSupport(BeanContextChild bcc) {
+
+ // If 'bcc' parameter is not null the JavaBean component itself
+ // implements BeanContextChild
+ this.beanContextChildPeer = (bcc == null ? this : bcc);
+
+ // Initialize necessary fileds for later use
+ pcSupport = new PropertyChangeSupport(this.beanContextChildPeer);
+ vcSupport = new VetoableChangeSupport(this.beanContextChildPeer);
+ this.rejectedSetBCOnce = false;
+ }
+
+ /**
+ * @com.intel.drl.spec_ref
+ */
+ public void addPropertyChangeListener(String name,
+ PropertyChangeListener pcl) {
+
+ // Do nothing if name or listener is null
+ if ((name == null) || (pcl == null)) {
+ return;
+ }
+
+ this.pcSupport.addPropertyChangeListener(name, pcl);
+ }
+
+ /**
+ * @com.intel.drl.spec_ref
+ */
+ public void addVetoableChangeListener(String name,
+ VetoableChangeListener vcl) {
+
+ // Do nothing if name or listener is null
+ if ((name == null) || (vcl == null)) {
+ return;
+ }
+
+ this.vcSupport.addVetoableChangeListener(name, vcl);
+ }
+
+ /**
+ * @com.intel.drl.spec_ref
+ */
+ public void firePropertyChange(String name, Object oldValue,
+ Object newValue) {
+
+ this.pcSupport.firePropertyChange(name, oldValue, newValue);
+ }
+
+ /**
+ * @com.intel.drl.spec_ref
+ */
+ public void fireVetoableChange(String name, Object oldValue,
+ Object newValue) throws PropertyVetoException {
+
+ this.vcSupport.fireVetoableChange(name, oldValue, newValue);
+ }
+
+ /**
+ * @com.intel.drl.spec_ref
+ */
+ public synchronized BeanContext getBeanContext() {
+ return this.beanContext;
+ }
+
+ /**
+ * @com.intel.drl.spec_ref
+ */
+ public BeanContextChild getBeanContextChildPeer() {
+ return this.beanContextChildPeer;
+ }
+
+ /**
+ * @com.intel.drl.spec_ref
+ */
+ protected void initializeBeanContextResources() {}
+
+ /**
+ * @com.intel.drl.spec_ref
+ */
+ public boolean isDelegated() {
+ return (!this.beanContextChildPeer.equals(this));
+ }
+
+ /**
+ * @com.intel.drl.spec_ref
+ */
+ private void readObject(ObjectInputStream ois)
+ throws IOException, ClassNotFoundException {
+
+ ois.defaultReadObject();
+ }
+
+ /**
+ * @com.intel.drl.spec_ref
+ */
+ protected void releaseBeanContextResources() {}
+
+ /**
+ * @com.intel.drl.spec_ref
+ */
+ public void removePropertyChangeListener(String name,
+ PropertyChangeListener pcl) {
+
+ this.pcSupport.removePropertyChangeListener(name, pcl);
+ }
+
+ /**
+ * @com.intel.drl.spec_ref
+ */
+ public void removeVetoableChangeListener(String name,
+ VetoableChangeListener vcl) {
+
+ this.vcSupport.removeVetoableChangeListener(name, vcl);
+ }
+
+ /**
+ * @com.intel.drl.spec_ref
+ */
+ public void serviceAvailable(BeanContextServiceAvailableEvent bcsae) {
+
+ BeanContextServicesListener l =
+ (BeanContextServicesListener) beanContextChildPeer;
+ l.serviceAvailable(bcsae);
+ }
+
+ /**
+ * @com.intel.drl.spec_ref
+ */
+ public void serviceRevoked(BeanContextServiceRevokedEvent bcsre) {
+
+ BeanContextServicesListener l =
+ (BeanContextServicesListener) beanContextChildPeer;
+ l.serviceRevoked(bcsre);
+ }
+
+ /**
+ * @com.intel.drl.spec_ref
+ */
+ public synchronized void setBeanContext(BeanContext bc)
+ throws PropertyVetoException {
+
+ // Do nothing if the old and new values are uqual
+ if ((this.beanContext == null) && (bc == null)) {
+ return;
+ }
+
+ if ((this.beanContext != null) && this.beanContext.equals(bc)) {
+ return;
+ }
+
+ releaseBeanContextResources();
+
+ // Children are not allowed to repeatedly veto this operation.
+ // So, we set rejectedSetBCOnce flag to true if veto occurs
+ // and never veto the change again
+ if (!this.rejectedSetBCOnce) {
+
+ // Validate the new BeanContext value and throw
+ // PropertyVetoException if it was not successful
+ if (!validatePendingSetBeanContext(bc)) {
+ this.rejectedSetBCOnce = true;
+ fireVetoableChange(BEAN_CONTEXT, this.beanContext, bc);
+
+ throw new PropertyVetoException(
+ "The new BeanContext can not be set",
+ new PropertyChangeEvent(this.beanContextChildPeer,
+ BEAN_CONTEXT,
+ this.beanContext,
+ bc));
+ }
+ else {
+ this.rejectedSetBCOnce = false;
+ }
+
+ // We have to notify all listeners about "beanContext"
+ // property change
+ firePropertyChange(BEAN_CONTEXT, this.beanContext, bc);
+ this.beanContext = bc;
+ initializeBeanContextResources();
+ }
+ }
+
+ /**
+ * @com.intel.drl.spec_ref
+ */
+ public boolean validatePendingSetBeanContext(BeanContext newValue) {
+ return true;
+ }
+
+ /**
+ * @com.intel.drl.spec_ref
+ */
+ private void writeObject(ObjectOutputStream oos) throws IOException {
+ oos.defaultWriteObject();
+ }
+}
Added: incubator/harmony/enhanced/classlib/trunk/modules/regex-beans-math/src/common/javasrc/java/beans/beancontext/BeanContextContainerProxy.java
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/classlib/trunk/modules/regex-beans-math/src/common/javasrc/java/beans/beancontext/BeanContextContainerProxy.java?rev=387239&view=auto
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/regex-beans-math/src/common/javasrc/java/beans/beancontext/BeanContextContainerProxy.java (added)
+++ incubator/harmony/enhanced/classlib/trunk/modules/regex-beans-math/src/common/javasrc/java/beans/beancontext/BeanContextContainerProxy.java Mon Mar 20 08:31:09 2006
@@ -0,0 +1,36 @@
+/*
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/**
+ * @author Sergei A. Krivenko
+ * @version $Revision: 1.2.4.3 $
+ */
+package java.beans.beancontext;
+
+import java.awt.Container;
+
+/**
+ * @author Sergei A. Krivenko
+ * @version $Revision: 1.2.4.3 $
+ */
+
+public interface BeanContextContainerProxy {
+
+ /**
+ * @com.intel.drl.spec_ref
+ */
+ public Container getContainer();
+}
Added: incubator/harmony/enhanced/classlib/trunk/modules/regex-beans-math/src/common/javasrc/java/beans/beancontext/BeanContextEvent.java
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/classlib/trunk/modules/regex-beans-math/src/common/javasrc/java/beans/beancontext/BeanContextEvent.java?rev=387239&view=auto
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/regex-beans-math/src/common/javasrc/java/beans/beancontext/BeanContextEvent.java (added)
+++ incubator/harmony/enhanced/classlib/trunk/modules/regex-beans-math/src/common/javasrc/java/beans/beancontext/BeanContextEvent.java Mon Mar 20 08:31:09 2006
@@ -0,0 +1,71 @@
+/*
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/**
+ * @author Sergei A. Krivenko
+ * @version $Revision: 1.4.4.3 $
+ */
+package java.beans.beancontext;
+
+import java.util.EventObject;
+
+/**
+ * @author Sergei A. Krivenko
+ * @version $Revision: 1.4.4.3 $
+ */
+
+public abstract class BeanContextEvent extends EventObject {
+
+ /**
+ * @serial
+ */
+ protected BeanContext propagatedFrom;
+
+ /**
+ * @com.intel.drl.spec_ref
+ */
+ protected BeanContextEvent(BeanContext bc) {
+ super(bc);
+ }
+
+ /**
+ * @com.intel.drl.spec_ref
+ */
+ public BeanContext getBeanContext() {
+ return (BeanContext) super.getSource();
+ }
+
+ /**
+ * @com.intel.drl.spec_ref
+ */
+ public synchronized BeanContext getPropagatedFrom() {
+ return this.propagatedFrom;
+ }
+
+ /**
+ * @com.intel.drl.spec_ref
+ */
+ public synchronized boolean isPropagated() {
+ return (this.propagatedFrom != null);
+ }
+
+ /**
+ * @com.intel.drl.spec_ref
+ */
+ public synchronized void setPropagatedFrom(BeanContext bc) {
+ this.propagatedFrom = bc;
+ }
+}