home *** CD-ROM | disk | FTP | other *** search
/ S283 Planetary Science &n…he Search for Life DVD 2 / DVD-ROM.iso / install / jre1_3 / lib / rt.jar / java / beans / IndexedPropertyDescriptor.class (.txt) < prev    next >
Encoding:
Java Class File  |  1979-12-31  |  3.0 KB  |  126 lines

  1. package java.beans;
  2.  
  3. import java.lang.reflect.Method;
  4.  
  5. public class IndexedPropertyDescriptor extends PropertyDescriptor {
  6.    private Class indexedPropertyType;
  7.    private Method indexedReadMethod;
  8.    private Method indexedWriteMethod;
  9.  
  10.    public IndexedPropertyDescriptor(String var1, Class var2) throws IntrospectionException {
  11.       this(var1, var2, "get" + PropertyDescriptor.capitalize(var1), "set" + PropertyDescriptor.capitalize(var1), "get" + PropertyDescriptor.capitalize(var1), "set" + PropertyDescriptor.capitalize(var1));
  12.    }
  13.  
  14.    public IndexedPropertyDescriptor(String var1, Class var2, String var3, String var4, String var5, String var6) throws IntrospectionException {
  15.       super(var1, var2, var3, var4);
  16.       this.indexedReadMethod = Introspector.findMethod(var2, var5, 1);
  17.       this.indexedWriteMethod = Introspector.findMethod(var2, var6, 2);
  18.       this.findIndexedPropertyType();
  19.    }
  20.  
  21.    public IndexedPropertyDescriptor(String var1, Method var2, Method var3, Method var4, Method var5) throws IntrospectionException {
  22.       super(var1, var2, var3);
  23.       this.indexedReadMethod = var4;
  24.       this.indexedWriteMethod = var5;
  25.       this.findIndexedPropertyType();
  26.    }
  27.  
  28.    public Method getIndexedReadMethod() {
  29.       return this.indexedReadMethod;
  30.    }
  31.  
  32.    public void setIndexedReadMethod(Method var1) throws IntrospectionException {
  33.       this.indexedReadMethod = var1;
  34.       this.findIndexedPropertyType();
  35.    }
  36.  
  37.    public Method getIndexedWriteMethod() {
  38.       return this.indexedWriteMethod;
  39.    }
  40.  
  41.    public void setIndexedWriteMethod(Method var1) throws IntrospectionException {
  42.       this.indexedWriteMethod = var1;
  43.       this.findIndexedPropertyType();
  44.    }
  45.  
  46.    public Class getIndexedPropertyType() {
  47.       return this.indexedPropertyType;
  48.    }
  49.  
  50.    private void findIndexedPropertyType() throws IntrospectionException {
  51.       try {
  52.          this.indexedPropertyType = null;
  53.          if (this.indexedReadMethod != null) {
  54.             Class[] var1 = this.indexedReadMethod.getParameterTypes();
  55.             if (var1.length != 1) {
  56.                throw new IntrospectionException("bad indexed read method arg count");
  57.             }
  58.  
  59.             if (var1[0] != Integer.TYPE) {
  60.                throw new IntrospectionException("non int index to indexed read method");
  61.             }
  62.  
  63.             this.indexedPropertyType = this.indexedReadMethod.getReturnType();
  64.             if (this.indexedPropertyType == Void.TYPE) {
  65.                throw new IntrospectionException("indexed read method returns void");
  66.             }
  67.          }
  68.  
  69.          if (this.indexedWriteMethod != null) {
  70.             Class[] var3 = this.indexedWriteMethod.getParameterTypes();
  71.             if (var3.length != 2) {
  72.                throw new IntrospectionException("bad indexed write method arg count");
  73.             }
  74.  
  75.             if (var3[0] != Integer.TYPE) {
  76.                throw new IntrospectionException("non int index to indexed write method");
  77.             }
  78.  
  79.             if (this.indexedPropertyType != null && this.indexedPropertyType != var3[1]) {
  80.                throw new IntrospectionException("type mismatch between indexed read and indexed write methods");
  81.             }
  82.  
  83.             this.indexedPropertyType = var3[1];
  84.          }
  85.  
  86.          Class var4 = ((PropertyDescriptor)this).getPropertyType();
  87.          if (var4 != null && (!var4.isArray() || var4.getComponentType() != this.indexedPropertyType)) {
  88.             throw new IntrospectionException("type mismatch between indexed and non-indexed methods");
  89.          }
  90.       } catch (IntrospectionException var2) {
  91.          throw var2;
  92.       }
  93.    }
  94.  
  95.    IndexedPropertyDescriptor(PropertyDescriptor var1, PropertyDescriptor var2) {
  96.       super(var1, var2);
  97.       if (var1 instanceof IndexedPropertyDescriptor) {
  98.          IndexedPropertyDescriptor var3 = (IndexedPropertyDescriptor)var1;
  99.          this.indexedReadMethod = var3.indexedReadMethod;
  100.          this.indexedWriteMethod = var3.indexedWriteMethod;
  101.          this.indexedPropertyType = var3.indexedPropertyType;
  102.       }
  103.  
  104.       if (var2 instanceof IndexedPropertyDescriptor) {
  105.          IndexedPropertyDescriptor var4 = (IndexedPropertyDescriptor)var2;
  106.          if (var4.indexedReadMethod != null) {
  107.             this.indexedReadMethod = var4.indexedReadMethod;
  108.          }
  109.  
  110.          if (var4.indexedWriteMethod != null) {
  111.             this.indexedWriteMethod = var4.indexedWriteMethod;
  112.          }
  113.  
  114.          this.indexedPropertyType = var4.indexedPropertyType;
  115.       }
  116.  
  117.    }
  118.  
  119.    IndexedPropertyDescriptor(IndexedPropertyDescriptor var1) {
  120.       super(var1);
  121.       this.indexedReadMethod = var1.indexedReadMethod;
  122.       this.indexedWriteMethod = var1.indexedWriteMethod;
  123.       this.indexedPropertyType = var1.indexedPropertyType;
  124.    }
  125. }
  126.