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 [4/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/Introspector.java
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/classlib/trunk/modules/regex-beans-math/src/common/javasrc/java/beans/Introspector.java?rev=387239&view=auto
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/regex-beans-math/src/common/javasrc/java/beans/Introspector.java (added)
+++ incubator/harmony/enhanced/classlib/trunk/modules/regex-beans-math/src/common/javasrc/java/beans/Introspector.java Mon Mar 20 08:31:09 2006
@@ -0,0 +1,1066 @@
+/*
+ *  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.23.6.3 $
+ */
+package java.beans;
+
+import java.awt.Image;
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.Comparator;
+import java.util.HashMap;
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.Vector;
+import java.lang.reflect.Method;
+import java.lang.reflect.Modifier;
+
+/**
+ * @author Maxim V. Berkultsev
+ * @version $Revision: 1.23.6.3 $
+ */
+
+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;
+    
+    private Introspector() {}
+
+    /**
+     * @com.intel.drl.spec_ref
+     */
+    public static String decapitalize(String name) {
+        if((name != null) && (name.length() > 0)) {
+            // first two letters are capital
+            if((name.length() > 1) && name.substring(0,2).equals(
+                    name.substring(0,2).toUpperCase())) {
+                return name;
+            }
+            String result = name.substring(0,1).toLowerCase();
+            if(name.length() > 1) {
+                result += name.substring(1);
+            }
+            return result;
+           }
+        return name;
+    }
+
+    /**
+     * @com.intel.drl.spec_ref
+     */
+    public static BeanInfo getBeanInfo(Class beanClass, int flags)
+        throws IntrospectionException 
+    {
+        BeanInfo result = null;
+        if (flags == USE_ALL_BEANINFO) {
+            result = getBeanInfo(beanClass, null, false, false);    
+        } else if (flags == IGNORE_IMMEDIATE_BEANINFO) {
+            result = getBeanInfo(beanClass, null, true, false);    
+        } else if (flags == IGNORE_ALL_BEANINFO) {
+            result = getBeanInfo(beanClass, null, true, true);    
+        }
+        return result;
+    }
+
+    /**
+     * @com.intel.drl.spec_ref
+     */
+    public static BeanInfo getBeanInfo(Class beanClass)
+            throws IntrospectionException {
+        return getBeanInfo(beanClass, null, false, false);    
+    }
+    
+    /**
+     * @com.intel.drl.spec_ref
+     */
+    public static BeanInfo getBeanInfo(Class beanClass, Class stopClass)
+       throws IntrospectionException
+    {
+        return getBeanInfo(beanClass, stopClass, false, false);
+    }
+
+    /**
+     * @com.intel.drl.spec_ref
+     */
+    public static synchronized void setBeanInfoSearchPath(String[] searchPath) {
+        if (searchPath != null) {
+            SecurityManager sm = System.getSecurityManager();
+            if (sm != null) {
+                sm.checkPropertiesAccess();
+            }
+            path = searchPath;
+        }
+    }
+
+    /**
+     * @com.intel.drl.spec_ref
+     */
+    public static synchronized String[] getBeanInfoSearchPath() {
+        return path;
+    }
+
+    /**
+     * @com.intel.drl.spec_ref
+     */
+    public static void flushFromCaches(Class clz) {
+        removeBeanInfoClassFromCache(clz);
+    }
+
+    /**
+     * @com.intel.drl.spec_ref
+     */
+    public static void flushCaches() {
+        removeAllBeanInfoClassesFromCache();
+    }
+
+    // private methods
+
+    private static BeanInfoWrapper getBeanInfo(Class beanClass, Class stopClass,
+        boolean ignoreBeanClassBeanInfo, boolean ignoreSuperClassBeanInfo)
+    {
+        if (beanClass == null) {
+            return null;
+        }
+
+        BeanInfoWrapper beanInfoWrapper = findBeanInfoClassInCache(beanClass,
+                stopClass, ignoreBeanClassBeanInfo, ignoreSuperClassBeanInfo);
+
+        if (beanInfoWrapper != null) {
+            return beanInfoWrapper;
+        }
+
+        // find bean info as a separate class
+        
+        BeanInfo beanInfo = null;
+        if (!ignoreBeanClassBeanInfo) {
+            try {
+                Class beanInfoClass = findBeanInfoClass(beanClass);
+                if(beanInfoClass != null) {
+                    beanInfo = (BeanInfo) beanInfoClass.newInstance();
+                }
+            } catch (Exception e) {
+            }
+        }
+        
+        //...
+        
+        // generate bean info automatically
+        
+        BeanInfoImpl beanInfoImpl = new BeanInfoImpl(beanClass);
+        
+        //...
+        
+        BeanInfoWrapper wrapper = new BeanInfoWrapper(beanInfo, beanInfoImpl);
+    
+        Class parent = beanClass.getSuperclass();
+        if ((parent != null) && (parent != stopClass)) {
+            BeanInfoWrapper parentBeanInfo = getBeanInfo(parent, stopClass,
+                ignoreSuperClassBeanInfo, ignoreSuperClassBeanInfo);
+            
+            wrapper.merge(parentBeanInfo);
+        }
+        
+        //...
+        
+        storeBeanInfoClassInCache(wrapper, beanClass, stopClass,
+            ignoreBeanClassBeanInfo, ignoreSuperClassBeanInfo);
+        
+        return wrapper;
+    }
+
+    private static Class findBeanInfoClass(Class beanClass) {
+        Object result = null;
+
+        String beanClassName = beanClass.getName();
+        int idx = beanClassName.lastIndexOf(".");
+        String shortBeanInfoClassName = beanClassName.substring(idx + 1,
+            beanClassName.length()) + "BeanInfo";
+        String fullBeanInfoClassName = beanClassName + "BeanInfo";
+
+        Class beanInfoClass = null;
+        try {
+            beanInfoClass = Class.forName(
+                fullBeanInfoClassName, true, beanClass.getClassLoader());
+            
+        } catch (ClassNotFoundException cnfe) {
+            for (int i = 0; i < path.length; ++i) {
+                try {
+                    fullBeanInfoClassName = path[i] + "."
+                            + shortBeanInfoClassName;
+                    beanInfoClass = Class.forName(fullBeanInfoClassName, true,
+                            beanClass.getClassLoader());
+                    break;
+                } catch (ClassNotFoundException cnfe2) {
+                }
+            }
+        }
+        
+        return beanInfoClass;
+    }
+
+    private static BeanInfoWrapper findBeanInfoClassInCache(
+            Class beanClass,
+            Class stopClass,
+            boolean ignoreBeanClassBeanInfo,
+            boolean ignoreSuperClassBeanInfo) {
+        BeanInfoWrapper result = null;
+        ArrayList beanInfoDatas = (ArrayList) beanInfos.get(
+                beanClass.getName());
+        if (beanInfoDatas != null) {
+            Iterator iterator = beanInfoDatas.iterator();
+            while(iterator.hasNext()) {
+                BeanInfoData beanInfoData = (BeanInfoData) iterator.next();
+                if ((beanInfoData.getStopClass() == stopClass) &&
+                    (beanInfoData.getIgnoreBeanClassBeanInfo()
+                            ==  ignoreBeanClassBeanInfo)
+                    && (beanInfoData.getIgnoreSuperClassBeanInfo()
+                            ==  ignoreSuperClassBeanInfo))
+                {
+                    result = beanInfoData.getBeanInfoWrapper();
+                }
+                if (result != null) break;
+            }
+        }
+        return result;
+    }
+    
+    private static void storeBeanInfoClassInCache(
+            BeanInfoWrapper beanInfoWrapper,
+            Class beanClass,
+            Class stopClass,
+            boolean ignoreBeanClassBeanInfo,
+            boolean ignoreSuperClassBeanInfo) {
+        ArrayList beanInfoDatas = (ArrayList) beanInfos.get(
+                beanClass.getName());
+        if(beanInfoDatas == null) {
+            beanInfoDatas = new ArrayList();
+            beanInfos.put(beanClass.getName(), beanInfoDatas);
+        }
+        beanInfoDatas.add(new BeanInfoData(stopClass, ignoreBeanClassBeanInfo,
+            ignoreSuperClassBeanInfo, beanInfoWrapper));
+    }
+
+    private static void removeBeanInfoClassFromCache(Class beanClass) {
+        beanInfos.remove(beanClass.getName());
+    }
+
+    private static void removeAllBeanInfoClassesFromCache() {
+        beanInfos.clear();
+    }
+
+    // private fields
+
+    private static String[] path = {"sun.beans.infos"};
+    private static HashMap beanInfos = new HashMap();
+
+}
+
+class BeanInfoData {
+
+    private Class stopClass;
+    private boolean ignoreBeanClassBeanInfo;
+    private boolean ignoreSuperClassBeanInfo;
+    private BeanInfoWrapper beanInfoWrapper;
+
+    public BeanInfoData(BeanInfoWrapper beanInfo) {
+        this.stopClass = null;
+        this.ignoreBeanClassBeanInfo = false;
+        this.ignoreSuperClassBeanInfo = false;
+        this.beanInfoWrapper = beanInfo;
+    }
+
+    public BeanInfoData(Class stopClass, boolean ignoreBeanClassBeanInfo,
+        boolean ignoreSuperClassBeanInfo, BeanInfoWrapper beanInfoWrapper)
+    {
+        this.stopClass = stopClass;
+        this.ignoreBeanClassBeanInfo = ignoreBeanClassBeanInfo;
+        this.ignoreSuperClassBeanInfo = ignoreSuperClassBeanInfo;
+        this.beanInfoWrapper = beanInfoWrapper;
+    }
+
+    public Class getStopClass() {
+        return stopClass;
+    }
+
+    public boolean getIgnoreBeanClassBeanInfo() {
+        return ignoreBeanClassBeanInfo;
+    }
+
+    public boolean getIgnoreSuperClassBeanInfo() {
+        return ignoreSuperClassBeanInfo;
+    }
+
+    public BeanInfoWrapper getBeanInfoWrapper() {
+        return beanInfoWrapper;
+    }
+}
+
+class BeanInfoImpl implements BeanInfo {
+
+    private static int MT_OTHER = 0;
+    private static int MT_SETTER = 1;
+    private static int MT_GETTER = 2;
+    private static int MT_BOOLEAN_GETTER = 3;
+    private static int MT_INDEXED_SETTER = 4;
+    private static int MT_INDEXED_GETTER = 5;
+
+    public BeanInfoImpl(Class beanClass) {
+        this.beanClass = beanClass;
+    }
+
+    public PropertyDescriptor[] getPropertyDescriptors() {
+        if (propertyDescriptors == null) {
+            HashMap result = new HashMap();
+            
+            if (beanClass != null) {
+                ArrayList beanClassMethodsArrayList = getPublicMethods(
+                        beanClass);
+                
+                ArrayList setters = new ArrayList();
+                ArrayList getters = new ArrayList();
+                ArrayList booleanGetters = new ArrayList();
+                ArrayList indexedSetters = new ArrayList();
+                ArrayList indexedGetters = new ArrayList();
+                
+                Iterator iterator = beanClassMethodsArrayList.iterator();
+                while (iterator.hasNext()) {
+                    Method method = (Method) iterator.next();
+                    
+                    int methodType = getMethodType(method);
+                    if (methodType == MT_SETTER) {
+                        setters.add(method);
+                    } else if (methodType == MT_GETTER) {
+                        getters.add(method);
+                    } else if (methodType == MT_BOOLEAN_GETTER) {
+                        booleanGetters.add(method);
+                    } else if (methodType == MT_INDEXED_SETTER) {
+                        indexedSetters.add(method);
+                    } else if (methodType == MT_INDEXED_GETTER) {
+                        indexedGetters.add(method);
+                    }
+                }
+                try {
+                    addIndexedPropertyDescriptorsFromMethodList(result,
+                            indexedGetters, false);
+                    addIndexedPropertyDescriptorsFromMethodList(result,
+                            indexedSetters, true);
+                    addPropertyDescriptorsFromMethodList(result, booleanGetters,
+                            false);
+                    addPropertyDescriptorsFromMethodList(result, setters, true);
+                    addPropertyDescriptorsFromMethodList(result, getters, true);
+                } catch (Exception e) {
+                }
+                
+                Object[] values = result.values().toArray();
+                propertyDescriptors = new PropertyDescriptor[values.length];
+                for(int k = 0; k < propertyDescriptors.length; ++k) {
+                    propertyDescriptors[k] = (PropertyDescriptor) values[k];
+                }
+            }
+        }
+        
+        return propertyDescriptors;
+    }
+
+    public MethodDescriptor[] getMethodDescriptors() {
+        if(methodDescriptors == null) {
+            ArrayList result = new ArrayList();
+            ArrayList beanClassMethodsArrayList = getPublicMethods(beanClass);
+            
+            Iterator iterator = beanClassMethodsArrayList.iterator();
+            while (iterator.hasNext()) {
+                Method method = (Method) iterator.next();
+                result.add(new MethodDescriptor(method));
+            }
+            
+            methodDescriptors = new MethodDescriptor[result.size()];
+            for(int i = 0; i < methodDescriptors.length; ++i) {
+                methodDescriptors[i] = (MethodDescriptor) result.get(i);
+            }
+            
+        }
+        
+        return methodDescriptors;
+    }
+
+    public EventSetDescriptor[] getEventSetDescriptors() {
+        if(eventSetDescriptors == null) {
+            HashMap result = new HashMap();
+            ArrayList beanClassMethodsArrayList = getPublicMethods(beanClass);
+            
+            Iterator iterator = beanClassMethodsArrayList.iterator();
+            while(iterator.hasNext()) {
+                Method method = (Method) iterator.next();
+                String methodName = method.getName();
+                
+                String listenerName = null;
+                if(methodName.endsWith("Listener")) {
+                    listenerName = methodName.substring(0,
+                            methodName.lastIndexOf("Listener"));
+                    
+                    if(methodName.startsWith("add")) {
+                        listenerName = listenerName.substring(3);
+                    } else if(methodName.startsWith("remove")) {
+                        listenerName = listenerName.substring(6);
+                    } else {
+                        continue;
+                    }
+                    
+                    if(result.get(listenerName) == null) {
+                        Class[] parameterTypes = method.getParameterTypes();
+                        
+                        if(parameterTypes.length == 1) {
+                            Class listenerType = parameterTypes[0];
+                            
+                            // full and short names of classes
+                            String listenerTypeName = listenerType.getName();
+
+                            // check if the listener name extracted from param name and
+                            // listener name extracted from registration method are the same
+                            String listenerNameFromParam =
+                                listenerTypeName.substring(
+                                        listenerTypeName.lastIndexOf(".") + 1);
+                            
+                            String listenerNameFromMethod = listenerName
+                                    + "Listener";
+                            if(!listenerNameFromParam.equals(
+                                    listenerNameFromMethod)) {
+                                continue;
+                            }
+                            
+                            String eventTypeName = listenerTypeName.substring(0,
+                                    listenerTypeName.lastIndexOf(".") + 1)
+                                    + listenerName + "Event";
+                            
+                            // classes generated from classes names
+                            Class eventType = null;
+                            try {
+                                eventType = Class.forName(eventTypeName, true,
+                                        beanClass.getClassLoader());
+                            } catch (ClassNotFoundException cnfe) {
+                                System.out.println("Event type with name "
+                                        + eventTypeName + " is not found.");
+                            } finally {
+                                if(eventType == null) {
+                                    continue;
+                                }
+                            }
+                            
+                            Method[] methods = listenerType.getMethods();
+                            Vector listenerMethodsVec = new Vector();
+                            for(int i = 0; i < methods.length; ++i) {
+                                Class[] listenerMethodParams =
+                                    methods[i].getParameterTypes();
+                                if(listenerMethodParams.length == 1
+                                        && listenerMethodParams[0] == eventType) {
+                                    listenerMethodsVec.add(methods[i]);
+                                }
+                            }
+                            
+                            Method[] listenerMethods =
+                                    new Method[listenerMethodsVec.size()];
+                            Iterator iter = listenerMethodsVec.iterator();
+                            int idx2 = 0;
+                            while(iter.hasNext()) {
+                                listenerMethods[idx2] = (Method) iter.next();
+                                idx2++;
+                            }
+                            
+                            Method addListenerMethod = null;
+                            String addListenerMethodName = "add" + listenerName
+                                    + "Listener";
+                            try {
+                                addListenerMethod = beanClass.getMethod(
+                                    addListenerMethodName,
+                                    new Class[] { listenerType });
+                            } catch (NoSuchMethodException nsme) {
+                                // no adder found
+                                continue;
+                            }
+                            
+                            Method removeListenerMethod = null;
+                            String removeListenerMethodName = "remove"
+                                    + listenerName + "Listener";
+                            try {
+                                removeListenerMethod = beanClass.getMethod(
+                                    removeListenerMethodName,
+                                    new Class[] { listenerType });
+                            } catch (NoSuchMethodException nsme) {
+                                // no remover found
+                                continue;
+                            }
+                            
+                            Method getListenerMethod = null;
+                            String getListenerMethodName = "get" + listenerName
+                                    + "Listeners";
+                            try {
+                                getListenerMethod = beanClass.getMethod(
+                                    getListenerMethodName, new Class[] {});
+                            } catch (NoSuchMethodException nsme) {
+                                // no action - getter is not a mandatory method in event set descriptor pattern
+                            }
+
+                            try {
+                                listenerName = Introspector.decapitalize(
+                                        listenerName);
+                                EventSetDescriptor esd = new EventSetDescriptor(
+                                        listenerName,
+                                        listenerType,
+                                        listenerMethods,
+                                        addListenerMethod,
+                                        removeListenerMethod,
+                                        getListenerMethod);
+                                result.put(listenerName, esd);
+                            } catch (IntrospectionException ie) {
+                                System.out.println(
+                                        "Cannot generate event set descriptor "
+                                        + "for name" + listenerName + ".");
+                            }
+                            
+                        }
+                    }
+                }
+            }
+            
+            String[] eventSetDescriptorNames =
+                    new String[result.keySet().size()];
+            Iterator i = result.keySet().iterator();
+            int idx = 0;
+            while(i.hasNext()) {
+                eventSetDescriptorNames[idx++] =
+                    ((EventSetDescriptor) result.get(
+                            (String) i.next())).getName();
+            }
+            
+            Arrays.sort(eventSetDescriptorNames);
+
+            eventSetDescriptors =
+                    new EventSetDescriptor[eventSetDescriptorNames.length];
+            for(int j = 0; j < eventSetDescriptors.length; ++j) {
+                eventSetDescriptors[j] = (EventSetDescriptor) result.get(
+                        eventSetDescriptorNames[j]);
+            }
+            
+        }
+        return eventSetDescriptors;
+    }
+
+    public BeanInfo[] getAdditionalBeanInfo() {
+        // no info is obtained thru automatic introspection
+        return null;
+    }
+
+    public BeanDescriptor getBeanDescriptor() {
+        return new BeanDescriptor(beanClass, null);
+    }
+
+    public Image getIcon(int iconKind) {
+        // no info is obtained thru automatic introspection
+        return null;
+    }
+
+    public int getDefaultPropertyIndex() {
+        return defaultPropertyIndex;
+    }
+
+    public int getDefaultEventIndex() {
+        return defaultEventIndex;
+    }
+
+    private static int getMethodType(Method method) {
+        String name = method.getName();
+        int result = MT_OTHER;
+        try {
+            int modifiers = method.getModifiers();
+            
+            if(Modifier.isPublic(modifiers) && !Modifier.isStatic(modifiers)) {
+                Class[] parameterTypes = method.getParameterTypes();
+                Class returnType = method.getReturnType();
+
+                if(name.startsWith("get") && (parameterTypes.length == 0)
+                        && (returnType != void.class) && (name.length() > 3)) {
+                    result = MT_GETTER;
+                } else if(name.startsWith("is") && (parameterTypes.length == 0)
+                        && (returnType == boolean.class)
+                        && (name.length() > 2)) {
+                    result = MT_BOOLEAN_GETTER;
+                } else if(name.startsWith("get") && (parameterTypes.length == 1)
+                        && (returnType != void.class)
+                        && (parameterTypes[0] == int.class)
+                        && (name.length() > 3)) {
+                    result = MT_INDEXED_GETTER;
+                } else if(name.startsWith("set") && (parameterTypes.length == 1)
+                        && (returnType == void.class) && (name.length() > 3)) {
+                    result = MT_SETTER;
+                } else if(name.startsWith("set") && (parameterTypes.length == 2)
+                        && (returnType == void.class)
+                        && (parameterTypes[0] == int.class)
+                        && (name.length() > 3)) {
+                    result = MT_INDEXED_SETTER;
+                }
+            }
+        } catch (Exception e) {
+            result = MT_OTHER;
+        }
+        
+        return result;
+    }
+
+    private static String extractPropertyName(String methodName)
+            throws Exception {
+        String result = null;
+        
+        if ( methodName.startsWith("set") || methodName.startsWith("get") ) {
+            result = methodName.substring(3);
+            result = Introspector.decapitalize(result);
+        } else if (methodName.startsWith("is")) {
+            result = methodName.substring(2);
+            result = Introspector.decapitalize(result);
+        }
+        
+        return result;
+    }
+
+    private static ArrayList getPublicMethods(Class theClass) {
+        ArrayList result = new ArrayList();
+
+        Method[] beanClassMethods = theClass.getDeclaredMethods();
+        for (int i = 0; i < beanClassMethods.length; ++i) {
+            if(Modifier.isPublic(beanClassMethods[i].getModifiers())) {
+                result.add(beanClassMethods[i]);
+            }
+        }
+        
+        return result;
+    }
+    
+    private void addPropertyDescriptorsFromMethodList(
+            HashMap hmPropertyDescriptors,
+            ArrayList methods,
+            boolean checkExisting) throws Exception
+    {
+        Iterator iterator = methods.iterator();
+        while(iterator.hasNext()) {
+            Method method = (Method) iterator.next();
+            String methodName = method.getName();
+            String propertyName = extractPropertyName(methodName);
+            if ((!checkExisting) || (checkExisting && (hmPropertyDescriptors.get(propertyName) == null))) {
+                PropertyDescriptor propertyDescriptor = null;
+                try {
+                    propertyDescriptor = new PropertyDescriptor(propertyName, beanClass);
+                    hmPropertyDescriptors.put(propertyName, propertyDescriptor);
+                } catch (IntrospectionException ie) {
+                    System.out.println(ie.getClass() + ": " + ie.getMessage());
+                }
+            }
+        }
+    }
+    
+    private void addIndexedPropertyDescriptorsFromMethodList(
+            HashMap hmPropertyDescriptors,
+            ArrayList methods,
+            boolean checkExisting) throws Exception
+    {
+        Iterator iterator = methods.iterator();
+        while(iterator.hasNext()) {
+            Method method = (Method) iterator.next();
+            String methodName = method.getName();
+            String propertyName = extractPropertyName(methodName);
+            if ((!checkExisting) || (checkExisting
+                    && (hmPropertyDescriptors.get(propertyName) == null))) {
+                IndexedPropertyDescriptor indexedPropertyDescriptor = null;
+                try {
+                    indexedPropertyDescriptor = new IndexedPropertyDescriptor(
+                            propertyName, beanClass);
+                    hmPropertyDescriptors.put(propertyName,
+                            indexedPropertyDescriptor);
+                } catch (IntrospectionException ie) {
+                    System.out.println(ie.getClass() + ": " + ie.getMessage());
+                }
+            }
+        }
+    }
+    
+    private void clear() {
+        propertyDescriptors = null; 
+        methodDescriptors = null;
+        eventSetDescriptors = null;
+        defaultPropertyIndex = -1;
+        defaultEventIndex = -1;
+    }
+
+    private Class beanClass = null;
+    private PropertyDescriptor[] propertyDescriptors = null; 
+    private MethodDescriptor[] methodDescriptors = null;
+    private EventSetDescriptor[] eventSetDescriptors = null;
+    private int defaultPropertyIndex = -1;
+    private int defaultEventIndex = -1;
+    
+}
+
+class BeanInfoWrapper implements BeanInfo {
+    
+    private BeanInfo info;
+    private BeanInfoImpl impl;
+    private BeanInfoWrapper parentBeanInfoWrapper;
+    
+    public BeanInfoWrapper(BeanInfo info, BeanInfoImpl impl) {
+        this.info = info;
+        this.impl = impl;
+    }
+    
+    public PropertyDescriptor[] getPropertyDescriptors() {
+        PropertyDescriptor[] result = null;
+        PropertyDescriptor[] infoResult = null;
+        
+        if(info != null) {
+            infoResult = info.getPropertyDescriptors();
+            
+            BeanInfo[] infos = info.getAdditionalBeanInfo();
+            if(infos != null) {
+                for(int i = 0; i < infos.length; ++i) {
+                    BeanInfo additionalInfo = infos[i];
+                    
+                    if(infoResult == null) {
+                        infoResult = additionalInfo.getPropertyDescriptors();
+                    } else {
+                        infoResult = concatArraysToOneArray(infoResult,
+                                additionalInfo.getPropertyDescriptors());
+                    }
+                }
+            }
+        }
+        
+        if(info == null || infoResult == null) {
+            PropertyDescriptor[] implResult = impl.getPropertyDescriptors();
+            
+            // merge with parent info
+            if(parentBeanInfoWrapper != null) {
+                PropertyDescriptor[] parentResult =
+                        parentBeanInfoWrapper.getPropertyDescriptors();
+                HashMap hm = concatArraysUniqueByName(implResult, parentResult);
+                
+                Collection values = hm.values();
+                
+                result = new PropertyDescriptor[values.size()];
+                int idx = 0;
+                Iterator iterator = values.iterator();
+                while(iterator.hasNext()) {
+                    result[idx++] = (PropertyDescriptor) iterator.next();
+                }
+                
+                Arrays.sort(result, new Comparator() {
+                    public int compare(Object o1, Object o2) {
+                        PropertyDescriptor pd1 = (PropertyDescriptor) o1;
+                        PropertyDescriptor pd2 = (PropertyDescriptor) o2;
+                        return pd1.getName().compareTo(pd2.getName());
+                    }
+                    public boolean equals(Object o) {
+                        return false;
+                    }
+                });
+            } else {
+                result = implResult;
+            }
+        } else {
+            result = infoResult;
+        }
+        
+        return result;
+    }
+
+    public MethodDescriptor[] getMethodDescriptors() {
+        MethodDescriptor[] result = null;
+        MethodDescriptor[] infoResult = null;
+        
+        if(info != null) {
+            infoResult = info.getMethodDescriptors();
+            
+            BeanInfo[] infos = info.getAdditionalBeanInfo();
+            if(infos != null) {
+                for(int i = 0; i < infos.length; ++i) {
+                    BeanInfo additionalInfo = infos[i];
+                    
+                    if(infoResult == null) {
+                        infoResult = additionalInfo.getMethodDescriptors();
+                    } else {
+                        infoResult = concatArraysToOneArray(infoResult,
+                                additionalInfo.getMethodDescriptors());
+                    }
+                }
+            }
+        }
+        
+        if(info == null || infoResult == null) {
+            MethodDescriptor[] implResult = impl.getMethodDescriptors();
+            
+            // merge with parent info
+            if(parentBeanInfoWrapper != null) {
+                MethodDescriptor[] parentResult =
+                        parentBeanInfoWrapper.getMethodDescriptors();
+                result = concatArraysToOneArray(implResult, parentResult);
+            } else {
+                result = implResult;
+            }
+        } else {
+            result = infoResult;
+        }
+
+        if(result != null) {
+            Arrays.sort(result, new Comparator() {
+                public int compare(Object o1, Object o2) {
+                    MethodDescriptor md1 = (MethodDescriptor) o1;
+                    MethodDescriptor md2 = (MethodDescriptor) o2;
+                    return md1.getName().compareTo(md2.getName());
+                }
+                public boolean equals(Object o) {
+                    return false;
+                }
+            });
+        }
+        
+        return result;
+    }
+
+    public EventSetDescriptor[] getEventSetDescriptors() {
+        EventSetDescriptor[] result = null;
+        EventSetDescriptor[] infoResult = null;
+        
+        if(info != null) {
+            infoResult = info.getEventSetDescriptors();
+            
+            BeanInfo[] infos = info.getAdditionalBeanInfo();
+            if(infos != null) {
+                for(int i = 0; i < infos.length; ++i) {
+                    BeanInfo additionalInfo = infos[i];
+                    
+                    if(infoResult == null) {
+                        infoResult = additionalInfo.getEventSetDescriptors();
+                    } else {
+                        infoResult = concatArraysToOneArray(infoResult,
+                                additionalInfo.getEventSetDescriptors());
+                    }
+                }
+            }
+        }
+        
+        if(info == null || infoResult == null) {
+            EventSetDescriptor[] implResult = impl.getEventSetDescriptors();
+            
+            // merge with parent info
+            if(parentBeanInfoWrapper != null) {
+                EventSetDescriptor[] parentResult =
+                        parentBeanInfoWrapper.getEventSetDescriptors();
+                HashMap hm = concatArraysUniqueByName(implResult, parentResult);
+                
+                Collection values = hm.values();
+                
+                result = new EventSetDescriptor[values.size()];
+                int idx = 0;
+                Iterator iterator = values.iterator();
+                while(iterator.hasNext()) {
+                    result[idx++] = (EventSetDescriptor) iterator.next();
+                }
+                
+                Arrays.sort(result, new Comparator() {
+                    public int compare(Object o1, Object o2) {
+                        EventSetDescriptor esd1 = (EventSetDescriptor) o1;
+                        EventSetDescriptor esd2 = (EventSetDescriptor) o2;
+                        return esd1.getName().compareTo(esd2.getName());
+                    }
+                    public boolean equals(Object o) {
+                        return false;
+                    }
+                });
+            } else {
+                result = implResult;
+            }
+        } else {
+            result = infoResult;
+        }
+        
+        return result;
+    }
+
+    public BeanInfo[] getAdditionalBeanInfo() {
+        BeanInfo[] result = null;
+        
+        if(info != null) {
+            result = info.getAdditionalBeanInfo();
+        }
+        
+        return result;
+    }
+
+    public BeanDescriptor getBeanDescriptor() {
+        BeanDescriptor result = null;
+        
+        if(info != null) {
+            result = info.getBeanDescriptor();
+        }
+        
+        if(info == null || result == null) {
+            result = impl.getBeanDescriptor();
+        }
+        
+        return result;
+    }
+
+    public Image getIcon(int iconKind) {
+        Image result = null;
+        
+        if(info != null) {
+            result = info.getIcon(iconKind);
+        }
+        
+        return result;
+    }
+
+    public int getDefaultPropertyIndex() {
+        int result = -1;
+        
+        if(info != null) {
+            result = info.getDefaultPropertyIndex();
+        }
+        
+        if(info == null || result == -1) {
+            result = impl.getDefaultPropertyIndex();
+        }
+        
+        return result;
+    }
+
+    public int getDefaultEventIndex() {
+        int result = -1;
+        
+        if(info != null) {
+            result = info.getDefaultEventIndex();
+        }
+        
+        if(info == null || result == -1) {
+            result = impl.getDefaultEventIndex();
+        }
+        
+        return result;
+    }
+    
+    void merge(BeanInfoWrapper parentBeanInfoWrapper) {
+        this.parentBeanInfoWrapper = parentBeanInfoWrapper;
+    }
+    
+    private static HashMap concatArraysUniqueByName(FeatureDescriptor[] childs,
+            FeatureDescriptor[] parents) {
+        HashMap result = new HashMap();
+        
+        if(childs != null) {
+            for(int i = 0; i < childs.length; ++i) {
+                result.put(childs[i].getName(), childs[i]);
+            }
+        }
+        
+        if(parents != null) {
+            for(int j = 0; j < parents.length; ++j) {
+                if(result.get(parents[j].getName()) == null) {
+                    result.put(parents[j].getName(), parents[j]);
+                }
+            }
+        }
+        
+        return result;
+    }
+    
+    private static PropertyDescriptor[] concatArraysToOneArray(
+            PropertyDescriptor[] childs, PropertyDescriptor[] parents) {
+        if(childs != null || parents != null) {
+            HashMap hm = concatArraysUniqueByName(childs, parents);
+            PropertyDescriptor[] result = new PropertyDescriptor[hm.size()];
+            
+            Iterator iterator = hm.keySet().iterator();
+            int idx = 0;
+            
+            while(iterator.hasNext()) {
+                String name = (String) iterator.next();
+                result[idx++] = (PropertyDescriptor) hm.get(name);
+            }
+            
+            return result;
+        } else {
+            return null;
+        }
+    }
+    
+    private static MethodDescriptor[] concatArraysToOneArray(
+            MethodDescriptor[] childs, MethodDescriptor[] parents) {
+        MethodDescriptor[] result = null;
+        
+        if(childs != null || parents != null) {
+            int resultLength = 0;
+            
+            if(childs != null) {
+                resultLength = childs.length; 
+            }
+            
+            if(parents != null) {
+                resultLength += parents.length;
+            }
+            
+            result = new MethodDescriptor[resultLength];
+
+            if(childs != null) {
+                for(int i = 0; i < childs.length; ++i) {
+                    result[i] = childs[i];
+                }
+            }
+            
+            if(parents != null) {
+                int shift = (childs == null) ? 0 : childs.length; 
+                for(int i = 0; i < parents.length; ++i) {
+                    result[shift + i] = parents[i];
+                }
+            }
+            
+        }
+        
+        return result;
+    }
+    
+    private static EventSetDescriptor[] concatArraysToOneArray(
+            EventSetDescriptor[] childs, EventSetDescriptor[] parents) {
+        if(childs != null || parents != null) {
+            HashMap hm = concatArraysUniqueByName(childs, parents);
+            EventSetDescriptor[] result = new EventSetDescriptor[hm.size()];
+            
+            Iterator iterator = hm.keySet().iterator();
+            int idx = 0;
+            
+            while(iterator.hasNext()) {
+                String name = (String) iterator.next();
+                result[idx++] = (EventSetDescriptor) hm.get(name);
+            }
+            
+            return result;
+        } else {
+            return null;
+        }
+    }
+}

