home *** CD-ROM | disk | FTP | other *** search
- package java.beans;
-
- import java.lang.reflect.Method;
-
- public class PropertyDescriptor extends FeatureDescriptor {
- private Class propertyType;
- private Method readMethod;
- private Method writeMethod;
- private boolean bound;
- private boolean constrained;
- private Class propertyEditorClass;
-
- public PropertyDescriptor(String var1, Class var2) throws IntrospectionException {
- ((FeatureDescriptor)this).setName(var1);
- String var3 = this.capitalize(var1);
- this.writeMethod = Introspector.findMethod(var2, "set" + var3, 1);
- if (this.writeMethod.getParameterTypes()[0] == Boolean.TYPE) {
- try {
- this.readMethod = Introspector.findMethod(var2, "is" + var3, 0);
- } catch (Exception var4) {
- }
- }
-
- if (this.readMethod == null) {
- this.readMethod = Introspector.findMethod(var2, "get" + var3, 0);
- }
-
- this.findPropertyType();
- }
-
- public PropertyDescriptor(String var1, Class var2, String var3, String var4) throws IntrospectionException {
- ((FeatureDescriptor)this).setName(var1);
- this.readMethod = Introspector.findMethod(var2, var3, 0);
- this.writeMethod = Introspector.findMethod(var2, var4, 1);
- this.findPropertyType();
- }
-
- public PropertyDescriptor(String var1, Method var2, Method var3) throws IntrospectionException {
- ((FeatureDescriptor)this).setName(var1);
- this.readMethod = var2;
- this.writeMethod = var3;
- this.findPropertyType();
- }
-
- public Class getPropertyType() {
- return this.propertyType;
- }
-
- public Method getReadMethod() {
- return this.readMethod;
- }
-
- public Method getWriteMethod() {
- return this.writeMethod;
- }
-
- public boolean isBound() {
- return this.bound;
- }
-
- public void setBound(boolean var1) {
- this.bound = var1;
- }
-
- public boolean isConstrained() {
- return this.constrained;
- }
-
- public void setConstrained(boolean var1) {
- this.constrained = var1;
- }
-
- public void setPropertyEditorClass(Class var1) {
- this.propertyEditorClass = var1;
- }
-
- public Class getPropertyEditorClass() {
- return this.propertyEditorClass;
- }
-
- PropertyDescriptor(PropertyDescriptor var1, PropertyDescriptor var2) {
- super(var1, var2);
- this.readMethod = var1.readMethod;
- this.propertyType = var1.propertyType;
- if (var2.readMethod != null) {
- this.readMethod = var2.readMethod;
- }
-
- this.writeMethod = var1.writeMethod;
- if (var2.writeMethod != null) {
- this.writeMethod = var2.writeMethod;
- }
-
- this.propertyEditorClass = var1.propertyEditorClass;
- if (var2.propertyEditorClass != null) {
- this.propertyEditorClass = var2.propertyEditorClass;
- }
-
- this.bound = var1.bound | var2.bound;
- this.constrained = var1.constrained | var2.constrained;
-
- try {
- this.findPropertyType();
- } catch (IntrospectionException var3) {
- throw new Error("PropertyDescriptor: internal error while merging PDs");
- }
- }
-
- private void findPropertyType() throws IntrospectionException {
- try {
- this.propertyType = null;
- if (this.readMethod != null) {
- if (this.readMethod.getParameterTypes().length != 0) {
- throw new IntrospectionException("bad read method arg count");
- }
-
- this.propertyType = this.readMethod.getReturnType();
- if (this.propertyType == Void.TYPE) {
- throw new IntrospectionException("read method " + this.readMethod.getName() + " returns void");
- }
- }
-
- if (this.writeMethod != null) {
- Class[] var1 = this.writeMethod.getParameterTypes();
- if (var1.length != 1) {
- throw new IntrospectionException("bad write method arg count");
- } else if (this.propertyType != null && this.propertyType != var1[0]) {
- throw new IntrospectionException("type mismatch between read and write methods");
- } else {
- this.propertyType = var1[0];
- }
- }
- } catch (IntrospectionException var2) {
- throw var2;
- }
- }
-
- private String capitalize(String var1) {
- char[] var2 = var1.toCharArray();
- var2[0] = Character.toUpperCase(var2[0]);
- return new String(var2);
- }
- }
-