diff --git a/src/de/dhbwstuttgart/parser/JavaClassName.java b/src/de/dhbwstuttgart/parser/JavaClassName.java new file mode 100644 index 00000000..857680f0 --- /dev/null +++ b/src/de/dhbwstuttgart/parser/JavaClassName.java @@ -0,0 +1,125 @@ +package de.dhbwstuttgart.parser; + +import de.dhbwstuttgart.typeinference.Menge; + +import de.dhbwstuttgart.syntaxtree.type.RefType; + +/** + * Stellt den Namen einer Java Klasse dar. + * Dieser kann auch den Packagenamen mit beinhalten: de.dhbwstuttgart.typeinference.Menge + * + * @author janulrich + * + */ +public class JavaClassName { + + private String name; + private PackageName packageName; + + public JavaClassName(String name){ + if(name == null)throw new NullPointerException(); + + String[] names = name.split("[.]"); + boolean match = true; + if(names.length == 1){ + //packageName = new PackageName(); + this.name = name; + }else { + name = names[names.length-1]; + Menge packageNames = new Menge(); + for(int i = 0; i names = new Menge(); + + public PackageName(Menge packageNames) { + names = packageNames; + } + + public PackageName() { + //Do nothing + } + + @Override + public int hashCode() { + final int prime = 31; + int result = 1; + result = prime * result + ((names == null) ? 0 : names.hashCode()); + return result; + } + + @Override + public boolean equals(Object obj) { + if (this == obj) + return true; + if (obj == null) + return false; + if (getClass() != obj.getClass()) + return false; + PackageName other = (PackageName) obj; + if (names == null) { + if (other.names != null) + return false; + } else if (!names.equals(other.names)) + return false; + return true; + } + + @Override + public String toString() { + String ret = ""; + if(names == null)return ""; + for(String n : names)ret+=n+"."; + return ret; + } +}