Added: incubator/harmony/enhanced/classlib/trunk/modules/regex-beans-math/src/common/javasrc/java/beans/MethodDescriptor.java
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/classlib/trunk/modules/regex-beans-math/src/common/javasrc/java/beans/MethodDescriptor.java?rev=387239&view=auto
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/regex-beans-math/src/common/javasrc/java/beans/MethodDescriptor.java (added)
+++ incubator/harmony/enhanced/classlib/trunk/modules/regex-beans-math/src/common/javasrc/java/beans/MethodDescriptor.java Mon Mar 20 08:31:09 2006
@@ -0,0 +1,77 @@
+/*
+ *  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.5.4.3 $
+ */
+package java.beans;
+
+import java.lang.reflect.Method;
+
+/**
+ * @author Maxim V. Berkultsev
+ * @version $Revision: 1.5.4.3 $
+ */
+
+public class MethodDescriptor extends FeatureDescriptor {
+    
+    private Method method = null;
+    private ParameterDescriptor[] parameterDescriptors = {};
+
+    /**
+     * @com.intel.drl.spec_ref
+     */
+    public MethodDescriptor(Method method,
+            ParameterDescriptor[] parameterDescriptors) {
+        super();
+        
+        this.method = method;
+        this.parameterDescriptors = parameterDescriptors;
+        
+        if(method != null) {
+            setName(method.getName());
+            setDisplayName(method.getName());
+        }
+    }
+
+    /**
+     * @com.intel.drl.spec_ref
+     */
+    public MethodDescriptor(Method method) {
+        super();
+        
+        this.method = method;
+        if(method != null) {
+            setName(method.getName());
+            setDisplayName(method.getName());
+        }
+    }
+
+    /**
+     * @com.intel.drl.spec_ref
+     */
+    public Method getMethod() {
+        return method;
+    }
+
+    /**
+     * @com.intel.drl.spec_ref
+     */
+    public ParameterDescriptor[] getParameterDescriptors() {
+        return parameterDescriptors;
+    }
+}

