From 25d61b703be663513c6bbb64524c78b1a672885f Mon Sep 17 00:00:00 2001 From: JanUlrich Date: Thu, 28 Aug 2014 18:42:54 +0200 Subject: [PATCH] =?UTF-8?q?JavaClassName=20eingef=C3=BChrt?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/mycompiler/myparser/JavaClassName.java | 124 +++++++++++++++++++++ 1 file changed, 124 insertions(+) create mode 100644 src/mycompiler/myparser/JavaClassName.java diff --git a/src/mycompiler/myparser/JavaClassName.java b/src/mycompiler/myparser/JavaClassName.java new file mode 100644 index 00000000..adf9b054 --- /dev/null +++ b/src/mycompiler/myparser/JavaClassName.java @@ -0,0 +1,124 @@ +package mycompiler.myparser; + +import java.util.Vector; + +import mycompiler.mytype.RefType; + +/** + * Stellt den Namen einer Java Klasse dar. + * Dieser kann auch den Packagenamen mit beinhalten: java.util.Vector + * + * @author janulrich + * + */ +public class JavaClassName { + + private String name; + private PackageName packageName; + + public JavaClassName(String name){ + String[] names = name.split("[.]"); + boolean match = true; + if(names.length == 1){ + packageName = new PackageName(); + this.name = name; + }else { + name = names[names.length-1]; + Vector packageNames = new Vector(); + for(int i = 0; i names = new Vector(); + + public PackageName(Vector 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; + } +}