2 * JavaInspect - Utility to visualize java software
3 * Copyright (C) 2013-2015, Svjatoslav Agejenko, svjatoslav@svjatoslav.eu
5 * This program is free software; you can redistribute it and/or
6 * modify it under the terms of version 3 of the GNU Lesser General Public License
7 * or later as published by the Free Software Foundation.
10 package eu.svjatoslav.inspector.java.methods;
12 import eu.svjatoslav.commons.string.tokenizer.InvalidSyntaxException;
13 import eu.svjatoslav.commons.string.tokenizer.Tokenizer;
14 import eu.svjatoslav.commons.string.tokenizer.TokenizerMatch;
16 import java.util.ArrayList;
17 import java.util.List;
21 private final String packageName;
22 private final String className;
23 private final boolean isInterface;
25 public ClassReference superClass;
26 public List<ClassReference> implementedInterfaces = new ArrayList<ClassReference>();
28 public Clazz(final String packageName, final String className,
29 final Tokenizer tokenizer, final boolean isInterface)
30 throws InvalidSyntaxException {
32 this.packageName = packageName;
33 this.className = className;
34 this.isInterface = isInterface;
37 final TokenizerMatch match = tokenizer.getNextToken();
39 if ("extends".equals(match.token)) {
40 superClass = new ClassReference(tokenizer);
44 if ("implements".equals(match.token)) {
46 implementedInterfaces.add(new ClassReference(tokenizer));
48 if (tokenizer.probeNextToken(","))
56 if ("{".equals(match.token)) {
57 parseClassBody(tokenizer);
64 public String getFullName() {
65 return packageName + "." + className;
68 public void parseClassBody(final Tokenizer tokenizer) {
69 tokenizer.skipUntilDataEnd();
73 public String toString() {
74 final EnumerationBuffer result = new EnumerationBuffer();
76 result.append(packageName + " -> " + className + " ");
79 result.append("(interface)");
81 result.append("(class)");
84 if (superClass != null)
85 result.append(" super: " + superClass.toString() + "\n");
87 if (implementedInterfaces.size() > 0) {
88 result.append(" implements: ");
89 for (final ClassReference classReference : implementedInterfaces)
90 result.appendEnumeration(classReference.toString());
94 return result.toString();