Added: incubator/harmony/enhanced/classlib/trunk/modules/regex-beans-math/src/common/javasrc/java/beans/ParameterDescriptor.java
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/classlib/trunk/modules/regex-beans-math/src/common/javasrc/java/beans/ParameterDescriptor.java?rev=387239&view=auto
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/regex-beans-math/src/common/javasrc/java/beans/ParameterDescriptor.java (added)
+++ incubator/harmony/enhanced/classlib/trunk/modules/regex-beans-math/src/common/javasrc/java/beans/ParameterDescriptor.java Mon Mar 20 08:31:09 2006
@@ -0,0 +1,35 @@
+/*
+ *  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 ParameterDescriptor extends FeatureDescriptor {
+
+    /**
+     * @com.intel.drl.spec_ref
+     */
+    public ParameterDescriptor() {
+    }
+}

Added: incubator/harmony/enhanced/classlib/trunk/modules/regex-beans-math/src/common/javasrc/java/beans/PersistenceDelegate.java
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/classlib/trunk/modules/regex-beans-math/src/common/javasrc/java/beans/PersistenceDelegate.java?rev=387239&view=auto
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/regex-beans-math/src/common/javasrc/java/beans/PersistenceDelegate.java (added)
+++ incubator/harmony/enhanced/classlib/trunk/modules/regex-beans-math/src/common/javasrc/java/beans/PersistenceDelegate.java Mon Mar 20 08:31:09 2006
@@ -0,0 +1,98 @@
+/*
+ *  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.10.6.3 $
+ */
+package java.beans;
+
+/**
+ * @author Maxim V. Berkultsev
+ * @version $Revision: 1.10.6.3 $
+ */
+
+public abstract class PersistenceDelegate {
+
+    /**
+     * @com.intel.drl.spec_ref
+     */
+    public PersistenceDelegate() {
+    }
+    
+    /**
+     * @com.intel.drl.spec_ref
+     */
+    protected void initialize(
+            Class type, Object oldInstance, Object newInstance, Encoder out) {
+        if((out != null) && (type != null)) {
+            PersistenceDelegate pd = out.getPersistenceDelegate(
+                    type.getSuperclass());
+            if(pd != null) {
+                pd.initialize(type, oldInstance, newInstance, out);
+            }
+        }
+    }
+
+    /**
+     * @com.intel.drl.spec_ref
+     */
+    protected abstract Expression instantiate(Object oldInstance, Encoder out);
+
+    /**
+     * @com.intel.drl.spec_ref
+     */
+    protected boolean mutatesTo(Object oldInstance, Object newInstance) {
+        boolean bothInstancesAreNull = (oldInstance == null)
+                && (newInstance == null);
+        
+        if(bothInstancesAreNull) {
+            return true;
+        } else {
+            return (oldInstance != null) && (newInstance != null) ? 
+                oldInstance.getClass() == newInstance.getClass() : false;
+        }
+    }
+
+    /**
+     * @com.intel.drl.spec_ref
+     */
+    public void writeObject(Object oldInstance, Encoder out) {
+        Object newInstance = (oldInstance != null) ? out.get(oldInstance)
+                : null;
+        
+       if(mutatesTo(oldInstance, newInstance)) {
+           if(oldInstance != null) {
+               initialize(oldInstance.getClass(), oldInstance, newInstance,
+                       out);
+           } else {
+               out.writeExpression(instantiate(oldInstance, out));
+           }
+       } else {
+           if(newInstance != null) {
+               out.remove(newInstance);
+           }
+           
+           out.writeExpression(instantiate(oldInstance, out));
+           
+           if(oldInstance != null) {
+            newInstance = out.get(oldInstance);
+               initialize(oldInstance.getClass(), oldInstance, newInstance,
+                       out);
+           }
+       }
+    }
+}

