home *** CD-ROM | disk | FTP | other *** search
- package java.beans;
-
- import java.lang.reflect.Method;
-
- public class IndexedPropertyDescriptor extends PropertyDescriptor {
- private Class indexedPropertyType;
- private Method indexedReadMethod;
- private Method indexedWriteMethod;
-
- public IndexedPropertyDescriptor(String var1, Class var2) throws IntrospectionException {
- this(var1, var2, "get" + capitalize(var1), "set" + capitalize(var1), "get" + capitalize(var1), "set" + capitalize(var1));
- }
-
- public IndexedPropertyDescriptor(String var1, Class var2, String var3, String var4, String var5, String var6) throws IntrospectionException {
- super(var1, var2, var3, var4);
- this.indexedReadMethod = Introspector.findMethod(var2, var5, 1);
- this.indexedWriteMethod = Introspector.findMethod(var2, var6, 2);
- this.findIndexedPropertyType();
- }
-
- public IndexedPropertyDescriptor(String var1, Method var2, Method var3, Method var4, Method var5) throws IntrospectionException {
- super(var1, var2, var3);
- this.indexedReadMethod = var4;
- this.indexedWriteMethod = var5;
- this.findIndexedPropertyType();
- }
-
- public Method getIndexedReadMethod() {
- return this.indexedReadMethod;
- }
-
- public Method getIndexedWriteMethod() {
- return this.indexedWriteMethod;
- }
-
- public Class getIndexedPropertyType() {
- return this.indexedPropertyType;
- }
-
- private void findIndexedPropertyType() throws IntrospectionException {
- try {
- this.indexedPropertyType = null;
- if (this.indexedReadMethod != null) {
- Class[] var1 = this.indexedReadMethod.getParameterTypes();
- if (var1.length != 1) {
- throw new IntrospectionException("bad indexed read method arg count");
- }
-
- if (var1[0] != Integer.TYPE) {
- throw new IntrospectionException("non int index to indexed read method");
- }
-
- this.indexedPropertyType = this.indexedReadMethod.getReturnType();
- if (this.indexedPropertyType == Void.TYPE) {
- throw new IntrospectionException("indexed read method returns void");
- }
- }
-
- if (this.indexedWriteMethod != null) {
- Class[] var3 = this.indexedWriteMethod.getParameterTypes();
- if (var3.length != 2) {
- throw new IntrospectionException("bad indexed write method arg count");
- }
-
- if (var3[0] != Integer.TYPE) {
- throw new IntrospectionException("non int index to indexed write method");
- }
-
- if (this.indexedPropertyType != null && this.indexedPropertyType != var3[1]) {
- throw new IntrospectionException("type mismatch between indexed read and indexed write methods");
- }
-
- this.indexedPropertyType = var3[1];
- }
-
- if (this.indexedPropertyType == null) {
- throw new IntrospectionException("no indexed getter or setter");
- } else {
- Class var4 = ((PropertyDescriptor)this).getPropertyType();
- if (var4 != null && (!var4.isArray() || var4.getComponentType() != this.indexedPropertyType)) {
- throw new IntrospectionException("type mismatch between indexed and non-indexed methods");
- }
- }
- } catch (IntrospectionException var2) {
- throw var2;
- }
- }
-
- IndexedPropertyDescriptor(PropertyDescriptor var1, PropertyDescriptor var2) {
- super(var1, var2);
- if (var1 instanceof IndexedPropertyDescriptor) {
- IndexedPropertyDescriptor var3 = (IndexedPropertyDescriptor)var1;
- this.indexedReadMethod = var3.indexedReadMethod;
- this.indexedWriteMethod = var3.indexedWriteMethod;
- this.indexedPropertyType = var3.indexedPropertyType;
- }
-
- if (var2 instanceof IndexedPropertyDescriptor) {
- IndexedPropertyDescriptor var4 = (IndexedPropertyDescriptor)var2;
- if (var4.indexedReadMethod != null) {
- this.indexedReadMethod = var4.indexedReadMethod;
- }
-
- if (var4.indexedWriteMethod != null) {
- this.indexedWriteMethod = var4.indexedWriteMethod;
- }
-
- this.indexedPropertyType = var4.indexedPropertyType;
- }
-
- }
-
- private static String capitalize(String var0) {
- char[] var1 = var0.toCharArray();
- var1[0] = Character.toUpperCase(var1[0]);
- return new String(var1);
- }
- }
-