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 {
- if (var1 != null && var1.length() != 0) {
- ((FeatureDescriptor)this).setName(var1);
- String var3 = capitalize(var1);
-
- try {
- this.readMethod = Introspector.findMethod(var2, "is" + var3, 0);
- } catch (Exception var5) {
- this.readMethod = Introspector.findMethod(var2, "get" + var3, 0);
- }
-
- Class[] var4 = new Class[]{this.readMethod.getReturnType()};
- this.writeMethod = Introspector.findMethod(var2, "set" + var3, 1, var4);
- this.findPropertyType();
- } else {
- throw new IntrospectionException("bad property name");
- }
- }
-
- public PropertyDescriptor(String var1, Class var2, String var3, String var4) throws IntrospectionException {
- if (var1 != null && var1.length() != 0) {
- ((FeatureDescriptor)this).setName(var1);
- this.readMethod = Introspector.findMethod(var2, var3, 0);
- if (this.readMethod != null) {
- Class[] var5 = new Class[]{this.readMethod.getReturnType()};
- this.writeMethod = Introspector.findMethod(var2, var4, 1, var5);
- } else {
- this.writeMethod = Introspector.findMethod(var2, var4, 1);
- }
-
- this.findPropertyType();
- } else {
- throw new IntrospectionException("bad property name");
- }
- }
-
- public PropertyDescriptor(String var1, Method var2, Method var3) throws IntrospectionException {
- if (var1 != null && var1.length() != 0) {
- ((FeatureDescriptor)this).setName(var1);
- this.readMethod = var2;
- this.writeMethod = var3;
- this.findPropertyType();
- } else {
- throw new IntrospectionException("bad property name");
- }
- }
-
- public Class getPropertyType() {
- return this.propertyType;
- }
-
- public Method getReadMethod() {
- return this.readMethod;
- }
-
- public void setReadMethod(Method var1) throws IntrospectionException {
- this.readMethod = var1;
- this.findPropertyType();
- }
-
- public Method getWriteMethod() {
- return this.writeMethod;
- }
-
- public void setWriteMethod(Method var1) throws IntrospectionException {
- this.writeMethod = var1;
- this.findPropertyType();
- }
-
- 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);
- Method var3 = var1.readMethod;
- Method var4 = var2.readMethod;
- this.readMethod = var3;
- if (var4 != null) {
- this.readMethod = var4;
- }
-
- if (var3 != null && var4 != null && var3.getDeclaringClass() == var4.getDeclaringClass() && var3.getReturnType() == Boolean.TYPE && var4.getReturnType() == Boolean.TYPE && var3.getName().indexOf("is") == 0 && var4.getName().indexOf("get") == 0) {
- this.readMethod = var3;
- }
-
- 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 var6) {
- throw new Error("PropertyDescriptor: internal error while merging PDs");
- }
- }
-
- PropertyDescriptor(PropertyDescriptor var1) {
- super(var1);
- this.readMethod = var1.readMethod;
- this.writeMethod = var1.writeMethod;
- this.propertyEditorClass = var1.propertyEditorClass;
- this.bound = var1.bound;
- this.constrained = var1.constrained;
- this.propertyType = var1.propertyType;
- }
-
- 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");
- }
-
- if (this.propertyType != null && this.propertyType != var1[0]) {
- throw new IntrospectionException("type mismatch between read and write methods");
- }
-
- this.propertyType = var1[0];
- }
-
- } catch (IntrospectionException var2) {
- throw var2;
- }
- }
-
- static String capitalize(String var0) {
- if (var0.length() == 0) {
- return var0;
- } else {
- char[] var1 = var0.toCharArray();
- var1[0] = Character.toUpperCase(var1[0]);
- return new String(var1);
- }
- }
- }
-