Added: incubator/harmony/enhanced/classlib/trunk/modules/regex-beans-math/src/common/javasrc/java/beans/PropertyChangeEvent.java
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/classlib/trunk/modules/regex-beans-math/src/common/javasrc/java/beans/PropertyChangeEvent.java?rev=387239&view=auto
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/regex-beans-math/src/common/javasrc/java/beans/PropertyChangeEvent.java (added)
+++ incubator/harmony/enhanced/classlib/trunk/modules/regex-beans-math/src/common/javasrc/java/beans/PropertyChangeEvent.java Mon Mar 20 08:31:09 2006
@@ -0,0 +1,83 @@
+/*
+ *  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.util.EventObject;
+
+/**
+ * @author Maxim V. Berkultsev
+ * @version $Revision: 1.4.6.3 $
+ */
+
+public class PropertyChangeEvent extends EventObject {
+    
+    String propertyName;
+    Object oldValue;
+    Object newValue;
+    Object propagationId;
+    
+    /**
+     * @com.intel.drl.spec_ref
+     */
+    public PropertyChangeEvent(Object source, String propertyName,
+            Object oldValue, Object newValue) {
+        super(source);
+        
+        this.propertyName = propertyName;
+        this.oldValue = oldValue;
+        this.newValue = newValue;
+    }
+
+    /**
+     * @com.intel.drl.spec_ref
+     */
+    public String getPropertyName() {
+        return propertyName;
+    }
+
+    /**
+     * @com.intel.drl.spec_ref
+     */
+    public void setPropagationId(Object propagationId) {
+        this.propagationId = propagationId;
+    }
+
+    /**
+     * @com.intel.drl.spec_ref
+     */
+    public Object getPropagationId() {
+        return propagationId;
+    }
+
+    /**
+     * @com.intel.drl.spec_ref
+     */
+    public Object getOldValue() {
+        return oldValue;
+    }
+
+    /**
+     * @com.intel.drl.spec_ref
+     */
+    public Object getNewValue() {
+        return newValue;
+    }
+}

