home *** CD-ROM | disk | FTP | other *** search
/ Borland JBuilder 6 / jbuilder6.iso / IBM VisualAge for Java Enterprise v4.0 Retail / ivj40 / setup / IDE.Cab / F87873_ArrayElementModel.class (.txt) < prev    next >
Encoding:
Java Class File  |  2001-03-22  |  2.4 KB  |  65 lines

  1. package com.ibm.ivj.testpilot.model;
  2.  
  3. import java.lang.reflect.Array;
  4.  
  5. public class ArrayElementModel extends ObjectModel {
  6.    private static String copyright = "Licensed Material - Property of IBM IBM(R) VisualAge(R) for Java(TM), Version 3.5 (C) Copyright IBM Corp. 1997, 2000- All Rights Reserved. US Government Users Restricted Rights - Use, duplication or disclosure restricted by GSA ADP Schedule Contract with IBM Corp.";
  7.    private int index;
  8.    private Class type = null;
  9.  
  10.    public ArrayElementModel(MemberModel var1, int var2, Class var3) {
  11.       super(var1);
  12.       this.initializeIndex(var2);
  13.       this.initializeType(var3);
  14.       ((MemberModel)this).initializeName(var1.getName() + "[" + var2 + "]");
  15.    }
  16.  
  17.    protected ArrayElementModel(MemberModel var1, int var2, Class var3, String var4) {
  18.       super(var1, var4);
  19.       this.initializeIndex(var2);
  20.       this.initializeType(var3);
  21.    }
  22.  
  23.    public Class getDeclaredType() {
  24.       return this.type;
  25.    }
  26.  
  27.    public int getIndex() {
  28.       return this.index;
  29.    }
  30.  
  31.    private void initializeIndex(int var1) {
  32.       this.index = var1;
  33.    }
  34.  
  35.    private void initializeType(Class var1) {
  36.       this.type = var1;
  37.    }
  38.  
  39.    public boolean isReadable() {
  40.       return ((MemberModel)this).getOwner().isReadable();
  41.    }
  42.  
  43.    public boolean isWritable() {
  44.       return ((MemberModel)this).getOwner().isReadable();
  45.    }
  46.  
  47.    protected Object tryGetObject() throws IllegalAccessException {
  48.       try {
  49.          return Array.get(((MemberModel)this).getOwner().getObject(), this.getIndex());
  50.       } catch (Throwable var2) {
  51.          throw new IllegalAccessException(var2.toString());
  52.       }
  53.    }
  54.  
  55.    protected void trySetObject(Object var1) throws IllegalAccessException {
  56.       try {
  57.          Array.set(((MemberModel)this).getOwner().getObject(), this.getIndex(), var1);
  58.       } catch (IllegalArgumentException var3) {
  59.       } catch (Throwable var4) {
  60.          throw new IllegalAccessException(var4.toString());
  61.       }
  62.  
  63.    }
  64. }
  65.