summaryrefslogtreecommitdiffstats
path: root/awt/java/beans
diff options
context:
space:
mode:
authorThe Android Open Source Project <initial-contribution@android.com>2009-03-03 18:28:45 -0800
committerThe Android Open Source Project <initial-contribution@android.com>2009-03-03 18:28:45 -0800
commitd5193d9394c5e58176d7bcdf50ef017f8a3b9e1e (patch)
tree4b825dc642cb6eb9a060e54bf8d69288fbee4904 /awt/java/beans
parent43aa2b1cbf7a03e248e10f4d0fec0463257cd52d (diff)
downloadframeworks_native-d5193d9394c5e58176d7bcdf50ef017f8a3b9e1e.zip
frameworks_native-d5193d9394c5e58176d7bcdf50ef017f8a3b9e1e.tar.gz
frameworks_native-d5193d9394c5e58176d7bcdf50ef017f8a3b9e1e.tar.bz2
auto import from //depot/cupcake/@135843
Diffstat (limited to 'awt/java/beans')
-rw-r--r--awt/java/beans/FeatureDescriptor.java234
-rw-r--r--awt/java/beans/IndexedPropertyDescriptor.java227
-rw-r--r--awt/java/beans/IntrospectionException.java27
-rw-r--r--awt/java/beans/PropertyDescriptor.java300
-rw-r--r--awt/java/beans/PropertyEditor.java49
-rw-r--r--awt/java/beans/PropertyEditorManager.java114
-rw-r--r--awt/java/beans/PropertyEditorSupport.java129
-rw-r--r--awt/java/beans/PropertyVetoException.java54
8 files changed, 0 insertions, 1134 deletions
diff --git a/awt/java/beans/FeatureDescriptor.java b/awt/java/beans/FeatureDescriptor.java
deleted file mode 100644
index 2945c65..0000000
--- a/awt/java/beans/FeatureDescriptor.java
+++ /dev/null
@@ -1,234 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You 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.
- */
-
-package java.beans;
-
-import java.util.Collections;
-import java.util.Enumeration;
-import java.util.HashMap;
-import java.util.LinkedList;
-import java.util.Map;
-
-/**
- * Common base class for Descriptors.
- */
-public class FeatureDescriptor {
-
- private Map<String, Object> values;
-
- boolean preferred, hidden, expert;
-
- String shortDescription;
-
- String name;
-
- String displayName;
-
- /**
- * <p>
- * Constructs an instance.
- * </p>
- */
- public FeatureDescriptor() {
- this.values = new HashMap<String, Object>();
- }
-
- /**
- * <p>
- * Sets the value for the named attribute.
- * </p>
- *
- * @param attributeName
- * The name of the attribute to set a value with.
- * @param value
- * The value to set.
- */
- public void setValue(String attributeName, Object value) {
- if (attributeName == null || value == null) {
- throw new NullPointerException();
- }
- values.put(attributeName, value);
- }
-
- /**
- * <p>
- * Gets the value associated with the named attribute.
- * </p>
- *
- * @param attributeName
- * The name of the attribute to get a value for.
- * @return The attribute's value.
- */
- public Object getValue(String attributeName) {
- Object result = null;
- if (attributeName != null) {
- result = values.get(attributeName);
- }
- return result;
- }
-
- /**
- * <p>
- * Enumerates the attribute names.
- * </p>
- *
- * @return An instance of {@link Enumeration}.
- */
- public Enumeration<String> attributeNames() {
- // Create a new list, so that the references are copied
- return Collections.enumeration(new LinkedList<String>(values.keySet()));
- }
-
- /**
- * <p>
- * Sets the short description.
- * </p>
- *
- * @param text
- * The description to set.
- */
- public void setShortDescription(String text) {
- this.shortDescription = text;
- }
-
- /**
- * <p>
- * Sets the name.
- * </p>
- *
- * @param name
- * The name to set.
- */
- public void setName(String name) {
- this.name = name;
- }
-
- /**
- * <p>
- * Sets the display name.
- * </p>
- *
- * @param displayName
- * The display name to set.
- */
- public void setDisplayName(String displayName) {
- this.displayName = displayName;
- }
-
- /**
- * <p>
- * Gets the short description or {@link #getDisplayName()} if not set.
- * </p>
- *
- * @return The description.
- */
- public String getShortDescription() {
- return shortDescription == null ? getDisplayName() : shortDescription;
- }
-
- /**
- * <p>
- * Gets the name.
- * </p>
- *
- * @return The name.
- */
- public String getName() {
- return name;
- }
-
- /**
- * <p>
- * Gets the display name or {@link #getName()} if not set.
- * </p>
- *
- * @return The display name.
- */
- public String getDisplayName() {
- return displayName == null ? getName() : displayName;
- }
-
- /**
- * <p>
- * Sets the preferred indicator.
- * </p>
- *
- * @param preferred
- * <code>true</code> if preferred, <code>false</code>
- * otherwise.
- */
- public void setPreferred(boolean preferred) {
- this.preferred = preferred;
- }
-
- /**
- * <p>
- * Sets the hidden indicator.
- * </p>
- *
- * @param hidden
- * <code>true</code> if hidden, <code>false</code> otherwise.
- */
- public void setHidden(boolean hidden) {
- this.hidden = hidden;
- }
-
- /**
- * <p>
- * Sets the expert indicator.
- * </p>
- *
- * @param expert
- * <code>true</code> if expert, <code>false</code> otherwise.
- */
- public void setExpert(boolean expert) {
- this.expert = expert;
- }
-
- /**
- * <p>
- * Indicates if this feature is preferred.
- * </p>
- *
- * @return <code>true</code> if preferred, <code>false</code> otherwise.
- */
- public boolean isPreferred() {
- return preferred;
- }
-
- /**
- * <p>
- * Indicates if this feature is hidden.
- * </p>
- *
- * @return <code>true</code> if hidden, <code>false</code> otherwise.
- */
- public boolean isHidden() {
- return hidden;
- }
-
- /**
- * <p>
- * Indicates if this feature is an expert feature.
- * </p>
- *
- * @return <code>true</code> if hidden, <code>false</code> otherwise.
- */
- public boolean isExpert() {
- return expert;
- }
-}
diff --git a/awt/java/beans/IndexedPropertyDescriptor.java b/awt/java/beans/IndexedPropertyDescriptor.java
deleted file mode 100644
index 25667d9..0000000
--- a/awt/java/beans/IndexedPropertyDescriptor.java
+++ /dev/null
@@ -1,227 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You 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.
- */
-
-package java.beans;
-
-import java.lang.reflect.Method;
-import java.lang.reflect.Modifier;
-import org.apache.harmony.beans.internal.nls.Messages;
-
-public class IndexedPropertyDescriptor extends PropertyDescriptor {
- private Method indexedGetter;
-
- private Method indexedSetter;
-
- public IndexedPropertyDescriptor(String propertyName, Class<?> beanClass,
- String getterName, String setterName, String indexedGetterName,
- String indexedSetterName) throws IntrospectionException {
- super(propertyName, beanClass, getterName, setterName);
-
- // RI behaves like this
- if (indexedGetterName == null && indexedSetterName == null &&
- (getterName != null || setterName != null)) {
- throw new IntrospectionException(Messages.getString("beans.50"));
- }
- setIndexedReadMethod(beanClass, indexedGetterName);
- setIndexedWriteMethod(beanClass, indexedSetterName);
- }
-
- public IndexedPropertyDescriptor(String propertyName, Method getter, Method setter,
- Method indexedGetter, Method indexedSetter) throws IntrospectionException {
- super(propertyName, getter, setter);
-
- // we need this in order to be compatible with RI
- if (indexedGetter == null && indexedSetter == null &&
- (getter != null || setter != null)) {
- throw new IntrospectionException(Messages.getString("beans.50"));
- }
- setIndexedReadMethod(indexedGetter);
- setIndexedWriteMethod(indexedSetter);
- }
-
- public IndexedPropertyDescriptor(String propertyName, Class<?> beanClass)
- throws IntrospectionException {
- super(propertyName, beanClass, null, null);
- String getterName;
- String setterName;
- String indexedGetterName;
- String indexedSetterName;
-
- // array getter
- getterName = createDefaultMethodName(propertyName, "get"); //$NON-NLS-1$
- if (hasMethod(beanClass, getterName)) {
- setReadMethod(beanClass, getterName);
- }
- // array setter
- setterName = createDefaultMethodName(propertyName, "set"); //$NON-NLS-1$
- if (hasMethod(beanClass, setterName)) {
- setWriteMethod(beanClass, setterName);
- }
- // indexed getter
- indexedGetterName = createDefaultMethodName(propertyName, "get"); //$NON-NLS-1$
- if (hasMethod(beanClass, indexedGetterName)) {
- setIndexedReadMethod(beanClass, indexedGetterName);
- }
- // indexed setter
- indexedSetterName = createDefaultMethodName(propertyName, "set"); //$NON-NLS-1$
- if (hasMethod(beanClass, indexedSetterName)) {
- setIndexedWriteMethod(beanClass, indexedSetterName);
- }
- // RI seems to behave a bit differently
- if (indexedGetter == null && indexedSetter == null &&
- getReadMethod() == null && getWriteMethod() == null) {
- throw new IntrospectionException(
- Messages.getString("beans.01", propertyName)); //$NON-NLS-1$
- }
- if (indexedGetter == null && indexedSetter == null) {
- // not an indexed property indeed
- throw new IntrospectionException(Messages.getString("beans.50"));
- }
- }
-
- public void setIndexedReadMethod(Method indexedGetter) throws IntrospectionException {
- if (indexedGetter != null) {
- int modifiers = indexedGetter.getModifiers();
- Class<?>[] parameterTypes;
- Class<?> returnType;
- Class<?> indexedPropertyType;
-
- if (!Modifier.isPublic(modifiers)) {
- throw new IntrospectionException(Messages.getString("beans.21")); //$NON-NLS-1$
- }
- parameterTypes = indexedGetter.getParameterTypes();
- if (parameterTypes.length != 1) {
- throw new IntrospectionException(Messages.getString("beans.22")); //$NON-NLS-1$
- }
- if (!parameterTypes[0].equals(int.class)) {
- throw new IntrospectionException(Messages.getString("beans.23")); //$NON-NLS-1$
- }
- returnType = indexedGetter.getReturnType();
- indexedPropertyType = getIndexedPropertyType();
- if ((indexedPropertyType != null) && !returnType.equals(indexedPropertyType)) {
- throw new IntrospectionException(Messages.getString("beans.24")); //$NON-NLS-1$
- }
- }
- this.indexedGetter = indexedGetter;
- }
-
- public void setIndexedWriteMethod(Method indexedSetter) throws IntrospectionException {
- if (indexedSetter != null) {
- int modifiers = indexedSetter.getModifiers();
- Class<?>[] parameterTypes;
- Class<?> firstParameterType;
- Class<?> secondParameterType;
- Class<?> propType;
-
- if (!Modifier.isPublic(modifiers)) {
- throw new IntrospectionException(Messages.getString("beans.25")); //$NON-NLS-1$
- }
- parameterTypes = indexedSetter.getParameterTypes();
- if (parameterTypes.length != 2) {
- throw new IntrospectionException(Messages.getString("beans.26")); //$NON-NLS-1$
- }
- firstParameterType = parameterTypes[0];
- if (!firstParameterType.equals(int.class)) {
- throw new IntrospectionException(Messages.getString("beans.27")); //$NON-NLS-1$
- }
- secondParameterType = parameterTypes[1];
- propType = getIndexedPropertyType();
- if (propType != null && !secondParameterType.equals(propType)) {
- throw new IntrospectionException(Messages.getString("beans.28")); //$NON-NLS-1$
- }
- }
- this.indexedSetter = indexedSetter;
- }
-
- public Method getIndexedWriteMethod() {
- return indexedSetter;
- }
-
- public Method getIndexedReadMethod() {
- return indexedGetter;
- }
-
- @Override
- public boolean equals(Object obj) {
- boolean result = super.equals(obj);
-
- if (result) {
- IndexedPropertyDescriptor pd = (IndexedPropertyDescriptor) obj;
-
- if (indexedGetter != null) {
- result = indexedGetter.equals(pd.getIndexedReadMethod());
- } else if (result && indexedGetter == null) {
- result = pd.getIndexedReadMethod() == null;
- }
-
- if (result) {
- if (indexedSetter != null) {
- result = indexedSetter.equals(pd.getIndexedWriteMethod());
- } else if (indexedSetter == null) {
- result = pd.getIndexedWriteMethod() == null;
- }
- }
- }
-
- return result;
- }
-
- public Class<?> getIndexedPropertyType() {
- Class<?> result = null;
-
- if (indexedGetter != null) {
- result = indexedGetter.getReturnType();
- } else if (indexedSetter != null) {
- Class<?>[] parameterTypes = indexedSetter.getParameterTypes();
-
- result = parameterTypes[1];
- }
- return result;
- }
-
- private void setIndexedReadMethod(Class<?> beanClass, String indexedGetterName) {
- Method[] getters = findMethods(beanClass, indexedGetterName);
- boolean result = false;
-
- for (Method element : getters) {
- try {
- setIndexedReadMethod(element);
- result = true;
- } catch (IntrospectionException ie) {}
-
- if (result) {
- break;
- }
- }
- }
-
- private void setIndexedWriteMethod(Class<?> beanClass, String indexedSetterName) {
- Method[] setters = findMethods(beanClass, indexedSetterName);
- boolean result = false;
-
- for (Method element : setters) {
- try {
- setIndexedWriteMethod(element);
- result = true;
- } catch (IntrospectionException ie) {}
-
- if (result) {
- break;
- }
- }
- }
-}
diff --git a/awt/java/beans/IntrospectionException.java b/awt/java/beans/IntrospectionException.java
deleted file mode 100644
index c895afe..0000000
--- a/awt/java/beans/IntrospectionException.java
+++ /dev/null
@@ -1,27 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You 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.
- */
-
-package java.beans;
-
-public class IntrospectionException extends Exception {
-
- static final long serialVersionUID = -3728150539969542619L;
-
- public IntrospectionException(String message) {
- super(message);
- }
-}
diff --git a/awt/java/beans/PropertyDescriptor.java b/awt/java/beans/PropertyDescriptor.java
deleted file mode 100644
index 9389152..0000000
--- a/awt/java/beans/PropertyDescriptor.java
+++ /dev/null
@@ -1,300 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You 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.
- */
-
-package java.beans;
-
-import java.lang.reflect.Constructor;
-import java.lang.reflect.Method;
-import java.lang.reflect.Modifier;
-import java.util.Vector;
-import org.apache.harmony.beans.internal.nls.Messages;
-
-public class PropertyDescriptor extends FeatureDescriptor {
- private Method getter;
-
- private Method setter;
-
- private Class<?> propertyEditorClass;
-
- private boolean constrained;
-
- private boolean bound;
-
- public PropertyDescriptor(String propertyName, Class<?> beanClass, String getterName,
- String setterName) throws IntrospectionException {
- super();
- if (beanClass == null) {
- throw new IntrospectionException(Messages.getString("beans.03")); //$NON-NLS-1$
- }
- if (propertyName == null || propertyName.length() == 0) {
- throw new IntrospectionException(Messages.getString("beans.04")); //$NON-NLS-1$
- }
- this.setName(propertyName);
- this.setDisplayName(propertyName);
- if (setterName != null) {
- if (hasMethod(beanClass, setterName)) {
- setWriteMethod(beanClass, setterName);
- } else {
- throw new IntrospectionException(Messages.getString("beans.20")); //$NON-NLS-1$
- }
- }
- if (getterName != null) {
- if (hasMethod(beanClass, getterName)) {
- setReadMethod(beanClass, getterName);
- } else {
- throw new IntrospectionException(Messages.getString("beans.1F")); //$NON-NLS-1$
- }
- }
- }
-
- public PropertyDescriptor(String propertyName, Method getter, Method setter)
- throws IntrospectionException {
- super();
- if (propertyName == null || propertyName.length() == 0) {
- throw new IntrospectionException(Messages.getString("beans.04")); //$NON-NLS-1$
- }
- this.setName(propertyName);
- this.setDisplayName(propertyName);
- setWriteMethod(setter);
- setReadMethod(getter);
- }
-
- public PropertyDescriptor(String propertyName, Class<?> beanClass)
- throws IntrospectionException {
- String getterName;
- String setterName;
- if (beanClass == null) {
- throw new IntrospectionException(Messages.getString("beans.03")); //$NON-NLS-1$
- }
- if (propertyName == null || propertyName.length() == 0) {
- throw new IntrospectionException(Messages.getString("beans.04")); //$NON-NLS-1$
- }
- this.setName(propertyName);
- this.setDisplayName(propertyName);
- getterName = createDefaultMethodName(propertyName, "is"); //$NON-NLS-1$
- if (hasMethod(beanClass, getterName)) {
- setReadMethod(beanClass, getterName);
- } else {
- getterName = createDefaultMethodName(propertyName, "get"); //$NON-NLS-1$
- if (hasMethod(beanClass, getterName)) {
- setReadMethod(beanClass, getterName);
- }
- }
- setterName = createDefaultMethodName(propertyName, "set"); //$NON-NLS-1$
- if (hasMethod(beanClass, setterName)) {
- setWriteMethod(beanClass, setterName);
- }
- if (getter == null && setter == null) {
- throw new IntrospectionException(Messages.getString("beans.01", propertyName)); //$NON-NLS-1$
- }
- }
-
- public void setWriteMethod(Method setter) throws IntrospectionException {
- if (setter != null) {
- int modifiers = setter.getModifiers();
- if (!Modifier.isPublic(modifiers)) {
- throw new IntrospectionException(Messages.getString("beans.05")); //$NON-NLS-1$
- }
- Class<?>[] parameterTypes = setter.getParameterTypes();
- if (parameterTypes.length != 1) {
- throw new IntrospectionException(Messages.getString("beans.06")); //$NON-NLS-1$
- }
- Class<?> parameterType = parameterTypes[0];
- Class<?> propertyType = getPropertyType();
- if (propertyType != null && !propertyType.equals(parameterType)) {
- throw new IntrospectionException(Messages.getString("beans.07")); //$NON-NLS-1$
- }
- }
- this.setter = setter;
- }
-
- public void setReadMethod(Method getter) throws IntrospectionException {
- if (getter != null) {
- int modifiers = getter.getModifiers();
- if (!Modifier.isPublic(modifiers)) {
- throw new IntrospectionException(Messages.getString("beans.0A")); //$NON-NLS-1$
- }
- Class<?>[] parameterTypes = getter.getParameterTypes();
- if (parameterTypes.length != 0) {
- throw new IntrospectionException(Messages.getString("beans.08")); //$NON-NLS-1$
- }
- Class<?> returnType = getter.getReturnType();
- if (returnType.equals(Void.TYPE)) {
- throw new IntrospectionException(Messages.getString("beans.33")); //$NON-NLS-1$
- }
- Class<?> propertyType = getPropertyType();
- if ((propertyType != null) && !returnType.equals(propertyType)) {
- throw new IntrospectionException(Messages.getString("beans.09")); //$NON-NLS-1$
- }
- }
- this.getter = getter;
- }
-
- public Method getWriteMethod() {
- return setter;
- }
-
- public Method getReadMethod() {
- return getter;
- }
-
- @Override
- public boolean equals(Object object) {
- boolean result = (object != null && object instanceof PropertyDescriptor);
- 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;
- }
-
- public void setPropertyEditorClass(Class<?> propertyEditorClass) {
- this.propertyEditorClass = propertyEditorClass;
- }
-
- 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;
- }
-
- public Class<?> getPropertyEditorClass() {
- return propertyEditorClass;
- }
-
- public void setConstrained(boolean constrained) {
- this.constrained = constrained;
- }
-
- public void setBound(boolean bound) {
- this.bound = bound;
- }
-
- public boolean isConstrained() {
- return constrained;
- }
-
- 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<Method> matchedMethods = new Vector<Method>();
- Method[] result;
- for (Method method : allMethods) {
- if (method.getName().equals(methodName)) {
- matchedMethods.add(method);
- }
- }
- result = new Method[matchedMethods.size()];
- for (int j = 0; j < matchedMethods.size(); ++j) {
- result[j] = matchedMethods.elementAt(j);
- }
- return result;
- }
-
- void setReadMethod(Class<?> beanClass, String getterName) {
- boolean result = false;
- Method[] getters = findMethods(beanClass, getterName);
- for (Method element : getters) {
- try {
- setReadMethod(element);
- result = true;
- } catch (IntrospectionException ie) {
- }
- if (result) {
- break;
- }
- }
- }
-
- void setWriteMethod(Class<?> beanClass, String setterName) throws IntrospectionException {
- boolean result = false;
- Method[] setters = findMethods(beanClass, setterName);
- for (Method element : setters) {
- try {
- setWriteMethod(element);
- result = true;
- } catch (IntrospectionException ie) {
- }
- if (result) {
- break;
- }
- }
- }
-
- public PropertyEditor createPropertyEditor(Object bean) {
- PropertyEditor editor;
- if (propertyEditorClass == null) {
- return null;
- }
- if (!PropertyEditor.class.isAssignableFrom(propertyEditorClass)) {
- // beans.48=Property editor is not assignable from the
- // PropertyEditor interface
- throw new ClassCastException(Messages.getString("beans.48")); //$NON-NLS-1$
- }
- try {
- Constructor<?> constr;
- try {
- // try to look for the constructor with single Object argument
- constr = propertyEditorClass.getConstructor(Object.class);
- editor = (PropertyEditor) constr.newInstance(bean);
- } catch (NoSuchMethodException e) {
- // try no-argument constructor
- constr = propertyEditorClass.getConstructor();
- editor = (PropertyEditor) constr.newInstance();
- }
- } catch (Exception e) {
- // beans.47=Unable to instantiate property editor
- RuntimeException re = new RuntimeException(Messages.getString("beans.47"), e); //$NON-NLS-1$
- throw re;
- }
- return editor;
- }
-}
diff --git a/awt/java/beans/PropertyEditor.java b/awt/java/beans/PropertyEditor.java
deleted file mode 100644
index 65bedea..0000000
--- a/awt/java/beans/PropertyEditor.java
+++ /dev/null
@@ -1,49 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You 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.
- */
-
-package java.beans;
-
-import java.awt.Component;
-import java.awt.Graphics;
-import java.awt.Rectangle;
-
-public interface PropertyEditor {
-
- public void paintValue(Graphics gfx, Rectangle box);
-
- public void setAsText(String text) throws IllegalArgumentException;
-
- public String[] getTags();
-
- public String getJavaInitializationString();
-
- public String getAsText();
-
- public void setValue(Object value);
-
- public Object getValue();
-
- public void removePropertyChangeListener(PropertyChangeListener listener);
-
- public void addPropertyChangeListener(PropertyChangeListener listener);
-
- public Component getCustomEditor();
-
- public boolean supportsCustomEditor();
-
- public boolean isPaintable();
-}
diff --git a/awt/java/beans/PropertyEditorManager.java b/awt/java/beans/PropertyEditorManager.java
deleted file mode 100644
index ed55829..0000000
--- a/awt/java/beans/PropertyEditorManager.java
+++ /dev/null
@@ -1,114 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You 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.
- */
-
-package java.beans;
-
-import java.util.HashMap;
-import java.util.Map;
-
-public class PropertyEditorManager {
-
- private static String[] path = { "org.apache.harmony.beans.editors" }; //$NON-NLS-1$
-
- private static final Map<Class<?>, Class<?>> registeredEditors = new HashMap<Class<?>, Class<?>>();
-
- public PropertyEditorManager() {
- }
-
- public static void registerEditor(Class<?> targetType, Class<?> editorClass) {
- if (targetType == null) {
- throw new NullPointerException();
- }
-
- SecurityManager sm = System.getSecurityManager();
- if (sm != null) {
- sm.checkPropertiesAccess();
- }
- if (editorClass != null) {
- registeredEditors.put(targetType, editorClass);
- } else {
- registeredEditors.remove(targetType);
- }
- }
-
- public static synchronized PropertyEditor findEditor(Class<?> targetType) {
- if (targetType == null) {
- throw new NullPointerException();
- }
-
- Class<?> editorClass = null;
- PropertyEditor editor = null;
-
- editorClass = registeredEditors.get(targetType);
-
- if (editorClass == null) {
- String editorClassName = targetType.getName() + "Editor"; //$NON-NLS-1$
- ClassLoader loader = targetType.getClassLoader();
-
- if (loader == null) {
- loader = Thread.currentThread().getContextClassLoader();
- }
-
- try {
- editorClass = Class.forName(editorClassName, true, loader);
- } catch (ClassNotFoundException cnfe) {
- String shortEditorClassName = editorClassName
- .substring(editorClassName.lastIndexOf(".") + 1); //$NON-NLS-1$
-
- if (targetType.isPrimitive()) {
- shortEditorClassName = shortEditorClassName.substring(0, 1)
- .toUpperCase()
- + shortEditorClassName.substring(1);
- }
-
- for (String element : path) {
- editorClassName = element + "." + shortEditorClassName; //$NON-NLS-1$
-
- try {
- editorClass = Class.forName(editorClassName, true,
- loader);
- break;
- } catch (Exception e) {
- }
- }
- } catch (Exception e) {
- }
- }
-
- if (editorClass != null) {
- try {
- editor = (PropertyEditor) editorClass.newInstance();
- } catch (Exception e) {
- }
- }
-
- return editor;
- }
-
- public static synchronized void setEditorSearchPath(String[] apath) {
- SecurityManager sm = System.getSecurityManager();
- if (sm != null) {
- sm.checkPropertiesAccess();
- }
-
- path = apath;
- }
-
- public static synchronized String[] getEditorSearchPath() {
- return path;
- }
-}
diff --git a/awt/java/beans/PropertyEditorSupport.java b/awt/java/beans/PropertyEditorSupport.java
deleted file mode 100644
index c3929a1..0000000
--- a/awt/java/beans/PropertyEditorSupport.java
+++ /dev/null
@@ -1,129 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You 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.
- */
-package java.beans;
-
-import java.awt.Component;
-import java.awt.Graphics;
-import java.awt.Rectangle;
-import java.util.ArrayList;
-import java.util.Iterator;
-import java.util.List;
-
-import org.apache.harmony.beans.internal.nls.Messages;
-
-public class PropertyEditorSupport implements PropertyEditor {
-
- Object source = null;
-
- List<PropertyChangeListener> listeners = new ArrayList<PropertyChangeListener>();
-
- Object oldValue = null;
-
- Object newValue = null;
-
- public PropertyEditorSupport(Object source) {
- if (source == null) {
- throw new NullPointerException(Messages.getString("beans.0C")); //$NON-NLS-1$
- }
- this.source = source;
- }
-
- public PropertyEditorSupport() {
- source = this;
- }
-
- public void paintValue(Graphics gfx, Rectangle box) {
- }
-
- public void setAsText(String text) throws IllegalArgumentException {
- if (newValue instanceof String) {
- setValue(text);
- } else {
- throw new IllegalArgumentException(text);
- }
- }
-
- public String[] getTags() {
- return null;
- }
-
- public String getJavaInitializationString() {
- return "???"; //$NON-NLS-1$
- }
-
- public String getAsText() {
- return newValue == null ? "null" : newValue.toString(); //$NON-NLS-1$
- }
-
- public void setValue(Object value) {
- this.oldValue = this.newValue;
- this.newValue = value;
- firePropertyChange();
- }
-
- public Object getValue() {
- return newValue;
- }
-
- public void setSource(Object source) {
- if (source == null) {
- throw new NullPointerException(Messages.getString("beans.0C")); //$NON-NLS-1$
- }
- this.source = source;
- }
-
- public Object getSource() {
- return source;
- }
-
- public synchronized void removePropertyChangeListener(
- PropertyChangeListener listener) {
- if (listeners != null) {
- listeners.remove(listener);
- }
- }
-
- public synchronized void addPropertyChangeListener(
- PropertyChangeListener listener) {
- listeners.add(listener);
- }
-
- public Component getCustomEditor() {
- return null;
- }
-
- public boolean supportsCustomEditor() {
- return false;
- }
-
- public boolean isPaintable() {
- return false;
- }
-
- public void firePropertyChange() {
- if (listeners.size() > 0) {
- PropertyChangeEvent event = new PropertyChangeEvent(source, null,
- oldValue, newValue);
- Iterator<PropertyChangeListener> iterator = listeners.iterator();
-
- while (iterator.hasNext()) {
- PropertyChangeListener listener = iterator.next();
- listener.propertyChange(event);
- }
- }
- }
-}
diff --git a/awt/java/beans/PropertyVetoException.java b/awt/java/beans/PropertyVetoException.java
deleted file mode 100644
index c7f092a..0000000
--- a/awt/java/beans/PropertyVetoException.java
+++ /dev/null
@@ -1,54 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You 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.
- */
-
-package java.beans;
-
-/**
- * Indicates that a proposed property change is unacceptable.
- */
-public class PropertyVetoException extends Exception {
-
- private static final long serialVersionUID = 129596057694162164L;
-
- private final PropertyChangeEvent evt;
-
- /**
- * <p>
- * Constructs an instance with a message and the change event.
- * </p>
- *
- * @param message
- * A description of the veto.
- * @param event
- * The event that was vetoed.
- */
- public PropertyVetoException(String message, PropertyChangeEvent event) {
- super(message);
- this.evt = event;
- }
-
- /**
- * <p>
- * Gets the property change event.
- * </p>
- *
- * @return An instance of {@link PropertyChangeEvent}
- */
- public PropertyChangeEvent getPropertyChangeEvent() {
- return evt;
- }
-}