Added: incubator/harmony/enhanced/classlib/trunk/modules/regex-beans-math/src/common/javasrc/java/beans/PropertyChangeListener.java
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/classlib/trunk/modules/regex-beans-math/src/common/javasrc/java/beans/PropertyChangeListener.java?rev=387239&view=auto
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/regex-beans-math/src/common/javasrc/java/beans/PropertyChangeListener.java (added)
+++ incubator/harmony/enhanced/classlib/trunk/modules/regex-beans-math/src/common/javasrc/java/beans/PropertyChangeListener.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 Maxim V. Berkultsev
+ * @version $Revision: 1.2.6.3 $
+ */
+package java.beans;
+
+import java.util.EventListener;
+
+/**
+ * @author Maxim V. Berkultsev
+ * @version $Revision: 1.2.6.3 $
+ */
+
+public interface PropertyChangeListener extends EventListener {
+
+    /**
+     * @com.intel.drl.spec_ref
+     */
+    public void propertyChange(PropertyChangeEvent event);
+}

Added: incubator/harmony/enhanced/classlib/trunk/modules/regex-beans-math/src/common/javasrc/java/beans/PropertyChangeListenerProxy.java
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/classlib/trunk/modules/regex-beans-math/src/common/javasrc/java/beans/PropertyChangeListenerProxy.java?rev=387239&view=auto
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/regex-beans-math/src/common/javasrc/java/beans/PropertyChangeListenerProxy.java (added)
+++ incubator/harmony/enhanced/classlib/trunk/modules/regex-beans-math/src/common/javasrc/java/beans/PropertyChangeListenerProxy.java Mon Mar 20 08:31:09 2006
@@ -0,0 +1,61 @@
+/*
+ *  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 PropertyChangeListenerProxy extends EventListenerProxy
+        implements PropertyChangeListener {
+    
+    String propertyName;
+
+    /**
+     * @com.intel.drl.spec_ref
+     */
+    public PropertyChangeListenerProxy(String propertyName,
+            PropertyChangeListener listener) {
+        super(listener);
+        this.propertyName = propertyName;
+    }
+
+    /**
+     * @com.intel.drl.spec_ref
+     */
+    public String getPropertyName() {
+        return propertyName;
+    }
+
+    /**
+     * @com.intel.drl.spec_ref
+     */
+    public void propertyChange(PropertyChangeEvent event) {
+        PropertyChangeListener listener =
+            (PropertyChangeListener) getListener();
+        if (listener != null) {
+            listener.propertyChange(event);
+        }
+    }
+}

