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 / java / ClassDeclaration.class (.txt) < prev    next >
Encoding:
Java Class File  |  1997-07-08  |  2.7 KB  |  101 lines

  1. package sun.tools.java;
  2.  
  3. public final class ClassDeclaration implements Constants {
  4.    int status;
  5.    Type type;
  6.    ClassDefinition definition;
  7.  
  8.    public ClassDeclaration(Identifier var1) {
  9.       this.type = Type.tClass(var1);
  10.    }
  11.  
  12.    public int getStatus() {
  13.       return this.status;
  14.    }
  15.  
  16.    public Identifier getName() {
  17.       return this.type.getClassName();
  18.    }
  19.  
  20.    public Type getType() {
  21.       return this.type;
  22.    }
  23.  
  24.    public boolean isDefined() {
  25.       switch (this.status) {
  26.          case 2:
  27.          case 4:
  28.          case 5:
  29.          case 7:
  30.             return true;
  31.          case 3:
  32.          case 6:
  33.          default:
  34.             return false;
  35.       }
  36.    }
  37.  
  38.    public ClassDefinition getClassDefinition() {
  39.       return this.definition;
  40.    }
  41.  
  42.    public ClassDefinition getClassDefinition(Environment var1) throws ClassNotFound {
  43.       while(true) {
  44.          switch (this.status) {
  45.             case 0:
  46.             case 1:
  47.             case 3:
  48.                var1.loadDefinition(this);
  49.                break;
  50.             case 2:
  51.             case 4:
  52.                this.definition.basicCheck(var1);
  53.                return this.definition;
  54.             case 5:
  55.             case 7:
  56.                return this.definition;
  57.             case 6:
  58.             default:
  59.                throw new ClassNotFound(this.getName());
  60.          }
  61.       }
  62.    }
  63.  
  64.    public void setDefinition(ClassDefinition var1, int var2) {
  65.       this.definition = var1;
  66.       this.status = var2;
  67.       if (var1 != null && !this.getName().equals(var1.getName())) {
  68.          throw new CompilerError("invalid class defintion: " + this + ", " + var1);
  69.       }
  70.    }
  71.  
  72.    public boolean equals(Object var1) {
  73.       return var1 != null && var1 instanceof ClassDeclaration ? this.type.equals(((ClassDeclaration)var1).type) : false;
  74.    }
  75.  
  76.    public String toString() {
  77.       String var1 = this.getName().toString();
  78.       String var2 = "type ";
  79.       String var3 = this.getName().isInner() ? "nested " : "";
  80.       if (this.getClassDefinition() != null) {
  81.          if (this.getClassDefinition().isInterface()) {
  82.             var2 = "interface ";
  83.          } else {
  84.             var2 = "class ";
  85.          }
  86.  
  87.          if (!this.getClassDefinition().isTopLevel()) {
  88.             var3 = "inner ";
  89.             if (this.getClassDefinition().isLocal()) {
  90.                var3 = "local ";
  91.                if (!this.getClassDefinition().isAnonymous()) {
  92.                   var1 = this.getClassDefinition().getLocalName() + " (" + var1 + ")";
  93.                }
  94.             }
  95.          }
  96.       }
  97.  
  98.       return var3 + var2 + var1;
  99.    }
  100. }
  101.