Vector fieldvec;
SymbolTable flags;
SymbolTable methods;
-
+
Hashtable singleImports;
-
+
int numstaticblocks = 0;
int numstaticfields = 0;
-
+
// for interfaces
Vector<String> superinterfaces;
SymbolTable superIFdesc;
private int interfaceid;
-
+
// for inner classes
boolean isInnerClass=false;
-
+
// inner classes/enum can have these
String surroundingclass=null;
ClassDescriptor surroudingdesc=null;
SymbolTable innerdescs;
-
+
// for enum type
boolean isEnum = false;
SymbolTable enumdescs;
HashMap<String, Integer> enumConstantTbl;
int enumconstantid = 0;
-
+
String sourceFileName;
-
+
public ClassDescriptor(String classname, boolean isInterface) {
this("", classname, isInterface);
}
public Iterator getFlags() {
return flags.getDescriptorsIterator();
}
-
+
public Iterator getSuperInterfaces() {
return this.superIFdesc.getDescriptorsIterator();
}
public SymbolTable getMethodTable() {
return methods;
}
-
+
public SymbolTable getSuperInterfaceTable() {
return this.superIFdesc;
}
st += "implements ";
boolean needcomma = false;
for(int i = 0; i < this.superinterfaces.size(); i++) {
- if(needcomma) {
- st += ", ";
- }
- st += this.superinterfaces.elementAt(i);
- needcomma = true;
+ if(needcomma) {
+ st += ", ";
+ }
+ st += this.superinterfaces.elementAt(i);
+ needcomma = true;
}
}
st+=" {\n";
indent=TreeNode.INDENT;
boolean printcr=false;
- for(Iterator it=getFlags(); it.hasNext();) {
+ for(Iterator it=getFlags(); it.hasNext(); ) {
FlagDescriptor fd=(FlagDescriptor)it.next();
st+=TreeNode.printSpace(indent)+fd.toString()+"\n";
printcr=true;
printcr=false;
- for(Iterator it=getFields(); it.hasNext();) {
+ for(Iterator it=getFields(); it.hasNext(); ) {
FieldDescriptor fd=(FieldDescriptor)it.next();
st+=TreeNode.printSpace(indent)+fd.toString()+"\n";
printcr=true;
}
if (printcr)
st+="\n";
-
- for(Iterator it=this.getInnerClasses(); it.hasNext();) {
+
+ for(Iterator it=this.getInnerClasses(); it.hasNext(); ) {
ClassDescriptor icd=(ClassDescriptor)it.next();
st+=icd.printTree(state)+"\n";
printcr=true;
}
if (printcr)
st+="\n";
-
- for(Iterator it=this.getEnum(); it.hasNext();) {
+
+ for(Iterator it=this.getEnum(); it.hasNext(); ) {
ClassDescriptor icd = (ClassDescriptor)it.next();
st += icd.getModifier().toString() + " enum " + icd.getSymbol() + " {\n ";
Set keys = icd.getEnumConstantTbl().keySet();
String[] econstants = new String[keys.size()];
Iterator it_keys = keys.iterator();
while(it_keys.hasNext()) {
- String key = (String)it_keys.next();
- econstants[icd.getEnumConstant(key)] = key;
+ String key = (String)it_keys.next();
+ econstants[icd.getEnumConstant(key)] = key;
}
for(int i = 0; i < econstants.length; i++) {
- st += econstants[i];
- if(i < econstants.length-1) {
- st += ", ";
- }
+ st += econstants[i];
+ if(i < econstants.length-1) {
+ st += ", ";
+ }
}
st+="\n}\n";
printcr=true;
if (printcr)
st+="\n";
- for(Iterator it=getMethods(); it.hasNext();) {
+ for(Iterator it=getMethods(); it.hasNext(); ) {
MethodDescriptor md=(MethodDescriptor)it.next();
st+=TreeNode.printSpace(indent)+md.toString()+" ";
BlockNode bn=state.getMethodBody(md);
ClassDescriptor cn=this;
while(true) {
if (cn==null) {
- // TODO: the original code returned "null" if no super class
- // ever defines the method. Is there a situation where this is
- // fine and the client should take other actions? If not, we should
- // change this warning to an error.
- System.out.println( "ClassDescriptor.java: WARNING "+md+
- " did not resolve to an actual method." );
+ // TODO: the original code returned "null" if no super class
+ // ever defines the method. Is there a situation where this is
+ // fine and the client should take other actions? If not, we should
+ // change this warning to an error.
+ System.out.println("ClassDescriptor.java: WARNING "+md+
+ " did not resolve to an actual method.");
return null;
}
Set possiblematches=cn.getMethodTable().getSetFromSameScope(md.getSymbol());
- for(Iterator matchit=possiblematches.iterator(); matchit.hasNext();) {
+ for(Iterator matchit=possiblematches.iterator(); matchit.hasNext(); ) {
MethodDescriptor matchmd=(MethodDescriptor)matchit.next();
-
+
if (md.matches(matchmd)) {
return matchmd;
}
}
-
+
//Not found...walk one level up
cn=cn.getSuperDesc();
}
public String getSuper() {
return superclass;
}
-
+
public void addSuperInterface(String superif) {
this.superinterfaces.addElement(superif);
}
-
+
public Vector<String> getSuperInterface() {
return this.superinterfaces;
}
-
+
public void addSuperInterfaces(ClassDescriptor sif) {
this.superIFdesc.add(sif);
}
-
+
public void incStaticBlocks() {
this.numstaticblocks++;
}
-
+
public int getNumStaticBlocks() {
return this.numstaticblocks;
}
-
+
public void incStaticFields() {
this.numstaticfields++;
}
-
+
public int getNumStaticFields() {
return this.numstaticfields;
}
-
+
public boolean isAbstract() {
return this.modifiers.isAbstract();
}
-
+
public boolean isInterface() {
return (this.classid == -2);
}
-
+
public void setInterfaceId(int id) {
this.interfaceid = id;
}
-
+
public boolean isStatic() {
return this.modifiers.isStatic();
}
-
+
public void setAsInnerClass() {
this.isInnerClass = true;
}
-
+
public boolean isInnerClass() {
return this.isInnerClass;
}
-
+
public void setSurroundingClass(String sclass) {
this.surroundingclass=sclass;
}
public void setSurrounding(ClassDescriptor scd) {
this.surroudingdesc=scd;
}
-
+
public void addInnerClass(ClassDescriptor icd) {
this.innerdescs.add(icd);
}
-
+
public Iterator getInnerClasses() {
return this.innerdescs.getDescriptorsIterator();
}
public SymbolTable getInnerClassTable() {
return this.innerdescs;
}
-
+
public void setAsEnum() {
this.isEnum = true;
}
-
+
public boolean isEnum() {
return this.isEnum;
}
-
+
public void addEnum(ClassDescriptor icd) {
this.enumdescs.add(icd);
}
-
+
public Iterator getEnum() {
return this.enumdescs.getDescriptorsIterator();
}
public SymbolTable getEnumTable() {
return this.enumdescs;
}
-
+
public void addEnumConstant(String econstant) {
if(this.enumConstantTbl == null) {
this.enumConstantTbl = new HashMap<String, Integer>();
}
return;
}
-
+
public int getEnumConstant(String econstant) {
if(this.enumConstantTbl.containsKey(econstant)) {
return this.enumConstantTbl.get(econstant).intValue();
return -1;
}
}
-
+
public HashMap<String, Integer> getEnumConstantTbl() {
return this.enumConstantTbl;
}
-
+
public Modifiers getModifier() {
return this.modifiers;
}
-
- public void setSourceFileName(String sourceFileName){
+
+ public void setSourceFileName(String sourceFileName) {
this.sourceFileName=sourceFileName;
}
-
+
public void setImports(Hashtable singleImports) {
this.singleImports = singleImports;
}
-
- public String getSourceFileName(){
+
+ public String getSourceFileName() {
return this.sourceFileName;
}
-
+
public Hashtable getSingleImportMappings() {
return this.singleImports;
}
-
+
}