Added: incubator/harmony/enhanced/classlib/trunk/modules/regex-beans-math/src/common/javasrc/java/beans/PropertyChangeSupport.java
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/classlib/trunk/modules/regex-beans-math/src/common/javasrc/java/beans/PropertyChangeSupport.java?rev=387239&view=auto
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/regex-beans-math/src/common/javasrc/java/beans/PropertyChangeSupport.java (added)
+++ incubator/harmony/enhanced/classlib/trunk/modules/regex-beans-math/src/common/javasrc/java/beans/PropertyChangeSupport.java Mon Mar 20 08:31:09 2006
@@ -0,0 +1,348 @@
+/*
+ *  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.2.4 $
+ */
+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.13.2.4 $
+ */
+
+public class PropertyChangeSupport implements Serializable {
+    
+    private static final long serialVersionUID = 6401253773779951803l; 
+    
+    private transient Object sourceBean;
+    private transient ArrayList allPropertiesChangeListeners = new ArrayList();
+    private transient HashMap selectedPropertiesChangeListeners = new HashMap();
+
+    // fields for serialization compatibility
+    private Hashtable children;
+    private Object source;
+    private int propertyChangeSupportSerializedDataVersion = 1; 
+
+    /**
+     * @com.intel.drl.spec_ref
+     */
+    public PropertyChangeSupport(Object sourceBean) {
+        this.sourceBean = sourceBean;
+    }
+
+    /**
+     * @com.intel.drl.spec_ref
+     */
+    public void firePropertyChange(
+            String propertyName, Object oldValue, Object newValue) {
+        PropertyChangeEvent event = createPropertyChangeEvent(propertyName,
+                oldValue, newValue);
+        doFirePropertyChange(event);
+    }
+
+    /**
+     * @com.intel.drl.spec_ref
+     */
+    public synchronized void removePropertyChangeListener(
+            String propertyName, PropertyChangeListener listener) {
+        if ( (propertyName != null) && (listener != null) ) {
+            ArrayList listeners =
+                (ArrayList) selectedPropertiesChangeListeners.get(propertyName);
+            
+            if(listeners != null) {
+                listeners.remove(listener);    
+            }
+        }
+    }
+
+    /**
+     * @com.intel.drl.spec_ref
+     */
+    public synchronized void addPropertyChangeListener(
+            String propertyName, PropertyChangeListener listener) {
+        if(propertyName == null) {
+            throw new NullPointerException("propertyName is null");
+        } else if(listener != null) {
+            ArrayList listeners =
+                (ArrayList) selectedPropertiesChangeListeners.get(propertyName);
+            
+            if (listeners == null) {
+                listeners = new ArrayList();
+                selectedPropertiesChangeListeners.put(propertyName, listeners);
+            }
+            
+            listeners.add(listener);
+        }
+    }
+
+    /**
+     * @com.intel.drl.spec_ref
+     */
+    public synchronized PropertyChangeListener[] getPropertyChangeListeners(
+            String propertyName) {
+        ArrayList listeners = null;
+        
+        if(propertyName != null) {
+            listeners = (ArrayList) selectedPropertiesChangeListeners.get(
+                    propertyName);
+        }
+        
+        return (listeners == null) ? new PropertyChangeListener[] {} :
+            getAsPropertyChangeListenerArray(listeners);
+        
+    }
+
+    /**
+     * @com.intel.drl.spec_ref
+     */
+    public void firePropertyChange(
+            String propertyName, boolean oldValue, boolean newValue) {
+        PropertyChangeEvent event = createPropertyChangeEvent(propertyName,
+                oldValue, newValue);
+        doFirePropertyChange(event);
+    }
+
+    /**
+     * @com.intel.drl.spec_ref
+     */
+    public void firePropertyChange(
+            String propertyName, int oldValue, int newValue) {
+        PropertyChangeEvent event = createPropertyChangeEvent(propertyName,
+                oldValue, newValue);
+        doFirePropertyChange(event);
+    }
+
+    /**
+     * @com.intel.drl.spec_ref
+     */
+    public synchronized boolean hasListeners(String propertyName) {
+        boolean result = allPropertiesChangeListeners.size() > 0;
+        if (!result && propertyName != null) {
+            ArrayList listeners =
+                (ArrayList) selectedPropertiesChangeListeners.get(propertyName);
+            if (listeners != null) {
+                result = listeners.size() > 0;
+            }
+        }
+        return result;    
+    }
+
+    /**
+     * @com.intel.drl.spec_ref
+     */
+    public synchronized void removePropertyChangeListener(
+            PropertyChangeListener listener) {
+        if (listener != null) {
+            Iterator iterator = allPropertiesChangeListeners.iterator();
+            while (iterator.hasNext()) {
+                PropertyChangeListener pcl =
+                    (PropertyChangeListener) iterator.next();
+                if (pcl == listener) {
+                    iterator.remove();
+                    break;
+                }
+            }
+        }
+    }
+
+    /**
+     * @com.intel.drl.spec_ref
+     */
+    public synchronized void addPropertyChangeListener(
+            PropertyChangeListener listener) {
+        if (listener != null) {
+            allPropertiesChangeListeners.add(listener);
+        }
+    }
+
+    /**
+     * @com.intel.drl.spec_ref
+     */
+    public synchronized PropertyChangeListener[] getPropertyChangeListeners() {
+        ArrayList result = new ArrayList(allPropertiesChangeListeners);
+        
+        Iterator keysIterator =
+                selectedPropertiesChangeListeners.keySet().iterator();
+        while (keysIterator.hasNext()) {
+            String propertyName = (String) keysIterator.next();
+            
+            ArrayList selectedListeners =
+                (ArrayList) selectedPropertiesChangeListeners.get(propertyName);
+            if(selectedListeners != null) {
+
+                Iterator i = selectedListeners.iterator();
+                while(i.hasNext()) {
+                    PropertyChangeListener listener =
+                        (PropertyChangeListener) i.next();
+                    result.add(new PropertyChangeListenerProxy(propertyName,
+                            listener));
+                }
+                
+            }
+            
+        }
+        
+        return getAsPropertyChangeListenerArray(result);
+    }
+    
+    /**
+     * @com.intel.drl.spec_ref
+     */
+    private void writeObject(ObjectOutputStream oos) throws IOException {
+        ArrayList allSerializedPropertiesChangeListeners = new ArrayList();
+        Iterator i = allPropertiesChangeListeners.iterator();
+        while(i.hasNext()) {
+            PropertyChangeListener pcl = (PropertyChangeListener) i.next();
+            if(pcl instanceof Serializable) {
+                allSerializedPropertiesChangeListeners.add(pcl);
+            }
+        }
+        
+        HashMap selectedSerializedPropertiesChangeListeners = new HashMap();
+        Iterator keyIterator =
+            selectedPropertiesChangeListeners.keySet().iterator();
+        while(keyIterator.hasNext()) {
+            String propertyName = (String) keyIterator.next();
+            ArrayList keyValues =
+                (ArrayList) selectedPropertiesChangeListeners.get(propertyName);
+            if(keyValues != null) {
+                ArrayList serializedPropertiesChangeListeners = new ArrayList();
+                
+                Iterator j = keyValues.iterator();
+                while(j.hasNext()) {
+                    PropertyChangeListener pcl =
+                        (PropertyChangeListener) j.next();
+                    if(pcl instanceof Serializable) {
+                        serializedPropertiesChangeListeners.add(pcl);
+                    }
+                }
+                
+                if(!serializedPropertiesChangeListeners.isEmpty()) {
+                    selectedSerializedPropertiesChangeListeners.put(
+                        propertyName, serializedPropertiesChangeListeners);
+                }
+                
+            }
+        }
+        
+        children = new Hashtable(selectedSerializedPropertiesChangeListeners);
+        children.put("", allSerializedPropertiesChangeListeners);
+        oos.writeObject(children);
+        
+        Object source = null;
+        if((sourceBean != null) && (sourceBean instanceof Serializable)) {
+            source = sourceBean;
+        }
+        oos.writeObject(source);
+        
+        oos.writeInt(propertyChangeSupportSerializedDataVersion);
+    }
+    
+    /**
+     * @com.intel.drl.spec_ref
+     */
+    private void readObject(ObjectInputStream ois)
+            throws IOException, ClassNotFoundException {
+        children = (Hashtable) ois.readObject();
+        
+        selectedPropertiesChangeListeners = new HashMap(children);
+        allPropertiesChangeListeners =
+            (ArrayList) selectedPropertiesChangeListeners.remove("");
+        if(allPropertiesChangeListeners == null) {
+            allPropertiesChangeListeners = new ArrayList();
+        }
+        
+        sourceBean = ois.readObject();
+        propertyChangeSupportSerializedDataVersion = ois.readInt();
+    }
+
+    /**
+     * @com.intel.drl.spec_ref
+     */
+    public void firePropertyChange(PropertyChangeEvent event) {
+        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) {
+        String propertyName = event.getPropertyName();
+        Object oldValue = event.getOldValue();
+        Object newValue = event.getNewValue();
+        
+        if (newValue != null && oldValue != null && newValue.equals(oldValue)) {
+            return;
+        }
+
+        Iterator iterator = allPropertiesChangeListeners.iterator();
+        while (iterator.hasNext()) {
+            PropertyChangeListener listener =
+                (PropertyChangeListener) iterator.next();
+            listener.propertyChange(event);
+        }
+        ArrayList listeners = (ArrayList) selectedPropertiesChangeListeners.get(
+                propertyName);
+        if (listeners != null) {
+            iterator = listeners.iterator();
+            while (iterator.hasNext()) {
+                PropertyChangeListener listener =
+                    (PropertyChangeListener) iterator.next();
+                listener.propertyChange(event);
+            }
+        }
+    }
+
+    private static PropertyChangeListener[] getAsPropertyChangeListenerArray(
+            ArrayList listeners) {
+        Object[] objects = listeners.toArray();
+        PropertyChangeListener[] arrayResult =
+                new PropertyChangeListener[objects.length];
+        
+        for(int i = 0; i < objects.length; ++i) {
+            arrayResult[i] = (PropertyChangeListener) objects[i];
+        }
+        
+        return arrayResult;
+    }
+}

