|
From: <js...@us...> - 2006-11-27 16:54:33
|
Revision: 32
http://svn.sourceforge.net/jcontracts/?rev=32&view=rev
Author: jstuyts
Date: 2006-11-27 08:54:31 -0800 (Mon, 27 Nov 2006)
Log Message:
-----------
Formatted code.
Modified Paths:
--------------
trunk/source/java/net/sf/jcontracts/codeparser/Class.java
trunk/source/java/net/sf/jcontracts/codeparser/CodeComment.java
trunk/source/java/net/sf/jcontracts/codeparser/CodeMetaclass.java
trunk/source/java/net/sf/jcontracts/codeparser/CodeMetaclassCache.java
trunk/source/java/net/sf/jcontracts/codeparser/DebugVisitor.java
trunk/source/java/net/sf/jcontracts/codeparser/DottyVisitor.java
trunk/source/java/net/sf/jcontracts/codeparser/DottyVisitorConstants.java
trunk/source/java/net/sf/jcontracts/codeparser/Dotty_Component_CommonLevel.java
trunk/source/java/net/sf/jcontracts/codeparser/Dotty_Component_PackageLevel.java
trunk/source/java/net/sf/jcontracts/codeparser/Dotty_Component_TypeLevel.java
trunk/source/java/net/sf/jcontracts/codeparser/ExtendedToken.java
trunk/source/java/net/sf/jcontracts/codeparser/ICodeBody.java
trunk/source/java/net/sf/jcontracts/codeparser/ICodeMetaclassVisitor.java
trunk/source/java/net/sf/jcontracts/codeparser/IDependencyFilter.java
trunk/source/java/net/sf/jcontracts/codeparser/IDotty_Component_Level.java
trunk/source/java/net/sf/jcontracts/codeparser/Interface.java
trunk/source/java/net/sf/jcontracts/codeparser/JavaLexer.java
trunk/source/java/net/sf/jcontracts/codeparser/JavaParser.java
trunk/source/java/net/sf/jcontracts/codeparser/JavaTokenTypes.java
trunk/source/java/net/sf/jcontracts/codeparser/MetaclassFactory.java
trunk/source/java/net/sf/jcontracts/codeparser/Method.java
trunk/source/java/net/sf/jcontracts/codeparser/Parser.java
trunk/source/java/net/sf/jcontracts/codeparser/ParserMetaclassFactory.java
trunk/source/java/net/sf/jcontracts/codeparser/TypeMetaclass.java
trunk/source/java/net/sf/jcontracts/codeparser/Variable.java
Modified: trunk/source/java/net/sf/jcontracts/codeparser/Class.java
===================================================================
--- trunk/source/java/net/sf/jcontracts/codeparser/Class.java 2006-11-27 16:52:23 UTC (rev 31)
+++ trunk/source/java/net/sf/jcontracts/codeparser/Class.java 2006-11-27 16:54:31 UTC (rev 32)
@@ -2,59 +2,77 @@
import java.util.Enumeration;
-public class Class extends TypeMetaclass {
+public class Class extends TypeMetaclass
+{
- public Class(String name, String filename, int line_number) {
- super(name, filename, line_number);
- }
+ public Class(String name, String filename, int line_number)
+ {
+ super(name, filename, line_number);
+ }
- protected boolean containsConstructor() {
- for (Enumeration e = super._elements.elements(); e.hasMoreElements();) {
- CodeMetaclass element = (CodeMetaclass)e.nextElement();
- if (element.isConstructor()) {
- return true;
- }
- }
+ protected boolean containsConstructor()
+ {
+ for (Enumeration e = super._elements.elements(); e.hasMoreElements();)
+ {
+ CodeMetaclass element = (CodeMetaclass) e.nextElement();
+ if (element.isConstructor())
+ {
+ return true;
+ }
+ }
- return false;
- }
+ return false;
+ }
- protected boolean containsDefaultConstructor() {
- for (Enumeration e = super._elements.elements(); e.hasMoreElements();) {
- CodeMetaclass element = (CodeMetaclass)e.nextElement();
- if (element.isDefaultConstructor()) {
- return true;
- }
- }
+ protected boolean containsDefaultConstructor()
+ {
+ for (Enumeration e = super._elements.elements(); e.hasMoreElements();)
+ {
+ CodeMetaclass element = (CodeMetaclass) e.nextElement();
+ if (element.isDefaultConstructor())
+ {
+ return true;
+ }
+ }
- return false;
- }
+ return false;
+ }
- public String getSignature() {
- return getName();
- }
+ public String getSignature()
+ {
+ return getName();
+ }
- public String getType() {
- return getName();
- }
+ public String getType()
+ {
+ return getName();
+ }
- public boolean isAbstract() {
- return getModifiers().contains("abstract");
- }
+ public boolean isAbstract()
+ {
+ return getModifiers().contains("abstract");
+ }
- public String toString() {
- String s = getLocationDescription();
- if (!getModifiers().isEmpty()) {
- s = s + getClass().getName() + " " + getModifiers();
- } else {
- s = s + getClass().getName();
- }
- String b = "";
- if (getStartOfBody() != 0 && getEndOfBody() != 0) {
- b = ", body [" + getStartOfBody() + ".." + getEndOfBody() + "]";
- } else {
- b = ", no body";
- }
- return s + " " + getName() + ", " + getCodeComment() + b;
- }
+ public String toString()
+ {
+ String s = getLocationDescription();
+ if (!getModifiers().isEmpty())
+ {
+ s = s + getClass().getName() + " " + getModifiers();
+ }
+ else
+ {
+ s = s + getClass().getName();
+ }
+ String b = "";
+ if (getStartOfBody() != 0 && getEndOfBody() != 0)
+ {
+ b = ", body [" + getStartOfBody() + ".." + getEndOfBody() + "]";
+ }
+ else
+ {
+ b = ", no body";
+ }
+ return s + " " + getName() + ", " + getCodeComment() + b;
+ }
}
Modified: trunk/source/java/net/sf/jcontracts/codeparser/CodeComment.java
===================================================================
--- trunk/source/java/net/sf/jcontracts/codeparser/CodeComment.java 2006-11-27 16:52:23 UTC (rev 31)
+++ trunk/source/java/net/sf/jcontracts/codeparser/CodeComment.java 2006-11-27 16:54:31 UTC (rev 32)
@@ -5,75 +5,105 @@
import java.util.Hashtable;
import java.util.Vector;
-class CodeComment
- implements Serializable {
+class CodeComment implements Serializable
+{
- private String _title;
- private Hashtable _comment_tags;
- public static final String AUTHOR_TAG = "author";
- public static final String VERSION_TAG = "version";
- public static final String SEE_TAG = "see";
- public static final String PARAM_TAG = "param";
- public static final String RETURN_TAG = "return";
- public static final String EXCEPTION_TAG = "exception";
- public static final String PRECOND_TAG = "requires";
- public static final String POSTCOND_TAG = "ensures";
- public static final String INVARIANT_TAG = "invariant";
- public static final String OPEN_TAG = "open";
- public static final String KNOWN_TAGS[] = {
- "author", "version", "see", "param", "return", "exception", "requires", "ensures", "invariant", "open"
- };
+ private String _title;
- CodeComment() {
- _title = "";
- _comment_tags = new Hashtable();
- }
+ private Hashtable _comment_tags;
- void addTagEntry(String tag, String entry) {
- if (!_comment_tags.containsKey(tag)) {
- _comment_tags.put(tag, new Vector());
- }
- ((Vector)_comment_tags.get(tag)).addElement(entry);
- }
+ public static final String AUTHOR_TAG = "author";
- Vector getTagEntry(String tag) {
- if (!_comment_tags.containsKey(tag)) {
- return new Vector();
- } else {
- return (Vector)_comment_tags.get(tag);
- }
- }
+ public static final String VERSION_TAG = "version";
- Vector getTagNames() {
- Vector names = new Vector();
- String element;
- for (Enumeration e = _comment_tags.keys(); e.hasMoreElements(); names.addElement(element)) {
- element = (String)e.nextElement();
- }
+ public static final String SEE_TAG = "see";
- return names;
- }
+ public static final String PARAM_TAG = "param";
- String getTitle() {
- return _title;
- }
+ public static final String RETURN_TAG = "return";
- void setTitle(String title) {
- _title = title;
- }
+ public static final String EXCEPTION_TAG = "exception";
- public String toString() {
- if (_comment_tags.isEmpty() && _title.length() == 0) {
- return "empty code comment (no title, no tags)";
- }
- if (_comment_tags.isEmpty() && _title.length() != 0) {
- return "code comment: \"" + _title + "\", no tags ";
- }
- if (!_comment_tags.isEmpty() && _title.length() == 0) {
- return "code comment: no title, tags: " + _comment_tags;
- } else {
- return "code comment: \"" + _title + "\", tags: " + _comment_tags;
- }
- }
+ public static final String PRECOND_TAG = "requires";
+ public static final String POSTCOND_TAG = "ensures";
+
+ public static final String INVARIANT_TAG = "invariant";
+
+ public static final String OPEN_TAG = "open";
+
+ public static final String KNOWN_TAGS[] =
+ {
+ "author", "version", "see", "param", "return", "exception", "requires", "ensures", "invariant", "open"
+ };
+
+ CodeComment()
+ {
+ _title = "";
+ _comment_tags = new Hashtable();
+ }
+
+ void addTagEntry(String tag, String entry)
+ {
+ if (!_comment_tags.containsKey(tag))
+ {
+ _comment_tags.put(tag, new Vector());
+ }
+ ((Vector) _comment_tags.get(tag)).addElement(entry);
+ }
+
+ Vector getTagEntry(String tag)
+ {
+ if (!_comment_tags.containsKey(tag))
+ {
+ return new Vector();
+ }
+ else
+ {
+ return (Vector) _comment_tags.get(tag);
+ }
+ }
+
+ Vector getTagNames()
+ {
+ Vector names = new Vector();
+ String element;
+ for (Enumeration e = _comment_tags.keys(); e.hasMoreElements(); names.addElement(element))
+ {
+ element = (String) e.nextElement();
+ }
+
+ return names;
+ }
+
+ String getTitle()
+ {
+ return _title;
+ }
+
+ void setTitle(String title)
+ {
+ _title = title;
+ }
+
+ public String toString()
+ {
+ if (_comment_tags.isEmpty() && _title.length() == 0)
+ {
+ return "empty code comment (no title, no tags)";
+ }
+ if (_comment_tags.isEmpty() && _title.length() != 0)
+ {
+ return "code comment: \"" + _title + "\", no tags ";
+ }
+ if (!_comment_tags.isEmpty() && _title.length() == 0)
+ {
+ return "code comment: no title, tags: " + _comment_tags;
+ }
+ else
+ {
+ return "code comment: \"" + _title + "\", tags: " + _comment_tags;
+ }
+ }
+
}
Modified: trunk/source/java/net/sf/jcontracts/codeparser/CodeMetaclass.java
===================================================================
--- trunk/source/java/net/sf/jcontracts/codeparser/CodeMetaclass.java 2006-11-27 16:52:23 UTC (rev 31)
+++ trunk/source/java/net/sf/jcontracts/codeparser/CodeMetaclass.java 2006-11-27 16:54:31 UTC (rev 32)
@@ -3,162 +3,199 @@
import java.io.Serializable;
import java.util.Vector;
-public abstract class CodeMetaclass
- implements Serializable {
- class Name
- implements Serializable {
+public abstract class CodeMetaclass implements Serializable
+{
+ class Name implements Serializable
+ {
- private String n_;
+ private String n_;
- String asString() {
- return n_;
- }
+ String asString()
+ {
+ return n_;
+ }
- void setName(String n) {
- n_ = n;
- }
+ void setName(String n)
+ {
+ n_ = n;
+ }
- Name(String name) {
- n_ = name;
- }
- }
+ Name(String name)
+ {
+ n_ = name;
+ }
+ }
+ private Name _name;
- private Name _name;
- private int _line_number;
- private String _filename;
- private String _packagename;
- private CodeComment _cc;
- private Vector _modifiers;
- private CodeMetaclass _parent;
+ private int _line_number;
- protected CodeMetaclass(String name, String filename, int line_number) {
- _cc = new CodeComment();
- _modifiers = new Vector();
- _parent = null;
- _name = new Name(name);
- _filename = filename;
- _line_number = line_number;
- }
+ private String _filename;
- public void accept(ICodeMetaclassVisitor visitor) {
- visitor.accept(this);
- }
+ private String _packagename;
- protected CodeComment getCodeComment() {
- return _cc;
- }
+ private CodeComment _cc;
- public String getCodeCommentTitle() {
- return _cc.getTitle();
- }
+ private Vector _modifiers;
- public String getFilename() {
- return _filename;
- }
+ private CodeMetaclass _parent;
- public String getLocationDescription() {
- return protectString(_filename, '\\') + ":" + _line_number + ": ";
- }
+ protected CodeMetaclass(String name, String filename, int line_number)
+ {
+ _cc = new CodeComment();
+ _modifiers = new Vector();
+ _parent = null;
+ _name = new Name(name);
+ _filename = filename;
+ _line_number = line_number;
+ }
- Vector getModifiers() {
- return _modifiers;
- }
+ public void accept(ICodeMetaclassVisitor visitor)
+ {
+ visitor.accept(this);
+ }
- public String getName() {
- return _name.asString();
- }
+ protected CodeComment getCodeComment()
+ {
+ return _cc;
+ }
- public String getPackagename() {
- return _packagename;
- }
+ public String getCodeCommentTitle()
+ {
+ return _cc.getTitle();
+ }
- public CodeMetaclass getParent() {
- return _parent;
- }
+ public String getFilename()
+ {
+ return _filename;
+ }
- public abstract String getSignature();
+ public String getLocationDescription()
+ {
+ return protectString(_filename, '\\') + ":" + _line_number + ": ";
+ }
- public Vector getTagEntry(String tag) {
- return _cc.getTagEntry(tag);
- }
+ Vector getModifiers()
+ {
+ return _modifiers;
+ }
- public Vector getTagNames() {
- return _cc.getTagNames();
- }
+ public String getName()
+ {
+ return _name.asString();
+ }
- public abstract String getType();
+ public String getPackagename()
+ {
+ return _packagename;
+ }
- public boolean isConstructor() {
- return false;
- }
+ public CodeMetaclass getParent()
+ {
+ return _parent;
+ }
- public boolean isDefaultConstructor() {
- return false;
- }
+ public abstract String getSignature();
- public boolean isPrivate() {
- return getModifiers().contains("private");
- }
+ public Vector getTagEntry(String tag)
+ {
+ return _cc.getTagEntry(tag);
+ }
- public boolean isProtected() {
- return getModifiers().contains("protected");
- }
+ public Vector getTagNames()
+ {
+ return _cc.getTagNames();
+ }
- public boolean isPublic() {
- return getModifiers().contains("public");
- }
+ public abstract String getType();
- public boolean isStatic() {
- return getModifiers().contains("static");
- }
+ public boolean isConstructor()
+ {
+ return false;
+ }
- String protectString(String str, char key) {
- if (str.length() == 0) {
- return str;
- }
- if (str.indexOf(key) == -1) {
- return str;
- }
- StringBuffer buf = new StringBuffer();
- int last;
- int j;
- for (last = 0; (j = str.indexOf(key, last)) != -1; last = j + 1) {
- for (int i = last; i < str.indexOf(key, last); i++) {
- buf.append(str.charAt(i));
- }
+ public boolean isDefaultConstructor()
+ {
+ return false;
+ }
- buf.append("\\");
- buf.append(key);
- }
+ public boolean isPrivate()
+ {
+ return getModifiers().contains("private");
+ }
- buf.append(str.substring(last, str.length()));
- return buf.toString();
- }
+ public boolean isProtected()
+ {
+ return getModifiers().contains("protected");
+ }
- void setCodeComment(CodeComment cc) {
- _cc = cc;
- }
+ public boolean isPublic()
+ {
+ return getModifiers().contains("public");
+ }
- void setModifiers(Vector modifiers) {
- _modifiers = modifiers;
- }
+ public boolean isStatic()
+ {
+ return getModifiers().contains("static");
+ }
- public void setName(String name) {
- _name.setName(name);
- }
+ String protectString(String str, char key)
+ {
+ if (str.length() == 0)
+ {
+ return str;
+ }
+ if (str.indexOf(key) == -1)
+ {
+ return str;
+ }
+ StringBuffer buf = new StringBuffer();
+ int last;
+ int j;
+ for (last = 0; (j = str.indexOf(key, last)) != -1; last = j + 1)
+ {
+ for (int i = last; i < str.indexOf(key, last); i++)
+ {
+ buf.append(str.charAt(i));
+ }
- public void setPackagename(String name) {
- _packagename = name;
- }
+ buf.append("\\");
+ buf.append(key);
+ }
- public void setParent(CodeMetaclass parent) {
- _parent = parent;
- }
+ buf.append(str.substring(last, str.length()));
+ return buf.toString();
+ }
- public String toShortDescription() {
- String s = getClass().getName();
- s = s + " " + getName();
- return s;
- }
+ void setCodeComment(CodeComment cc)
+ {
+ _cc = cc;
+ }
+
+ void setModifiers(Vector modifiers)
+ {
+ _modifiers = modifiers;
+ }
+
+ public void setName(String name)
+ {
+ _name.setName(name);
+ }
+
+ public void setPackagename(String name)
+ {
+ _packagename = name;
+ }
+
+ public void setParent(CodeMetaclass parent)
+ {
+ _parent = parent;
+ }
+
+ public String toShortDescription()
+ {
+ String s = getClass().getName();
+ s = s + " " + getName();
+ return s;
+ }
}
Modified: trunk/source/java/net/sf/jcontracts/codeparser/CodeMetaclassCache.java
===================================================================
--- trunk/source/java/net/sf/jcontracts/codeparser/CodeMetaclassCache.java 2006-11-27 16:52:23 UTC (rev 31)
+++ trunk/source/java/net/sf/jcontracts/codeparser/CodeMetaclassCache.java 2006-11-27 16:54:31 UTC (rev 32)
@@ -13,37 +13,45 @@
import antlr.ParserException;
-public class CodeMetaclassCache {
-
+public class CodeMetaclassCache
+{
+
private static final String base;
-
- public Vector getAnnotations(Vector allFilenames, Vector outdatedFilenames, String srcbase)
- throws IOException, ParserException, ClassNotFoundException {
+
+ public Vector getAnnotations(Vector allFilenames, Vector outdatedFilenames, String srcbase) throws IOException,
+ ParserException, ClassNotFoundException
+ {
File t_dir = new File(base);
- if (!t_dir.exists()) {
+ if (!t_dir.exists())
+ {
t_dir.mkdirs();
}
long start = System.currentTimeMillis();
- Vector noUpdate = (Vector)allFilenames.clone();
- for (Enumeration e = allFilenames.elements(); e.hasMoreElements();) {
- String fn = (String)e.nextElement();
- if (outdatedFilenames.contains(fn)) {
+ Vector noUpdate = (Vector) allFilenames.clone();
+ for (Enumeration e = allFilenames.elements(); e.hasMoreElements();)
+ {
+ String fn = (String) e.nextElement();
+ if (outdatedFilenames.contains(fn))
+ {
noUpdate.removeElement(fn);
}
}
-
- Vector recache = (Vector)outdatedFilenames.clone();
- for (Enumeration e = noUpdate.elements(); e.hasMoreElements();) {
- String fn = (String)e.nextElement();
+
+ Vector recache = (Vector) outdatedFilenames.clone();
+ for (Enumeration e = noUpdate.elements(); e.hasMoreElements();)
+ {
+ String fn = (String) e.nextElement();
File f = new File(getCacheFilenameFor(fn));
- if (!f.exists()) {
+ if (!f.exists())
+ {
recache.addElement(fn);
}
}
-
+
Vector result = new Vector(allFilenames.size() * 20);
- for (Enumeration e = recache.elements(); e.hasMoreElements();) {
- String fn = (String)e.nextElement();
+ for (Enumeration e = recache.elements(); e.hasMoreElements();)
+ {
+ String fn = (String) e.nextElement();
FileInputStream is = new FileInputStream(srcbase + fn);
System.err.println("Upating cache entry for: " + fn.replace(File.separatorChar, '.'));
Parser parser = new Parser(is, fn);
@@ -53,32 +61,43 @@
Vector annotations = parser.getAnnotations();
OutputStream os = new FileOutputStream(new File(getCacheFilenameFor(fn)));
ObjectOutputStream cmos = new ObjectOutputStream(os);
- try {
+ try
+ {
cmos.writeObject(annotations);
- } finally {
+ }
+ finally
+ {
os.close();
}
}
-
- for (Enumeration e = allFilenames.elements(); e.hasMoreElements();) {
- String fn = (String)e.nextElement();
+
+ for (Enumeration e = allFilenames.elements(); e.hasMoreElements();)
+ {
+ String fn = (String) e.nextElement();
InputStream is = new FileInputStream(new File(getCacheFilenameFor(fn)));
ObjectInputStream cmis = new ObjectInputStream(is);
- try {
- Vector ann = (Vector)cmis.readObject();
+ try
+ {
+ Vector ann = (Vector) cmis.readObject();
System.err.print("+");
- for (Enumeration e2 = ann.elements(); e2.hasMoreElements(); result.addElement(e2.nextElement())) { }
- } finally {
+ for (Enumeration e2 = ann.elements(); e2.hasMoreElements(); result.addElement(e2.nextElement()))
+ {
+ }
+ }
+ finally
+ {
is.close();
}
}
-
+
long end = System.currentTimeMillis();
- System.err.println("\nFound " + result.size() + " elements in " + allFilenames.size() + " files (took " + (double)(end - start) / 1000D + "s).");
+ System.err.println("\nFound " + result.size() + " elements in " + allFilenames.size() + " files (took "
+ + (double) (end - start) / 1000D + "s).");
return result;
}
-
- private String getCacheFilenameFor(String fn) {
+
+ private String getCacheFilenameFor(String fn)
+ {
String result = fn;
result = result.replace(':', '_');
result = result.replace('/', '_');
@@ -86,11 +105,13 @@
result = result.replace('.', '-');
return base + result + ".idarwin";
}
-
- public CodeMetaclassCache() {
+
+ public CodeMetaclassCache()
+ {
}
-
- static {
+
+ static
+ {
base = "." + File.separatorChar + "darwin-data" + File.separatorChar + "cache" + File.separatorChar;
}
}
Modified: trunk/source/java/net/sf/jcontracts/codeparser/DebugVisitor.java
===================================================================
--- trunk/source/java/net/sf/jcontracts/codeparser/DebugVisitor.java 2006-11-27 16:52:23 UTC (rev 31)
+++ trunk/source/java/net/sf/jcontracts/codeparser/DebugVisitor.java 2006-11-27 16:54:31 UTC (rev 32)
@@ -1,33 +1,37 @@
package net.sf.jcontracts.codeparser;
+public class DebugVisitor implements ICodeMetaclassVisitor
+{
-public class DebugVisitor
- implements ICodeMetaclassVisitor {
+ public void accept(CodeMetaclass codemetaclass)
+ {
+ }
- public void accept(CodeMetaclass codemetaclass) {
- }
+ public void acceptMethod(CodeMetaclass item)
+ {
+ System.out.println("#### METHOD ####");
+ System.out.println("PARENT=\n" + item.getParent());
+ System.out.println("ITEM=\n" + item);
+ System.out.println();
+ }
- public void acceptMethod(CodeMetaclass item) {
- System.out.println("#### METHOD ####");
- System.out.println("PARENT=\n" + item.getParent());
- System.out.println("ITEM=\n" + item);
- System.out.println();
- }
+ public void acceptTypeMetaclass(CodeMetaclass item)
+ {
+ System.out.println("#### TYPE ####");
+ System.out.println("PARENT=\n" + item.getParent());
+ System.out.println("ITEM=\n" + item);
+ System.out.println();
+ }
- public void acceptTypeMetaclass(CodeMetaclass item) {
- System.out.println("#### TYPE ####");
- System.out.println("PARENT=\n" + item.getParent());
- System.out.println("ITEM=\n" + item);
- System.out.println();
- }
+ public void acceptVariable(CodeMetaclass item)
+ {
+ System.out.println("#### VARIABLE ####");
+ System.out.println("PARENT=\n" + item.getParent());
+ System.out.println("ITEM=\n" + item);
+ System.out.println();
+ }
- public void acceptVariable(CodeMetaclass item) {
- System.out.println("#### VARIABLE ####");
- System.out.println("PARENT=\n" + item.getParent());
- System.out.println("ITEM=\n" + item);
- System.out.println();
- }
-
- public DebugVisitor() {
- }
+ public DebugVisitor()
+ {
+ }
}
Modified: trunk/source/java/net/sf/jcontracts/codeparser/DottyVisitor.java
===================================================================
--- trunk/source/java/net/sf/jcontracts/codeparser/DottyVisitor.java 2006-11-27 16:52:23 UTC (rev 31)
+++ trunk/source/java/net/sf/jcontracts/codeparser/DottyVisitor.java 2006-11-27 16:54:31 UTC (rev 32)
@@ -8,160 +8,215 @@
import net.sf.jcontracts.idarwin.specification.openapi.IArchitectureExporter;
import net.sf.jcontracts.idarwin.specification.openapi.IArchitectureSpecification;
-public class DottyVisitor
- implements ICodeMetaclassVisitor {
+public class DottyVisitor implements ICodeMetaclassVisitor
+{
- private PrintWriter ostream;
- public static final int TYPE_DETAIL_LEVEL = 2;
- public static final int PACKAGE_DETAIL_LEVEL = 1;
- private IDotty_Component_Level component;
- private boolean layoutLR;
- private boolean directed;
- private int cluster_index;
- private boolean boxPackages;
- private boolean do_not_show_dependecy_details;
- private IArchitectureSpecification specification;
- private IDependencyFilter filter;
- private Vector unusedConstraints;
+ private PrintWriter ostream;
- public DottyVisitor(IArchitectureSpecification spec, String filename, String title, boolean layoutLR, boolean directed, int componentVisitorDetailLevel, boolean showPackages,
- Vector quietList, boolean check, boolean do_not_show_dependecy_details, IDependencyFilter filter) throws IOException {
- ostream = null;
- this.layoutLR = false;
- this.directed = true;
- cluster_index = 1;
- specification = null;
- this.filter = null;
- unusedConstraints = new Vector();
- specification = spec;
- if (componentVisitorDetailLevel == 2) {
- component = new Dotty_Component_TypeLevel(filter, check);
- }
- if (componentVisitorDetailLevel == 1) {
- component = new Dotty_Component_PackageLevel(filter, check);
- }
- this.directed = directed;
- boxPackages = showPackages;
- this.layoutLR = layoutLR;
- this.do_not_show_dependecy_details = do_not_show_dependecy_details;
- this.filter = filter;
- ostream = new PrintWriter(new FileOutputStream(filename));
- if (filter == null) {
- writeHeader(ostream, title);
- } else {
- filter.writeHeader(ostream, title);
- }
- component.setIgnoranceList(quietList);
- }
+ public static final int TYPE_DETAIL_LEVEL = 2;
- public void accept(CodeMetaclass codemetaclass) {
- }
+ public static final int PACKAGE_DETAIL_LEVEL = 1;
- public void acceptMethod(CodeMetaclass item) {
- component.acceptMethod(item, ostream, directed, specification, do_not_show_dependecy_details);
- }
+ private IDotty_Component_Level component;
- public void acceptTypeMetaclass(CodeMetaclass item) {
- component.acceptTypeMetaclass(item, ostream, directed, specification, do_not_show_dependecy_details);
- }
+ private boolean layoutLR;
- public void acceptVariable(CodeMetaclass item) {
- component.acceptVariable(item, ostream, directed, specification, do_not_show_dependecy_details);
- }
+ private boolean directed;
- public void close() {
- if (filter == null) {
- component.createErrorLinks(directed, ostream);
- ostream.println("\n}");
- } else {
- filter.writeTrailer(ostream);
- }
- ostream.close();
- }
+ private int cluster_index;
- public void endSubGraph(String label) {
- if (boxPackages) {
- ostream.println("label=\"" + label + "\";");
- ostream.println("}");
- }
- }
+ private boolean boxPackages;
- public void export(String filename) {
- IArchitectureExporter exporter = null;
- try {
- exporter = specification.newArchitectureExporter(filename);
- if (exporter == null) {
- throw new RuntimeException("iDarwin: error no exporter implemented for this specification language.");
- }
- }
- catch (IOException e) {
- throw new RuntimeException("iDarwin: error could not open " + filename + " to export specification (" + e + ").", e);
- }
- try {
- exporter.open();
- exporter.export(specification);
- }
- catch (IOException e) {
- throw new RuntimeException("iDarwin: error during specification export to " + filename + " (" + e + ").", e);
- }
- finally {
- if (exporter != null) {
- try {
- exporter.close();
+ private boolean do_not_show_dependecy_details;
+
+ private IArchitectureSpecification specification;
+
+ private IDependencyFilter filter;
+
+ private Vector unusedConstraints;
+
+ public DottyVisitor(IArchitectureSpecification spec, String filename, String title, boolean layoutLR,
+ boolean directed, int componentVisitorDetailLevel, boolean showPackages, Vector quietList, boolean check,
+ boolean do_not_show_dependecy_details, IDependencyFilter filter) throws IOException
+ {
+ ostream = null;
+ this.layoutLR = false;
+ this.directed = true;
+ cluster_index = 1;
+ specification = null;
+ this.filter = null;
+ unusedConstraints = new Vector();
+ specification = spec;
+ if (componentVisitorDetailLevel == 2)
+ {
+ component = new Dotty_Component_TypeLevel(filter, check);
+ }
+ if (componentVisitorDetailLevel == 1)
+ {
+ component = new Dotty_Component_PackageLevel(filter, check);
+ }
+ this.directed = directed;
+ boxPackages = showPackages;
+ this.layoutLR = layoutLR;
+ this.do_not_show_dependecy_details = do_not_show_dependecy_details;
+ this.filter = filter;
+ ostream = new PrintWriter(new FileOutputStream(filename));
+ if (filter == null)
+ {
+ writeHeader(ostream, title);
+ }
+ else
+ {
+ filter.writeHeader(ostream, title);
+ }
+ component.setIgnoranceList(quietList);
+ }
+
+ public void accept(CodeMetaclass codemetaclass)
+ {
+ }
+
+ public void acceptMethod(CodeMetaclass item)
+ {
+ component.acceptMethod(item, ostream, directed, specification, do_not_show_dependecy_details);
+ }
+
+ public void acceptTypeMetaclass(CodeMetaclass item)
+ {
+ component.acceptTypeMetaclass(item, ostream, directed, specification, do_not_show_dependecy_details);
+ }
+
+ public void acceptVariable(CodeMetaclass item)
+ {
+ component.acceptVariable(item, ostream, directed, specification, do_not_show_dependecy_details);
+ }
+
+ public void close()
+ {
+ if (filter == null)
+ {
+ component.createErrorLinks(directed, ostream);
+ ostream.println("\n}");
+ }
+ else
+ {
+ filter.writeTrailer(ostream);
+ }
+ ostream.close();
+ }
+
+ public void endSubGraph(String label)
+ {
+ if (boxPackages)
+ {
+ ostream.println("label=\"" + label + "\";");
+ ostream.println("}");
+ }
+ }
+
+ public void export(String filename)
+ {
+ IArchitectureExporter exporter = null;
+ try
+ {
+ exporter = specification.newArchitectureExporter(filename);
+ if (exporter == null)
+ {
+ throw new RuntimeException("iDarwin: error no exporter implemented for this specification language.");
}
- catch (IOException e) {
- throw new RuntimeException("iDarwin: error attempt to close open stream " + filename + " failed (" + e + ").", e);
+ }
+ catch (IOException e)
+ {
+ throw new RuntimeException("iDarwin: error could not open " + filename + " to export specification (" + e
+ + ").", e);
+ }
+ try
+ {
+ exporter.open();
+ exporter.export(specification);
+ }
+ catch (IOException e)
+ {
+ throw new RuntimeException("iDarwin: error during specification export to " + filename + " (" + e + ").", e);
+ }
+ finally
+ {
+ if (exporter != null)
+ {
+ try
+ {
+ exporter.close();
+ }
+ catch (IOException e)
+ {
+ throw new RuntimeException("iDarwin: error attempt to close open stream " + filename + " failed ("
+ + e + ").", e);
+ }
}
- }
- }
- }
+ }
+ }
- public boolean getError() {
- return component.getError();
- }
+ public boolean getError()
+ {
+ return component.getError();
+ }
- public int getNumberOfErrors() {
- return component.getNumberOfErrors();
- }
+ public int getNumberOfErrors()
+ {
+ return component.getNumberOfErrors();
+ }
- public int getNumberOfLinks() {
- return component.getNumberOfLinks();
- }
+ public int getNumberOfLinks()
+ {
+ return component.getNumberOfLinks();
+ }
- public void startSubGraph() {
- if (boxPackages) {
- ostream.println("subgraph cluster_" + cluster_index + " {");
- ostream.println("color=orange;");
- ostream.println("fontname=Helvetica;");
- ostream.println("fontsize=16;");
- cluster_index++;
- }
- }
+ public void startSubGraph()
+ {
+ if (boxPackages)
+ {
+ ostream.println("subgraph cluster_" + cluster_index + " {");
+ ostream.println("color=orange;");
+ ostream.println("fontname=Helvetica;");
+ ostream.println("fontsize=16;");
+ cluster_index++;
+ }
+ }
- public void writeHeader(PrintWriter ostream, String title) throws IOException {
- if (directed) {
- ostream.println("digraph \"" + title + "\" {");
- } else {
- ostream.println("graph \"" + title + "\" {");
- }
- ostream.println("fontsize=" + DottyVisitorConstants.fontSize() + ";");
- ostream.println("fontname=\"" + DottyVisitorConstants.fontName() + "\"");
- if (layoutLR) {
- ostream.println("rankdir=LR;");
- }
- }
+ public void writeHeader(PrintWriter ostream, String title) throws IOException
+ {
+ if (directed)
+ {
+ ostream.println("digraph \"" + title + "\" {");
+ }
+ else
+ {
+ ostream.println("graph \"" + title + "\" {");
+ }
+ ostream.println("fontsize=" + DottyVisitorConstants.fontSize() + ";");
+ ostream.println("fontname=\"" + DottyVisitorConstants.fontName() + "\"");
+ if (layoutLR)
+ {
+ ostream.println("rankdir=LR;");
+ }
+ }
- public void writeHeader(String filename, String title) throws IOException {
- ostream = new PrintWriter(new FileOutputStream(filename));
- if (directed) {
- ostream.println("digraph \"" + title + "\" {");
- } else {
- ostream.println("graph \"" + title + "\" {");
- }
- ostream.println("fontsize=" + DottyVisitorConstants.fontSize() + ";");
- ostream.println("fontname=\"" + DottyVisitorConstants.fontName() + "\"");
- if (layoutLR) {
- ostream.println("rankdir=LR;");
- }
- }
+ public void writeHeader(String filename, String title) throws IOException
+ {
+ ostream = new PrintWriter(new FileOutputStream(filename));
+ if (directed)
+ {
+ ostream.println("digraph \"" + title + "\" {");
+ }
+ else
+ {
+ ostream.println("graph \"" + title + "\" {");
+ }
+ ostream.println("fontsize=" + DottyVisitorConstants.fontSize() + ";");
+ ostream.println("fontname=\"" + DottyVisitorConstants.fontName() + "\"");
+ if (layoutLR)
+ {
+ ostream.println("rankdir=LR;");
+ }
+ }
}
Modified: trunk/source/java/net/sf/jcontracts/codeparser/DottyVisitorConstants.java
===================================================================
--- trunk/source/java/net/sf/jcontracts/codeparser/DottyVisitorConstants.java 2006-11-27 16:52:23 UTC (rev 31)
+++ trunk/source/java/net/sf/jcontracts/codeparser/DottyVisitorConstants.java 2006-11-27 16:54:31 UTC (rev 32)
@@ -1,60 +1,80 @@
package net.sf.jcontracts.codeparser;
+public class DottyVisitorConstants
+{
-public class DottyVisitorConstants {
+ public static int FONT_SIZE = 12;
- public static int FONT_SIZE = 12;
- public static int EDGE_LENGTH = 4;
- public static String FONT_NAME = "Helvetica";
- public static final String DEFAULT_PACKAGE = "PACKAGE_DEFAULT";
+ public static int EDGE_LENGTH = 4;
- public static String edgeLengthCommand(boolean directed) {
- String result = null;
- if (directed) {
- result = "minlen=" + getEdgeLength() + ",";
- } else {
- result = "len=" + getEdgeLength() + ",";
- }
- return result;
- }
+ public static String FONT_NAME = "Helvetica";
- public static String extractPackage(String type) {
- String result = null;
- char tag = '.';
- if (type.indexOf('$') > type.indexOf('.')) {
- tag = '$';
- }
- if (type.indexOf(tag) == -1) {
- result = "PACKAGE_DEFAULT";
- } else {
- result = type.substring(0, type.lastIndexOf(tag));
- }
- return result;
- }
+ public static final String DEFAULT_PACKAGE = "PACKAGE_DEFAULT";
- public static String fontName() {
- return FONT_NAME;
- }
+ public static String edgeLengthCommand(boolean directed)
+ {
+ String result = null;
+ if (directed)
+ {
+ result = "minlen=" + getEdgeLength() + ",";
+ }
+ else
+ {
+ result = "len=" + getEdgeLength() + ",";
+ }
+ return result;
+ }
- public static int fontSize() {
- return FONT_SIZE;
- }
+ public static String extractPackage(String type)
+ {
+ String result = null;
+ char tag = '.';
+ if (type.indexOf('$') > type.indexOf('.'))
+ {
+ tag = '$';
+ }
+ if (type.indexOf(tag) == -1)
+ {
+ result = "PACKAGE_DEFAULT";
+ }
+ else
+ {
+ result = type.substring(0, type.lastIndexOf(tag));
+ }
+ return result;
+ }
- public static int getEdgeLength() {
- return EDGE_LENGTH;
- }
+ public static String fontName()
+ {
+ return FONT_NAME;
+ }
- public static String linkSymbol(boolean directed) {
- String result = null;
- if (directed) {
- result = " -> ";
- } else {
- result = " -- ";
- }
- return result;
- }
+ public static int fontSize()
+ {
+ return FONT_SIZE;
+ }
- public DottyVisitorConstants() {
- }
+ public static int getEdgeLength()
+ {
+ return EDGE_LENGTH;
+ }
+ public static String linkSymbol(boolean directed)
+ {
+ String result = null;
+ if (directed)
+ {
+ result = " -> ";
+ }
+ else
+ {
+ result = " -- ";
+ }
+ return result;
+ }
+
+ public DottyVisitorConstants()
+ {
+ }
+
}
Modified: trunk/source/java/net/sf/jcontracts/codeparser/Dotty_Component_CommonLevel.java
===================================================================
--- trunk/source/java/net/sf/jcontracts/codeparser/Dotty_Component_CommonLevel.java 2006-11-27 16:52:23 UTC (rev 31)
+++ trunk/source/java/net/sf/jcontracts/codeparser/Dotty_Component_CommonLevel.java 2006-11-27 16:54:31 UTC (rev 32)
@@ -8,350 +8,473 @@
import net.sf.jcontracts.icontract.QuietOption;
import net.sf.jcontracts.idarwin.specification.openapi.IArchitectureSpecification;
-public class Dotty_Component_CommonLevel {
+public class Dotty_Component_CommonLevel
+{
- protected Vector previouslyCheckedlinks;
- protected Vector previouslyDisplayedlinks;
- protected Hashtable errorBook;
- protected boolean hideAllButPublic;
- protected boolean performChecks;
- protected static final int BELONGS_TO = 0;
- public static final int INTERFACE_EXTENSION = 1;
- public static final int CLASS_EXTENSION = 2;
- public static final int INTERFACE_IMPLEMENTATION = 3;
- public static final int RETURN = 4;
- public static final int PARAMETER = 5;
- public static final int VARIABLE = 6;
- public static final int NEWED = 7;
- public static final int LOCALVAR = 8;
- protected IDependencyFilter filter;
- public static final int STATICREF = 9;
- public static final int CAST = 10;
- private String colorLUT[] = {
- "gray", "black", "black", "black", "blue", "blue", "yellow", "green", "pink", "cyan",
- "orange"
- };
- public String relationNameLUT[] = {
- "belongs-to", "extends", "extends", "implements", "return", "parameter", "variable", "new", "local-var", "static",
- "cast"
- };
- public static Vector ignore = new Vector();
- private boolean containsErrors;
- private int numberofErrors;
- private int errorID;
- private int numberNumberOfLink;
+ protected Vector previouslyCheckedlinks;
- public void addDependency(String source_item, String target_item, int relationType, PrintWriter ostream, boolean directed, String extra, IArchitectureSpecification specification,
- CodeMetaclass item, boolean do_not_show_dependecy_details) {
- if (filter == null) {
- localAddDependency(source_item, target_item, relationType, ostream, directed, extra, specification, item, do_not_show_dependecy_details);
- } else {
- filter.addDependency(source_item, target_item, relationType, ostream, directed, extra, specification, item, do_not_show_dependecy_details);
- }
- }
+ protected Vector previouslyDisplayedlinks;
- protected void addPackage(PrintWriter ostream, CodeMetaclass item) {
- if (filter == null) {
- localAddPackage(ostream, item);
- } else {
- filter.addPackage(ostream, item);
- }
- }
+ protected Hashtable errorBook;
- protected void addType(PrintWriter ostream, CodeMetaclass item) {
- if (filter == null) {
- localAddType(ostream, item);
- } else {
- filter.addType(ostream, item);
- }
- }
+ protected boolean hideAllButPublic;
- private final boolean atomicMatch(String item, String pattern) {
- boolean result = false;
- if (item.equals(pattern)) {
- result = true;
- } else
- if (pattern.equals("*")) {
- result = true;
- } else {
- int starPos = -1;
- if ((starPos = pattern.indexOf('*')) != -1) {
- if (pattern.endsWith("*") && pattern.startsWith("*")) {
- String subsection = pattern.substring(1, pattern.length() - 1);
- result = item.indexOf(subsection) != -1;
- } else
- if (pattern.endsWith("*")) {
- String b = pattern.substring(0, starPos);
- result = item.startsWith(b);
- } else
- if (pattern.startsWith("*")) {
- String e = pattern.substring(starPos + 1, pattern.length());
- result = item.endsWith(e);
- } else {
- pattern.substring(0, starPos);
- String e = pattern.substring(starPos + 1, pattern.length());
- result = item.startsWith(e) && item.endsWith(e);
+ protected boolean performChecks;
+
+ protected static final int BELONGS_TO = 0;
+
+ public static final int INTERFACE_EXTENSION = 1;
+
+ public static final int CLASS_EXTENSION = 2;
+
+ public static final int INTERFACE_IMPLEMENTATION = 3;
+
+ public static final int RETURN = 4;
+
+ public static final int PARAMETER = 5;
+
+ public static final int VARIABLE = 6;
+
+ public static final int NEWED = 7;
+
+ public static final int LOCALVAR = 8;
+
+ protected IDependencyFilter filter;
+
+ public static final int STATICREF = 9;
+
+ public static final int CAST = 10;
+
+ private String colorLUT[] =
+ {
+ "gray", "black", "black", "black", "blue", "blue", "yellow", "green", "pink", "cyan", "orange"
+ };
+
+ public String relationNameLUT[] =
+ {
+ "belongs-to", "extends", "extends", "implements", "return", "parameter", "variable", "new", "local-var",
+ "static", "cast"
+ };
+
+ public static Vector ignore = new Vector();
+
+ private boolean containsErrors;
+
+ private int numberofErrors;
+
+ private int errorID;
+
+ private int numberNumberOfLink;
+
+ public void addDependency(String source_item, String target_item, int relationType, PrintWriter ostream,
+ boolean directed, String extra, IArchitectureSpecification specification, CodeMetaclass item,
+ boolean do_not_show_dependecy_details)
+ {
+ if (filter == null)
+ {
+ localAddDependency(source_item, target_item, relationType, ostream, directed, extra, specification, item,
+ do_not_show_dependecy_details);
+ }
+ else
+ {
+ filter.addDependency(source_item, target_item, relationType, ostream, directed, extra, specification, item,
+ do_not_show_dependecy_details);
+ }
+ }
+
+ protected void addPackage(PrintWriter ostream, CodeMetaclass item)
+ {
+ if (filter == null)
+ {
+ localAddPackage(ostream, item);
+ }
+ else
+ {
+ filter.addPackage(ostream, item);
+ }
+ }
+
+ protected void addType(PrintWriter ostream, CodeMetaclass item)
+ {
+ if (filter == null)
+ {
+ localAddType(ostream, item);
+ }
+ else
+ {
+ filter.addType(ostream, item);
+ }
+ }
+
+ private final boolean atomicMatch(String item, String pattern)
+ {
+ boolean result = false;
+ if (item.equals(pattern))
+ {
+ result = true;
+ }
+ else if (pattern.equals("*"))
+ {
+ result = true;
+ }
+ else
+ {
+ int starPos = -1;
+ if ((starPos = pattern.indexOf('*')) != -1)
+ {
+ if (pattern.endsWith("*") && pattern.startsWith("*"))
+ {
+ String subsection = pattern.substring(1, pattern.length() - 1);
+ result = item.indexOf(subsection) != -1;
+ }
+ else if (pattern.endsWith("*"))
+ {
+ String b = pattern.substring(0, starPos);
+ result = item.startsWith(b);
+ }
+ else if (pattern.startsWith("*"))
+ {
+ String e = pattern.substring(starPos + 1, pattern.length());
+ result = item.endsWith(e);
+ }
+ else
+ {
+ pattern.substring(0, starPos);
+ String e = pattern.substring(starPos + 1, pattern.length());
+ result = item.startsWith(e) && item.endsWith(e);
+ }
}
- }
- }
- QuietOption _tmp = QuietOption.theQuietOption;
- return result;
- }
+ }
+ QuietOption _tmp = QuietOption.theQuietOption;
+ return result;
+ }
- public void createErrorLinks(boolean directed, PrintWriter ostream) {
- String ms;
- String mt;
- int fontSize;
- String fontName;
- String edgeLengthCommand;
- String linkSymbol;
- String color;
- String extra;
- for (Enumeration e = errorBook.keys(); e.hasMoreElements(); ostream.println(ms + linkSymbol + mt + " [" + edgeLengthCommand + extra + "color=" + color + ",fontsize=" + fontSize + ",fontname=\"" + fontName + "\",style=bold,fontcolor=red];")) {
- String key = (String)e.nextElement();
- Object o[] = (Object[])errorBook.get(key);
- String label = (String)o[1];
- int num = 0;
- for (int pos = 0; (pos = label.indexOf("\\n", pos + 1)) != -1;) {
+ public void createErrorLinks(boolean directed, PrintWriter ostream)
+ {
+ String ms;
+ String mt;
+ int fontSize;
+ String fontName;
+ String edgeLengthCommand;
+ String linkSymbol;
+ String color;
+ String extra;
+ for (Enumeration e = errorBook.keys(); e.hasMoreElements(); ostream.println(ms + linkSymbol + mt + " ["
+ + edgeLengthCommand + extra + "color=" + color + ",fontsize=" + fontSize + ",fontname=\"" + fontName
+ + "\",style=bold,fontcolor=red];"))
+ {
+ String key = (String) e.nextElement();
+ Object o[] = (Object[]) errorBook.get(key);
+ String label = (String) o[1];
+ int num = 0;
+ for (int pos = 0; (pos = label.indexOf("\\n", pos + 1)) != -1;)
+ {
+ num++;
+ }
+
num++;
- }
+ String s = key.substring(0, key.indexOf("&"));
+ String t = key.substring(key.indexOf("&") + 1, key.lastIndexOf("&"));
+ ms = mangle(s);
+ mt = mangle(t);
+ fontSize = DottyVisitorConstants.fontSize();
+ fontName = DottyVisitorConstants.fontName();
+ edgeLengthCommand = DottyVisitorConstants.edgeLengthCommand(directed);
+ linkSymbol = DottyVisitorConstants.linkSymbol(directed);
+ color = "red";
+ extra = "label=\"" + num;
+ if (num > 1)
+ {
+ extra = extra + " errors:\\n";
+ }
+ else
+ {
+ extra = extra + " error:\\n";
+ }
+ extra = extra + label + "\"";
+ }
- num++;
- String s = key.substring(0, key.indexOf("&"));
- String t = key.substring(key.indexOf("&") + 1, key.lastIndexOf("&"));
- ms = mangle(s);
- mt = mangle(t);
- fontSize = DottyVisitorConstants.fontSize();
- fontName = DottyVisitorConstants.fontName();
- edgeLengthCommand = DottyVisitorConstants.edgeLengthCommand(directed);
- linkSymbol = DottyVisitorConstants.linkSymbol(directed);
- color = "red";
- extra = "label=\"" + num;
- if (num > 1) {
- extra = extra + " errors:\\n";
- } else {
- extra = extra + " error:\\n";
- }
- extra = extra + label + "\"";
- }
+ }
- }
+ public boolean getError()
+ {
+ return containsErrors;
+ }
- public boolean getError() {
- return containsErrors;
- }
+ protected String getErrorTextForDisplay(String source, String target, String type, String rule)
+ {
+ return "label=\"" + type + " VIOLATES\\n" + rule + "\",style=bold,fontcolor=red,";
+ }
- protected String getErrorTextForDisplay(String source, String target, String type, String rule) {
- return "label=\"" + type + " VIOLATES\\n" + rule + "\",style=bold,fontcolor=red,";
- }
+ public int getNumberOfErrors()
+ {
+ return numberofErrors;
+ }
- public int getNumberOfErrors() {
- return numberofErrors;
- }
+ public int getNumberOfLinks()
+ {
+ return numberNumberOfLink;
+ }
- public int getNumberOfLinks() {
- return numberNumberOfLink;
- }
+ protected String getVisibilityColorCode(CodeMetaclass item)
+ {
+ String color = "yellow";
+ if (item.isPublic())
+ {
+ color = "green";
+ }
+ if (item.isPrivate())
+ {
+ color = "gray";
+ }
+ if (item.isProtected())
+ {
+ color = "blue";
+ }
+ return color;
+ }
- protected String getVisibilityColorCode(CodeMetaclass item) {
- String color = "yellow";
- if (item.isPublic()) {
- color = "green";
- }
- if (item.isPrivate()) {
- color = "gray";
- }
- if (item.isProtected()) {
- color = "blue";
- }
- return color;
- }
-
- public void localAddDependency(String source_item, String target_item, int relationType, PrintWriter ostream, boolean directed, String extra, IArchitectureSpecification specification,
- CodeMetaclass item, boolean do_not_show_dependecy_details) {
- if (!shall_hide(source_item, target_item)) {
- numberNumberOfLink++;
- boolean checkPassed = true;
- String color = colorLUT[relationType];
- StringBuffer consoleErrorReportBuffer = new StringBuffer();
- StringBuffer displayErrorReportBuffer = new StringBuffer();
- String source = mangle(pruneToLevel(source_item));
- String target = mangle(pruneToLevel(target_item));
- if (performChecks) {
- String checkLinkID = source_item + "__" + target_item + "__" + relationType;
- if (!previouslyCheckedlinks.contains(checkLinkID)) {
- String errorBookKey = null;
- net.sf.jcontracts.idarwin.specification.openapi.IDependency dependency = specification.newDependency(source_item, target_item, relationNameLUT[relationType], item.getLocationDescription());
- StringBuffer errorReporBbuffer = new StringBuffer();
- if (!specification.check(dependency, consoleErrorReportBuffer, displayErrorReportBuffer)) {
- String errorText = errorReporBbuffer.toString();
- numberofErrors++;
- System.err.print("iDarwin: error " + errorID + " ");
- System.err.println(consoleErrorReportBuffer.toString());
- if (do_not_show_dependecy_details) {
- errorBookKey = source + "&" + target + "&";
- } else {
- errorBookKey = source + "&" + target + "&" + relationType;
- }
- if (!errorBook.containsKey(errorBookKey)) {
- Object arr[] = new Object[2];
- arr[0] = new Integer(0);
- arr[1] = "";
- errorBook.put(errorBookKey, ((Object) (arr)));
- }
- Object entry[] = (Object[])errorBook.get(errorBookKey);
- entry[0] = new Integer(((Integer)entry[0]).intValue() + 1);
- if (((String)entry[1]).length() > 0) {
- entry[1] = entry[1] + "\\n" + errorID + " (" + relationNameLUT[relationType] + ")";
- } else {
- entry[1] = "" + errorID + " (" + relationNameLUT[relationType] + ")";
- }
- errorID++;
- entry[1] = entry[1] + errorText;
- errorBook.put(errorBookKey, ((Object) (entry)));
- color = "red";
- String latestError = "error id: " + (String)entry[1] + "\\n(console)";
- extra = "label=\"" + latestError + "\",style=bold,fontcolor=red,";
- checkPassed = false;
- }
- previouslyCheckedlinks.addElement(checkLinkID);
+ public void localAddDependency(String source_item, String target_item, int relationType, PrintWriter ostream,
+ boolean directed, String extra, IArchitectureSpecification specification, CodeMetaclass item,
+ boolean do_not_show_dependecy_details)
+ {
+ if (!shall_hide(source_item, target_item))
+ {
+ numberNumberOfLink++;
+ boolean checkPassed = true;
+ String color = colorLUT[relationType];
+ StringBuffer consoleErrorReportBuffer = new StringBuffer();
+ StringBuffer displayErrorReportBuffer = new StringBuffer();
+ String source = mangle(pruneToLevel(source_item));
+ String target = mangle(pruneToLevel(target_item));
+ if (performChecks)
+ {
+ String checkLinkID = source_item + "__" + target_item + "__" + relationType;
+ if (!previouslyCheckedlinks.contains(checkLinkID))
+ {
+ String errorBookKey = null;
+ net.sf.jcontracts.idarwin.specification.openapi.IDependency dependency = specification
+ .newDependency(source_item, target_item, relationNameLUT[relationType], item
+ .getLocationDescription());
+ StringBuffer errorReporBbuffer = new StringBuffer();
+ if (!specification.check(dependency, consoleErrorReportBuffer, displayErrorReportBuffer))
+ {
+ String errorText = errorReporBbuffer.toString();
+ numberofErrors++;
+ System.err.print("iDarwin: error " + errorID + " ");
+ System.err.println(consoleErrorReportBuffer.toString());
+ if (do_not_show_dependecy_details)
+ {
+ errorBookKey = source + "&" + target + "&";
+ }
+ else
+ {
+ errorBookKey = source + "&" + target + "&" + relationType;
+ }
+ if (!errorBook.containsKey(errorBookKey))
+ {
+ Object arr[] = new Object[2];
+ arr[0] = new Integer(0);
+ arr[1] = "";
+ errorBook.put(errorBookKey, ((Object) (arr)));
+ }
+ Object entry[] = (Object[]) errorBook.get(errorBookKey);
+ entry[0] = new Integer(((Integer) entry[0]).intValue() + 1);
+ if (((String) entry[1]).length() > 0)
+ {
+ entry[1] = entry[1] + "\\n" + errorID + " (" + relationNameLUT[relationType] + ")";
+ }
+ else
+ {
+ entry[1] = "" + errorID + " (" + relationNameLUT[relationType] + ")";
+ }
+ errorID++;
+ entry[1] = entry[1] + errorText;
+ ...
[truncated message content] |