home *** CD-ROM | disk | FTP | other *** search
/ Symantec Visual Cafe for Java 2.5 / symantec-visual-cafe-2.5-database-dev-edition.iso / VPage / Java.bin / CLASSES.ZIP / sun / tools / debug / RemoteClass.class (.txt) < prev    next >
Encoding:
Java Class File  |  1997-07-08  |  6.4 KB  |  299 lines

  1. package sun.tools.debug;
  2.  
  3. import java.io.InputStream;
  4.  
  5. public class RemoteClass extends RemoteObject {
  6.    String name;
  7.    String sourceName;
  8.    boolean intf;
  9.    RemoteClass superclass;
  10.    RemoteObject loader;
  11.    RemoteClass[] interfaces;
  12.    private RemoteField[] methods;
  13.    private RemoteField[] instanceFields;
  14.    private RemoteField[] staticFields;
  15.  
  16.    RemoteClass(RemoteAgent var1, int var2) {
  17.       super(var1, 16, var2, var1.classClass);
  18.    }
  19.  
  20.    private void getClassInfo() throws Exception {
  21.       if (this.interfaces == null) {
  22.          super.agent.getClassInfo(this);
  23.       }
  24.  
  25.    }
  26.  
  27.    private void loadFields() throws Exception {
  28.       if (this.staticFields == null || this.instanceFields == null) {
  29.          RemoteField[] var1 = super.agent.getFields(super.id);
  30.          int var2 = 0;
  31.  
  32.          for(int var3 = 0; var3 < var1.length; ++var3) {
  33.             if (var1[var3].isStatic()) {
  34.                ++var2;
  35.             }
  36.          }
  37.  
  38.          this.staticFields = new RemoteField[var2];
  39.          this.instanceFields = new RemoteField[var1.length - var2];
  40.          int var4 = 0;
  41.          int var5 = 0;
  42.  
  43.          for(int var6 = 0; var6 < var1.length; ++var6) {
  44.             if (var1[var6].isStatic()) {
  45.                this.staticFields[var5++] = var1[var6];
  46.             } else {
  47.                this.instanceFields[var4++] = var1[var6];
  48.             }
  49.          }
  50.       }
  51.  
  52.    }
  53.  
  54.    public String getName() throws Exception {
  55.       this.getClassInfo();
  56.       return this.name;
  57.    }
  58.  
  59.    public String typeName() throws Exception {
  60.       this.getClassInfo();
  61.       return this.getName();
  62.    }
  63.  
  64.    public boolean isInterface() throws Exception {
  65.       this.getClassInfo();
  66.       return this.intf;
  67.    }
  68.  
  69.    public RemoteClass getSuperclass() throws Exception {
  70.       this.getClassInfo();
  71.       return this.superclass;
  72.    }
  73.  
  74.    public RemoteObject getClassLoader() throws Exception {
  75.       this.getClassInfo();
  76.       return this.loader;
  77.    }
  78.  
  79.    public RemoteClass[] getInterfaces() throws Exception {
  80.       this.getClassInfo();
  81.       return this.interfaces;
  82.    }
  83.  
  84.    public String getSourceFileName() throws Exception {
  85.       this.getClassInfo();
  86.       return this.sourceName;
  87.    }
  88.  
  89.    public InputStream getSourceFile() throws Exception {
  90.       this.getClassInfo();
  91.       return super.agent.getSourceFile(this.name, this.sourceName);
  92.    }
  93.  
  94.    public RemoteField[] getFields() throws Exception {
  95.       return this.getStaticFields();
  96.    }
  97.  
  98.    public RemoteField[] getStaticFields() throws Exception {
  99.       this.loadFields();
  100.       return this.staticFields;
  101.    }
  102.  
  103.    public RemoteField[] getInstanceFields() throws Exception {
  104.       this.loadFields();
  105.       return this.instanceFields;
  106.    }
  107.  
  108.    public RemoteField getField(int var1) throws Exception {
  109.       this.loadFields();
  110.       if (var1 >= 0 && var1 < this.staticFields.length) {
  111.          return this.staticFields[var1];
  112.       } else {
  113.          throw new ArrayIndexOutOfBoundsException();
  114.       }
  115.    }
  116.  
  117.    public RemoteField getField(String var1) throws NoSuchFieldException, Exception {
  118.       this.loadFields();
  119.  
  120.       for(int var2 = 0; var2 < this.staticFields.length; ++var2) {
  121.          if (var1.equals(this.staticFields[var2].getName())) {
  122.             return this.staticFields[var2];
  123.          }
  124.       }
  125.  
  126.       throw new NoSuchFieldException();
  127.    }
  128.  
  129.    public RemoteField getInstanceField(int var1) throws Exception {
  130.       this.loadFields();
  131.       if (var1 >= 0 && var1 < this.instanceFields.length) {
  132.          return this.instanceFields[var1];
  133.       } else {
  134.          throw new ArrayIndexOutOfBoundsException();
  135.       }
  136.    }
  137.  
  138.    public RemoteValue getFieldValue(int var1) throws Exception {
  139.       return this.getField(var1).getValue(super.id);
  140.    }
  141.  
  142.    public RemoteValue getFieldValue(String var1) throws NoSuchFieldException, Exception {
  143.       this.loadFields();
  144.  
  145.       for(int var2 = 0; var2 < this.staticFields.length; ++var2) {
  146.          if (var1.equals(this.staticFields[var2].getName())) {
  147.             return this.staticFields[var2].getValue(super.id);
  148.          }
  149.       }
  150.  
  151.       throw new NoSuchFieldException();
  152.    }
  153.  
  154.    public RemoteField getMethod(String var1) throws NoSuchMethodException, Exception {
  155.       if (this.methods == null) {
  156.          this.methods = super.agent.getMethods(super.id);
  157.       }
  158.  
  159.       for(int var2 = 0; var2 < this.methods.length; ++var2) {
  160.          if (var1.equals(this.methods[var2].getName())) {
  161.             return this.methods[var2];
  162.          }
  163.       }
  164.  
  165.       throw new NoSuchMethodException();
  166.    }
  167.  
  168.    public RemoteField[] getMethods() throws Exception {
  169.       if (this.methods == null) {
  170.          this.methods = super.agent.getMethods(super.id);
  171.       }
  172.  
  173.       return this.methods;
  174.    }
  175.  
  176.    public String[] getMethodNames() throws Exception {
  177.       if (this.methods == null) {
  178.          this.methods = super.agent.getMethods(super.id);
  179.       }
  180.  
  181.       String[] var1 = new String[this.methods.length];
  182.  
  183.       for(int var2 = 0; var2 < this.methods.length; ++var2) {
  184.          var1[var2] = this.methods[var2].getName();
  185.       }
  186.  
  187.       return var1;
  188.    }
  189.  
  190.    public int getMethodLineNumber(String var1) throws NoSuchMethodException, NoSuchLineNumberException, Exception {
  191.       if (this.methods == null) {
  192.          this.methods = super.agent.getMethods(super.id);
  193.       }
  194.  
  195.       for(int var2 = 0; var2 < this.methods.length; ++var2) {
  196.          if (var1.equals(this.methods[var2].getName())) {
  197.             int var3 = super.agent.getMethodLineNumber(super.id, var2);
  198.             if (var3 == -1) {
  199.                throw new NoSuchLineNumberException();
  200.             }
  201.  
  202.             return var3;
  203.          }
  204.       }
  205.  
  206.       throw new NoSuchMethodException();
  207.    }
  208.  
  209.    public int getMethodLineNumber(int var1) throws IndexOutOfBoundsException, NoSuchLineNumberException, Exception {
  210.       if (this.methods == null) {
  211.          this.methods = super.agent.getMethods(super.id);
  212.       }
  213.  
  214.       if (var1 >= 0 && var1 < this.methods.length) {
  215.          int var2 = super.agent.getMethodLineNumber(super.id, var1);
  216.          if (var2 == -1) {
  217.             throw new NoSuchLineNumberException();
  218.          } else {
  219.             return var2;
  220.          }
  221.       } else {
  222.          throw new IndexOutOfBoundsException();
  223.       }
  224.    }
  225.  
  226.    public String setBreakpointLine(int var1) throws Exception {
  227.       return super.agent.setBreakpointLine(this, var1);
  228.    }
  229.  
  230.    public String setBreakpointMethod(RemoteField var1) throws Exception {
  231.       return super.agent.setBreakpointMethod(this, var1);
  232.    }
  233.  
  234.    public String clearBreakpoint(int var1) throws Exception {
  235.       return super.agent.clearBreakpoint(this, var1);
  236.    }
  237.  
  238.    public String clearBreakpointLine(int var1) throws Exception {
  239.       return super.agent.clearBreakpointLine(this, var1);
  240.    }
  241.  
  242.    public String clearBreakpointMethod(RemoteField var1) throws Exception {
  243.       return super.agent.clearBreakpointMethod(this, var1);
  244.    }
  245.  
  246.    private boolean isExceptionClass() throws Exception {
  247.       if (!this.getName().equals("java.lang.Exception") && !this.getName().equals("java.lang.Error")) {
  248.          RemoteClass var1 = this.superclass;
  249.  
  250.          do {
  251.             super.agent.message("isExceptionClass: superClass=" + var1.getName());
  252.             if (var1.getName().equals("java.lang.Exception") || var1.getName().equals("java.lang.Error")) {
  253.                return true;
  254.             }
  255.  
  256.             var1 = var1.getSuperclass();
  257.          } while(!var1.getName().equals("java.lang.Object"));
  258.  
  259.          return false;
  260.       } else {
  261.          return true;
  262.       }
  263.    }
  264.  
  265.    public void catchExceptions() throws Exception {
  266.       if (this.isExceptionClass()) {
  267.          super.agent.catchExceptionClass(this);
  268.       } else {
  269.          throw new ClassCastException();
  270.       }
  271.    }
  272.  
  273.    public void ignoreExceptions() throws Exception {
  274.       if (this.isExceptionClass()) {
  275.          super.agent.ignoreExceptionClass(this);
  276.       } else {
  277.          throw new ClassCastException();
  278.       }
  279.    }
  280.  
  281.    public int[] getLineNumbers() throws Exception {
  282.       this.getClassInfo();
  283.       return super.agent.getLineNumbers(this);
  284.    }
  285.  
  286.    public String description() {
  287.       return this.toString();
  288.    }
  289.  
  290.    public String toString() {
  291.       try {
  292.          this.getClassInfo();
  293.          return RemoteValue.toHex(super.id) + ":" + (this.intf ? "interface" : "class") + "(" + this.getName() + ")";
  294.       } catch (Exception var1) {
  295.          return "<communications errors>";
  296.       }
  297.    }
  298. }
  299.