Added: incubator/harmony/enhanced/classlib/trunk/modules/regex-beans-math/src/common/javasrc/java/beans/PropertyDescriptor.java
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/classlib/trunk/modules/regex-beans-math/src/common/javasrc/java/beans/PropertyDescriptor.java?rev=387239&view=auto
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/regex-beans-math/src/common/javasrc/java/beans/PropertyDescriptor.java (added)
+++ incubator/harmony/enhanced/classlib/trunk/modules/regex-beans-math/src/common/javasrc/java/beans/PropertyDescriptor.java Mon Mar 20 08:31:09 2006
@@ -0,0 +1,337 @@
+/*
+ *  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.9.4.3 $
+ */
+package java.beans;
+
+import java.lang.reflect.Method;
+import java.lang.reflect.Modifier;
+import java.util.Vector;
+
+/**
+ * @author Maxim V. Berkultsev
+ * @version $Revision: 1.9.4.3 $
+ */
+
+public class PropertyDescriptor extends FeatureDescriptor {
+
+    Class beanClass = null;
+    String propertyName = null;
+    
+    Method getter = null;
+    Method setter = null;
+    
+    Class propertyEditorClass = null;
+    
+    boolean constrained = false;
+    boolean bound = false;
+
+    /**
+     * @com.intel.drl.spec_ref
+     */
+    public PropertyDescriptor(
+            String propertyName,
+            Class beanClass,
+            String getterName,
+            String setterName) throws IntrospectionException {
+        super();
+        this.beanClass = beanClass;
+        this.propertyName = propertyName;
+        
+        this.setName(propertyName);
+        this.setDisplayName(propertyName);
+        
+        setWriteMethod(beanClass, setterName);
+        setReadMethod(beanClass, getterName);
+    }
+
+    /**
+     * @com.intel.drl.spec_ref
+     */
+    public PropertyDescriptor(String propertyName, Method getter, Method setter)
+            throws IntrospectionException {
+        super();
+        this.propertyName = propertyName;
+        
+        this.setName(propertyName);
+        this.setDisplayName(propertyName);
+        
+        setWriteMethod(setter);
+        setReadMethod(getter);
+    }
+
+    /**
+     * @com.intel.drl.spec_ref
+     */
+    public PropertyDescriptor(String propertyName, Class beanClass)
+            throws IntrospectionException {
+        super();
+        this.propertyName = propertyName;
+        
+        this.setName(propertyName);
+        this.setDisplayName(propertyName);
+        
+        String getterName = createDefaultMethodName(propertyName, "is");
+        if(hasMethod(beanClass, getterName)) {
+            setReadMethod(beanClass, getterName);
+        } else {
+            getterName = createDefaultMethodName(propertyName, "get");
+            if(hasMethod(beanClass, getterName)) {
+                setReadMethod(beanClass, getterName);
+            }
+        }
+        String setterName = createDefaultMethodName(propertyName, "set");
+        if(hasMethod(beanClass, setterName)) {
+            setWriteMethod(beanClass, setterName);
+        }
+    }
+        
+    /**
+     * @com.intel.drl.spec_ref
+     */
+    public void setWriteMethod(Method setter) throws IntrospectionException {
+        if (setter != null) {
+            int modifiers = setter.getModifiers();
+            if (!Modifier.isPublic(modifiers)) {
+                throw new IntrospectionException(
+                        "Modifier for setter method should be public.");
+            }
+            
+            Class[] parameterTypes = setter.getParameterTypes();
+            if (parameterTypes.length != 1) {
+                throw new IntrospectionException(
+                        "Number of parameters in setter method is not "
+                        + "equal to 1.");
+            }
+            
+            Class parameterType = parameterTypes[0];
+            Class propertyType = getPropertyType();
+            if(propertyType != null && !propertyType.equals(parameterType)) {
+                throw new IntrospectionException(
+                        "Parameter type in setter method does not "
+                        + "corresponds to predefined.");
+            }
+        }
+        
+        this.setter = setter;
+    }
+
+    /**
+     * @com.intel.drl.spec_ref
+     */
+    public void setReadMethod(Method getter) throws IntrospectionException {
+        if (getter != null) {
+            int modifiers = getter.getModifiers();
+            if (!Modifier.isPublic(modifiers)) {
+                throw new IntrospectionException(
+                        "Modifier for getter method should be public.");
+            }
+            
+            Class[] parameterTypes = getter.getParameterTypes();
+            if (parameterTypes.length != 0) {
+                throw new IntrospectionException(
+                        "Number of parameters in getter method is not "
+                        + "equal to 0.");
+            }
+            
+            Class returnType = getter.getReturnType();
+            Class propertyType = getPropertyType();
+            if((propertyType != null) && !returnType.equals(propertyType)) {
+                throw new IntrospectionException(
+                        "Parameter type in getter method does not "
+                        + "corresponds to predefined.");
+            }
+        }
+        
+        this.getter = getter;
+    }
+
+    /**
+     * @com.intel.drl.spec_ref
+     */
+    public Method getWriteMethod() {
+        return setter;
+    }
+
+    /**
+     * @com.intel.drl.spec_ref
+     */
+    public Method getReadMethod() {
+        return getter;
+    }
+
+    /**
+     * @com.intel.drl.spec_ref
+     */
+    public boolean equals(Object object) {
+        boolean result = (object != null);
+        if (result) {
+            PropertyDescriptor pd = (PropertyDescriptor) object;
+            
+            boolean gettersAreEqual = (this.getter == null)
+                    && (pd.getReadMethod() == null) || (this.getter != null)
+                    && (this.getter.equals(pd.getReadMethod()));
+            
+            boolean settersAreEqual = (this.setter == null)
+                    && (pd.getWriteMethod() == null) || (this.setter != null)
+                    && (this.setter.equals(pd.getWriteMethod()));
+            
+            boolean propertyTypesAreEqual =
+                    this.getPropertyType() == pd.getPropertyType();
+            boolean propertyEditorClassesAreEqual =
+                    this.getPropertyEditorClass() == pd.getPropertyEditorClass();
+            boolean boundPropertyAreEqual = this.isBound() == pd.isBound();
+            boolean constrainedPropertyAreEqual =
+                    this.isConstrained() == pd.isConstrained();
+            
+            result = gettersAreEqual
+                    && settersAreEqual
+                    && propertyTypesAreEqual
+                    && propertyEditorClassesAreEqual
+                    && boundPropertyAreEqual
+                    && constrainedPropertyAreEqual;
+        };
+        return result;
+    }
+
+    /**
+     * @com.intel.drl.spec_ref
+     */
+    public void setPropertyEditorClass(Class propertyEditorClass) {
+        this.propertyEditorClass = propertyEditorClass;
+    }
+
+    /**
+     * @com.intel.drl.spec_ref
+     */
+    public Class getPropertyType() {
+        Class result = null;
+        if (getter != null) {
+            result = getter.getReturnType();
+        } else if (setter != null) {
+            Class[] parameterTypes = setter.getParameterTypes();
+            result = parameterTypes[0];
+        }
+        return result;
+    }
+
+    /**
+     * @com.intel.drl.spec_ref
+     */
+    public Class getPropertyEditorClass() {
+        return propertyEditorClass;
+    }
+
+    /**
+     * @com.intel.drl.spec_ref
+     */
+    public void setConstrained(boolean constrained) {
+        this.constrained = constrained;
+    }
+
+    /**
+     * @com.intel.drl.spec_ref
+     */
+    public void setBound(boolean bound) {
+        this.bound = bound;
+    }
+
+    /**
+     * @com.intel.drl.spec_ref
+     */
+    public boolean isConstrained() {
+        return constrained;
+    }
+
+    /**
+     * @com.intel.drl.spec_ref
+     */
+    public boolean isBound() {
+        return bound;
+    }
+    
+    boolean hasMethod(Class beanClass, String methodName) {
+        Method[] methods = findMethods(beanClass, methodName);
+        return (methods.length > 0);
+    }
+    
+    String createDefaultMethodName(String propertyName, String prefix) {
+        String result = null;
+        if (propertyName != null) {
+            String bos = propertyName.substring(0, 1).toUpperCase();
+            String eos = propertyName.substring(1, propertyName.length());
+            result = prefix + bos + eos;
+        }
+        return result;
+    }
+    
+    Method[] findMethods(Class aClass, String methodName) {
+        Method[] allMethods = aClass.getMethods();
+        Vector matchedMethods = new Vector();
+        for (int i = 0; i < allMethods.length; ++i) {
+            Method method = allMethods[i];
+            if (method.getName().equals(methodName)) {
+                matchedMethods.add(method);
+            }
+        }
+        
+        Method[] result = new Method[matchedMethods.size()];
+        for(int j = 0; j < matchedMethods.size(); ++j) {
+            result[j] = (Method) matchedMethods.elementAt(j);
+        }
+        return result;
+    }
+    
+    private void setReadMethod(Class beanClass, String getterName) {
+        boolean result = false;
+        
+        Method[] getters = findMethods(beanClass, getterName);
+        
+        for (int i = 0; i < getters.length; ++i) {
+            try {
+                setReadMethod(getters[i]);
+                result = true;
+            } catch (IntrospectionException ie) {
+            }
+            
+            if (result) {
+                break;
+            }
+        }
+    }
+
+    private void setWriteMethod(Class beanClass, String setterName)
+            throws IntrospectionException {
+        boolean result = false;
+        
+        Method[] setters = findMethods(beanClass, setterName);
+        
+        for (int i = 0; i < setters.length; ++i) {
+            try {
+                setWriteMethod(setters[i]);
+                result = true;
+            } catch (IntrospectionException ie) {
+            }
+            
+            if (result) {
+                break;
+            }
+        }
+    }
+}

Added: incubator/harmony/enhanced/classlib/trunk/modules/regex-beans-math/src/common/javasrc/java/beans/PropertyEditor.java
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/classlib/trunk/modules/regex-beans-math/src/common/javasrc/java/beans/PropertyEditor.java?rev=387239&view=auto
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/regex-beans-math/src/common/javasrc/java/beans/PropertyEditor.java (added)
+++ incubator/harmony/enhanced/classlib/trunk/modules/regex-beans-math/src/common/javasrc/java/beans/PropertyEditor.java Mon Mar 20 08:31:09 2006
@@ -0,0 +1,93 @@
+/*
+ *  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;
+
+/**
+ * @author Maxim V. Berkultsev
+ * @version $Revision: 1.3.6.3 $
+ */
+
+public interface PropertyEditor {
+
+    /**
+     * @com.intel.drl.spec_ref
+     */
+    public void paintValue(Graphics gfx, Rectangle box);
+
+    /**
+     * @com.intel.drl.spec_ref
+     */
+    public void setAsText(String text) throws IllegalArgumentException;
+
+    /**
+     * @com.intel.drl.spec_ref
+     */
+    public String[] getTags();
+
+    /**
+     * @com.intel.drl.spec_ref
+     */
+    public String getJavaInitializationString();
+
+    /**
+     * @com.intel.drl.spec_ref
+     */
+    public String getAsText();
+
+    /**
+     * @com.intel.drl.spec_ref
+     */
+    public void setValue(Object value);
+
+    /**
+     * @com.intel.drl.spec_ref
+     */
+    public Object getValue();
+
+    /**
+     * @com.intel.drl.spec_ref
+     */
+    public void removePropertyChangeListener(PropertyChangeListener listener);
+
+    /**
+     * @com.intel.drl.spec_ref
+     */
+    public void addPropertyChangeListener(PropertyChangeListener listener);
+
+    /**
+     * @com.intel.drl.spec_ref
+     */
+    public Component getCustomEditor();
+
+    /**
+     * @com.intel.drl.spec_ref
+     */
+    public boolean supportsCustomEditor();
+
+    /**
+     * @com.intel.drl.spec_ref
+     */
+    public boolean isPaintable();
+}

Added: incubator/harmony/enhanced/classlib/trunk/modules/regex-beans-math/src/common/javasrc/java/beans/PropertyEditorManager.java
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/classlib/trunk/modules/regex-beans-math/src/common/javasrc/java/beans/PropertyEditorManager.java?rev=387239&view=auto
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/regex-beans-math/src/common/javasrc/java/beans/PropertyEditorManager.java (added)
+++ incubator/harmony/enhanced/classlib/trunk/modules/regex-beans-math/src/common/javasrc/java/beans/PropertyEditorManager.java Mon Mar 20 08:31:09 2006
@@ -0,0 +1,128 @@
+/*
+ *  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.6.6.4 $
+ */
+package java.beans;
+
+import java.util.HashMap;
+
+/**
+ * @author Maxim V. Berkultsev
+ * @version $Revision: 1.6.6.4 $
+ */
+
+public class PropertyEditorManager {
+    
+    private static String[] path = {"org.apache.harmony.beans.editors"};
+    private static HashMap registeredEditors = new HashMap();
+    
+    /**
+     */
+    public PropertyEditorManager() {
+    }
+
+    /**
+     * @com.intel.drl.spec_ref
+     */
+    public static void registerEditor(Class targetType, Class editorClass) {
+        if (targetType != null) {
+            SecurityManager sm = System.getSecurityManager();
+            if (sm != null) {
+                sm.checkPropertiesAccess();
+            }
+            if (editorClass != null) {
+                registeredEditors.put(targetType, editorClass);
+            } else {
+                registeredEditors.remove(targetType);
+            }
+        }
+    }
+
+    /**
+     * @com.intel.drl.spec_ref
+     */
+    public static synchronized PropertyEditor findEditor(Class targetType) {
+        Class editorClass = null;
+        PropertyEditor editor = null;
+        
+        if (targetType != null) {
+            editorClass = (Class) registeredEditors.get(targetType);
+            
+            if (editorClass == null) {
+                String editorClassName = targetType.getName() + "Editor";
+                
+                try {
+                    editorClass = Class.forName(
+                        editorClassName, true, targetType.getClassLoader());
+                } catch (ClassNotFoundException cnfe) {
+                    String shortEditorClassName = editorClassName.substring(
+                        editorClassName.lastIndexOf(".") + 1);
+                    
+                    if(targetType.isPrimitive()) {
+                        shortEditorClassName =
+                            shortEditorClassName.substring(0,1).toUpperCase()
+                            + shortEditorClassName.substring(1);
+                    }
+                    
+                    for (int i = 0; i < path.length; ++i) {
+                        editorClassName = path[i] + "." + shortEditorClassName;
+                        
+                        try {
+                            editorClass = Class.forName(editorClassName, true,
+                                targetType.getClassLoader());
+                        } catch (ClassNotFoundException cnfe2) {
+                        } catch (Exception e) {
+                            break;
+                        }
+                    }
+                } catch (Exception e) {
+                }
+            }
+                
+            if (editorClass != null) {
+                try {
+                    editor = (PropertyEditor) editorClass.newInstance();
+                } catch (Exception e) {
+                }
+            }
+            
+        }
+        return editor;
+    }
+
+    /**
+     * @com.intel.drl.spec_ref
+     */
+    public static synchronized void setEditorSearchPath(String[] apath) {
+        SecurityManager sm = System.getSecurityManager();
+        
+        if (sm != null) {
+            sm.checkPropertiesAccess();
+        }
+        
+        path = apath;
+    }
+
+    /**
+     * @com.intel.drl.spec_ref
+     */
+    public static synchronized String[] getEditorSearchPath() {
+        return path;
+    }
+}