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] |
From: <js...@us...> - 2008-05-09 17:07:12
|
Revision: 47 http://jcontracts.svn.sourceforge.net/jcontracts/?rev=47&view=rev Author: jstuyts Date: 2008-05-09 10:07:10 -0700 (Fri, 09 May 2008) Log Message: ----------- Removed Dotty-related classes. Removed Paths: ------------- 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/IDependencyFilter.java trunk/source/java/net/sf/jcontracts/codeparser/IDotty_Component_Level.java Deleted: trunk/source/java/net/sf/jcontracts/codeparser/DottyVisitor.java =================================================================== --- trunk/source/java/net/sf/jcontracts/codeparser/DottyVisitor.java 2008-05-09 17:04:57 UTC (rev 46) +++ trunk/source/java/net/sf/jcontracts/codeparser/DottyVisitor.java 2008-05-09 17:07:10 UTC (rev 47) @@ -1,235 +0,0 @@ -/* - * Copyright 1997-2000 Reto Kramer - * Copyright 2006 John Swapceinski, Johan Stuyts - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package net.sf.jcontracts.codeparser; - -import java.io.FileOutputStream; -import java.io.IOException; -import java.io.PrintWriter; -import java.util.Vector; - -import net.sf.jcontracts.idarwin.specification.openapi.IArchitectureExporter; -import net.sf.jcontracts.idarwin.specification.openapi.IArchitectureSpecification; - -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; - - 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; - 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 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 int getNumberOfErrors() - { - return component.getNumberOfErrors(); - } - - 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 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;"); - } - } -} Deleted: trunk/source/java/net/sf/jcontracts/codeparser/DottyVisitorConstants.java =================================================================== --- trunk/source/java/net/sf/jcontracts/codeparser/DottyVisitorConstants.java 2008-05-09 17:04:57 UTC (rev 46) +++ trunk/source/java/net/sf/jcontracts/codeparser/DottyVisitorConstants.java 2008-05-09 17:07:10 UTC (rev 47) @@ -1,96 +0,0 @@ -/* - * Copyright 1997-2000 Reto Kramer - * Copyright 2006 John Swapceinski, Johan Stuyts - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package net.sf.jcontracts.codeparser; - -public class DottyVisitorConstants -{ - - 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 String edgeLengthCommand(boolean directed) - { - String result = null; - if (directed) - { - result = "minlen=" + getEdgeLength() + ","; - } - else - { - result = "len=" + getEdgeLength() + ","; - } - return result; - } - - 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 String fontName() - { - return FONT_NAME; - } - - public static int fontSize() - { - return FONT_SIZE; - } - - 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() - { - } - -} Deleted: trunk/source/java/net/sf/jcontracts/codeparser/Dotty_Component_CommonLevel.java =================================================================== --- trunk/source/java/net/sf/jcontracts/codeparser/Dotty_Component_CommonLevel.java 2008-05-09 17:04:57 UTC (rev 46) +++ trunk/source/java/net/sf/jcontracts/codeparser/Dotty_Component_CommonLevel.java 2008-05-09 17:07:10 UTC (rev 47) @@ -1,494 +0,0 @@ -/* - * Copyright 1997-2000 Reto Kramer - * Copyright 2006 John Swapceinski, Johan Stuyts - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package net.sf.jcontracts.codeparser; - -import java.io.PrintWriter; -import java.util.Enumeration; -import java.util.Hashtable; -import java.util.Vector; - -import net.sf.jcontracts.idarwin.specification.openapi.IArchitectureSpecification; - -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; - - 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); - } - } - } - 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;) - { - 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 + "\""; - } - - } - - 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,"; - } - - public int getNumberOfErrors() - { - return numberofErrors; - } - - 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; - } - - 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); - } - } - String displayLinkID = null; - if (do_not_show_dependecy_details) - { - displayLinkID = source + "__" + target; - if (checkPassed) - { - color = "black"; - } - } - else - { - displayLinkID = source + "__" + target + "__" + relationType; - } - if (checkPassed && !previouslyDisplayedlinks.contains(displayLinkID)) - { - int fontSize = DottyVisitorConstants.fontSize(); - String fontName = DottyVisitorConstants.fontName(); - String edgeLengthCommand = DottyVisitorConstants.edgeLengthCommand(directed); - String linkSymbol = DottyVisitorConstants.linkSymbol(directed); - ostream.println(source + linkSymbol + target + " [" + edgeLengthCommand + extra + "color=" + color - + ",fontsize=" + fontSize + ",fontname=\"" + fontName + "\"];"); - previouslyDisplayedlinks.addElement(displayLinkID); - } - if (performChecks) - { - containsErrors = checkPassed; - } - else - { - containsErrors = false; - } - } - } - - protected void localAddPackage(PrintWriter ostream, CodeMetaclass item) - { - int fontSize = DottyVisitorConstants.fontSize(); - String fontName = DottyVisitorConstants.fontName(); - String name = item.getName(); - ostream.print(mangle(pruneToLevel(name))); - ostream.print(" [label=\"<<package>>\\n" + pruneToLevel(name) + "\""); - ostream.print(",shape=box"); - ostream.println(",fontsize=" + fontSize + ",fontname=\"" + fontName + "\"];"); - } - - protected void localAddType(PrintWriter ostream, CodeMetaclass item) - { - int fontSize = DottyVisitorConstants.fontSize(); - String fontName = DottyVisitorConstants.fontName(); - String id = item.getName(); - ostream.print(mangle(id)); - if (item instanceof Class) - { - ostream.print(" [label=\"<<class>>\\n" + item.getName() + "\""); - ostream.print(",shape=box,style=filled,color=" + getVisibilityColorCode(item)); - } - else - { - ostream.print(" [label=\"<<interface>>\\n" + item.getName() + "\""); - ostream.print(",shape=diamond,style=filled,color=" + getVisibilityColorCode(item)); - } - ostream.println(",fontsize=" + fontSize + ",fontname=\"" + fontName + "\"];"); - } - - protected static String mangle(String name) - { - String newname = null; - if (name.indexOf("Node") != -1 || name.indexOf("Graph") != -1) - { - newname = "_" + name; - } - else - { - newname = name; - } - newname = newname.replace('.', '_'); - newname = newname.replace('[', '_'); - newname = newname.replace(']', '_'); - newname = newname.replace('$', '_'); - newname = newname.replace('*', '_'); - newname = newname.replace('\\', '_'); - newname = newname.replace(' ', '_'); - return newname; - } - - private boolean match(String item, String pattern) - { - boolean result = false; - int pos = pattern.indexOf("\\"); - if (pos == -1) - { - result = atomicMatch(item, pattern); - } - else - { - String affermative = pattern.substring(0, pos); - String negative = pattern.substring(pos + 1); - if (match(item, affermative)) - { - result = !atomicMatch(item, negative); - } - else - { - result = false; - } - } - return result; - } - - protected String pruneToLevel(String name) - { - return name; - } - - public void setIgnoranceList(Vector quietList) - { - ignore = quietList; - } - - private boolean shall_hide(String source_item, String target_item) - { - boolean hide = pruneToLevel(source_item).equals("PACKAGE_DEFAULT") - || pruneToLevel(target_item).equals("PACKAGE_DEFAULT"); - if (!hide) - { - hide = target_item.indexOf("$") == -1 && target_item.indexOf("_") == -1 && target_item.indexOf(".") == -1; - } - return hide; - } - - protected final boolean shallIgnore(String type) - { - if (type.equals("boolean") || type.equals("char") || type.equals("int") || type.equals("long") - || type.equals("byte") || type.equals("float") || type.equals("PACKAGE_DEFAULT") - || type.equals("double")) - { - return true; - } - for (int i = 0; i < ignore.size(); i++) - { - if (match(type, (String) ignore.elementAt(i))) - { - return true; - } - } - - return false; - } - - protected String stripArray(String qualifiedName) - { - int start = qualifiedName.indexOf("["); - String result = null; - if (start == -1) - { - result = qualifiedName; - } - else - { - result = qualifiedName.substring(0, start); - } - return result; - } - - public Dotty_Component_CommonLevel() - { - previouslyCheckedlinks = new Vector(); - previouslyDisplayedlinks = new Vector(); - errorBook = new Hashtable(); - hideAllButPublic = false; - performChecks = true; - filter = null; - containsErrors = false; - numberofErrors = 0; - errorID = 1; - numberNumberOfLink = 0; - } - -} Deleted: trunk/source/java/net/sf/jcontracts/codeparser/Dotty_Component_PackageLevel.java =================================================================== --- trunk/source/java/net/sf/jcontracts/codeparser/Dotty_Component_PackageLevel.java 2008-05-09 17:04:57 UTC (rev 46) +++ trunk/source/java/net/sf/jcontracts/codeparser/Dotty_Component_PackageLevel.java 2008-05-09 17:07:10 UTC (rev 47) @@ -1,244 +0,0 @@ -/* - * Copyright 1997-2000 Reto Kramer - * Copyright 2006 John Swapceinski, Johan Stuyts - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package net.sf.jcontracts.codeparser; - -import java.io.PrintWriter; -import java.util.Enumeration; -import java.util.Vector; - -import net.sf.jcontracts.idarwin.specification.openapi.IArchitectureSpecification; - -public class Dotty_Component_PackageLevel extends Dotty_Component_CommonLevel implements IDotty_Component_Level -{ - - public Dotty_Component_PackageLevel(IDependencyFilter filter, boolean performChecks) - { - super.performChecks = performChecks; - super.filter = filter; - } - - public Dotty_Component_PackageLevel(boolean performChecks) - { - super.performChecks = performChecks; - } - - public void acceptMethod(CodeMetaclass item, PrintWriter ostream, boolean directed, - IArchitectureSpecification specification, boolean do_not_show_dependecy_details) - { - Method m = (Method) item; - if ((!super.hideAllButPublic || item.isPublic()) && !shallIgnore(m.getParent().getName())) - { - String id = m.getParent().getName(); - String otherid = ""; - if (m.hasType()) - { - otherid = m.getType(); - otherid = stripArray(otherid); - if (!shallIgnore(otherid)) - { - addDependency(id, otherid, 4, ostream, directed, "", specification, item, - do_not_show_dependecy_details); - } - } - for (Enumeration e = m.getParameterNames().elements(); e.hasMoreElements();) - { - String t = m.getTypeOfParameter((String) e.nextElement()); - otherid = t; - otherid = stripArray(otherid); - if (!shallIgnore(otherid)) - { - addDependency(id, otherid, 5, ostream, directed, "", specification, item, - do_not_show_dependecy_details); - } - } - - for (Enumeration e = m.getNewedTypes().elements(); e.hasMoreElements();) - { - String t = (String) e.nextElement(); - otherid = t; - otherid = stripArray(otherid); - if (!shallIgnore(otherid)) - { - addDependency(id, otherid, 7, ostream, directed, "", specification, item, - do_not_show_dependecy_details); - } - } - - for (Enumeration e = m.getLocalVarTypes().elements(); e.hasMoreElements();) - { - String t = (String) e.nextElement(); - otherid = t; - otherid = stripArray(otherid); - if (!shallIgnore(otherid)) - { - addDependency(id, otherid, 8, ostream, directed, "", specification, item, - do_not_show_dependecy_details); - } - } - - for (Enumeration e = m.getStaticRefTypes().elements(); e.hasMoreElements();) - { - String t = (String) e.nextElement(); - otherid = t; - otherid = stripArray(otherid); - if (!shallIgnore(otherid)) - { - addDependency(id, otherid, 9, ostream, directed, "", specification, item, - do_not_show_dependecy_details); - } - } - - for (Enumeration e = m.getCastedTypes().elements(); e.hasMoreElements();) - { - String t = (String) e.nextElement(); - otherid = t; - otherid = stripArray(otherid); - if (!shallIgnore(otherid)) - { - addDependency(id, otherid, 10, ostream, directed, "", specification, item, - do_not_show_dependecy_details); - } - } - - } - } - - public void acceptTypeMetaclass(CodeMetaclass item, PrintWriter ostream, boolean directed, - IArchitectureSpecification specification, boolean do_not_show_dependecy_details) - { - if ((!super.hideAllButPublic || item.isPublic()) && !shallIgnore(item.getName())) - { - addPackage(ostream, item); - String id = item.getName(); - String superclassName = ((TypeMetaclass) item).getExtendedClassName(); - if (superclassName != null) - { - String otherid = superclassName; - if (!shallIgnore(otherid)) - { - addDependency(id, otherid, 2, ostream, directed, "weight=10,style=bold,", specification, item, - do_not_show_dependecy_details); - } - } - Vector v = ((TypeMetaclass) item).getExtendedInterfaces(); - if (v != null && !v.isEmpty()) - { - for (Enumeration e = v.elements(); e.hasMoreElements();) - { - String sss = (String) e.nextElement(); - String otherid = sss; - if (!shallIgnore(otherid)) - { - addDependency(id, otherid, 1, ostream, directed, "weight=3,style=dotted,", specification, item, - do_not_show_dependecy_details); - } - } - - } - v = ((TypeMetaclass) item).getImplementedInterfaces(); - if (v != null && !v.isEmpty()) - { - for (Enumeration e = v.elements(); e.hasMoreElements();) - { - String sss = (String) e.nextElement(); - String otherid = sss; - if (!shallIgnore(otherid)) - { - addDependency(id, otherid, 3, ostream, directed, "weight=2,style=dotted,", specification, item, - do_not_show_dependecy_details); - } - } - - } - for (Enumeration e = ((ICodeBody) item).getNewedTypes().elements(); e.hasMoreElements();) - { - String sss = (String) e.nextElement(); - String otherid = sss; - otherid = stripArray(otherid); - if (!shallIgnore(otherid)) - { - addDependency(id, otherid, 7, ostream, directed, "", specification, item, - do_not_show_dependecy_details); - } - } - - for (Enumeration e = ((ICodeBody) item).getStaticRefTypes().elements(); e.hasMoreElements();) - { - String sss = (String) e.nextElement(); - String otherid = sss; - otherid = stripArray(otherid); - if (!shallIgnore(otherid)) - { - addDependency(id, otherid, 9, ostream, directed, "", specification, item, - do_not_show_dependecy_details); - } - } - - for (Enumeration e = ((ICodeBody) item).getCastedTypes().elements(); e.hasMoreElements();) - { - String sss = (String) e.nextElement(); - String otherid = sss; - otherid = stripArray(otherid); - if (!shallIgnore(otherid)) - { - addDependency(id, otherid, 10, ostream, directed, "", specification, item, - do_not_show_dependecy_details); - } - } - - } - } - - public void acceptVariable(CodeMetaclass item, PrintWriter ostream, boolean directed, - IArchitectureSpecification specification, boolean do_not_show_dependecy_details) - { - try - { - Variable v = (Variable) item; - if (!super.hideAllButPublic || item.isPublic()) - { - String t = stripArray(v.getType()); - if (!shallIgnore(t)) - { - String id = t; - String otherid = v.getParent().getName(); - if (!shallIgnore(otherid)) - { - addDependency(otherid, id, 6, ostream, directed, "", specification, item, - do_not_show_dependecy_details); - } - } - } - } - catch (ClassCastException e) - { - System.err.println(e + " during visiting " + item + "\ndelete internal cache file and restart."); - throw e; - } - } - - protected String getErrorTextForDisplay(String source, String target, String type, String rule) - { - return "label=\"Dependency\\n" + source + "\\n-" + type + "->\\n" + target + "\\n" + "VIOLATES\\n" + rule - + "\",style=bold,fontcolor=red,"; - } - - protected String pruneToLevel(String name) - { - return DottyVisitorConstants.extractPackage(name); - } -} Deleted: trunk/source/java/net/sf/jcontracts/codeparser/Dotty_Component_TypeLevel.java =================================================================== --- trunk/source/java/net/sf/jcontracts/codeparser/Dotty_Component_TypeLevel.java 2008-05-09 17:04:57 UTC (rev 46) +++ trunk/source/java/net/sf/jcontracts/codeparser/Dotty_Component_TypeLevel.java 2008-05-09 17:07:10 UTC (rev 47) @@ -1,236 +0,0 @@ -/* - * Copyright 1997-2000 Reto Kramer - * Copyright 2006 John Swapceinski, Johan Stuyts - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package net.sf.jcontracts.codeparser; - -import java.io.PrintWriter; -import java.util.Enumeration; -import java.util.Vector; - -import net.sf.jcontracts.idarwin.specification.openapi.IArchitectureSpecification; - -public class Dotty_Component_TypeLevel extends Dotty_Component_CommonLevel implements IDotty_Component_Level -{ - - public Dotty_Component_TypeLevel(IDependencyFilter filter, boolean performChecks) - { - super.performChecks = performChecks; - super.filter = filter; - } - - public Dotty_Component_TypeLevel(boolean performChecks) - { - super.performChecks = performChecks; - } - - public void acceptMethod(CodeMetaclass item, PrintWriter ostream, boolean directed, - IArchitectureSpecification specification, boolean do_not_show_dependecy_details) - { - DottyVisitorConstants.fontSize(); - DottyVisitorConstants.fontName(); - DottyVisitorConstants.edgeLengthCommand(directed); - DottyVisitorConstants.linkSymbol(directed); - Method m = (Method) item; - if ((!super.hideAllButPublic || item.isPublic()) && !shallIgnore(m.getParent().getName())) - { - String id = m.getParent().getName(); - String otherid = ""; - if (m.hasType()) - { - otherid = m.getType(); - otherid = stripArray(otherid); - if (!shallIgnore(otherid)) - { - addDependency(id, otherid, 4, ostream, directed, "", specification, item, - do_not_show_dependecy_details); - } - } - for (Enumeration e = m.getParameterNames().elements(); e.hasMoreElements();) - { - String t = m.getTypeOfParameter((String) e.nextElement()); - otherid = t; - otherid = stripArray(otherid); - if (!shallIgnore(otherid)) - { - addDependency(id, otherid, 5, ostream, directed, "", specification, item, - do_not_show_dependecy_details); - } - } - - for (Enumeration e = m.getNewedTypes().elements(); e.hasMoreElements();) - { - otherid = (String) e.nextElement(); - otherid = stripArray(otherid); - if (!shallIgnore(otherid)) - { - addDependency(id, otherid, 7, ostream, directed, "", specification, item, - do_not_show_dependecy_details); - } - } - - for (Enumeration e = m.getLocalVarTypes().elements(); e.hasMoreElements();) - { - otherid = (String) e.nextElement(); - otherid = stripArray(otherid); - if (!shallIgnore(otherid)) - { - addDependency(id, otherid, 8, ostream, directed, "", specification, item, - do_not_show_dependecy_details); - } - } - - for (Enumeration e = m.getStaticRefTypes().elements(); e.hasMoreElements();) - { - otherid = (String) e.nextElement(); - otherid = stripArray(otherid); - if (!shallIgnore(otherid)) - { - addDependency(id, otherid, 9, ostream, directed, "", specification, item, - do_not_show_dependecy_details); - } - } - - for (Enumeration e = m.getCastedTypes().elements(); e.hasMoreElements();) - { - otherid = (String) e.nextElement(); - otherid = stripArray(otherid); - if (!shallIgnore(otherid)) - { - addDependency(id, otherid, 10, ostream, directed, "", specification, item, - do_not_show_dependecy_details); - } - } - - } - } - - public void acceptTypeMetaclass(CodeMetaclass item, PrintWriter ostream, boolean directed, - IArchitectureSpecification specification, boolean do_not_show_dependecy_details) - { - DottyVisitorConstants.fontSize(); - DottyVisitorConstants.fontName(); - DottyVisitorConstants.edgeLengthCommand(directed); - DottyVisitorConstants.linkSymbol(directed); - if ((!super.hideAllButPublic || item.isPublic()) && !shallIgnore(item.getName())) - { - addType(ostream, item); - String id = item.getName(); - String superclassName = ((TypeMetaclass) item).getExtendedClassName(); - if (superclassName != null) - { - String otherid = superclassName; - if (!shallIgnore(otherid)) - { - addDependency(id, otherid, 2, ostream, directed, "weight=10,style=bold,", specification, item, - do_not_show_dependecy_details); - } - } - Vector v = ((TypeMetaclass) item).getExtendedInterfaces(); - if (v != null && !v.isEmpty()) - { - for (Enumeration e = v.elements(); e.hasMoreElements();) - { - String otherid = (String) e.nextElement(); - if (!shallIgnore(otherid)) - { - addDependency(id, otherid, 1, ostream, directed, "weight=3,style=dotted,", specification, item, - do_not_show_dependecy_details); - } - } - - } - v = ((TypeMetaclass) item).getImplementedInterfaces(); - if (v != null && !v.isEmpty()) - { - for (Enumeration e = v.elements(); e.hasMoreElements();) - { - String otherid = (String) e.nextElement(); - if (!shallIgnore(otherid)) - { - addDependency(id, otherid, 3, ostream, directed, "weight=2,style=dotted,", specification, item, - do_not_show_dependecy_details); - } - } - - } - for (Enumeration e = ((ICodeBody) item).getNewedTypes().elements(); e.hasMoreElements();) - { - String otherid = (String) e.nextElement(); - otherid = stripArray(otherid); - if (!shallIgnore(otherid)) - { - addDependency(id, otherid, 7, ostream, directed, "", specification, item, - do_not_show_dependecy_details); - } - } - - for (Enumeration e = ((ICodeBody) item).getStaticRefTypes().elements(); e.hasMoreElements();) - { - String otherid = (String) e.nextElement(); - otherid = stripArray(otherid); - if (!shallIgnore(otherid)) - { - addDependency(id, otherid, 9, ostream, directed, "", specification, item, - do_not_show_dependecy_details); - } - } - - for (Enumeration e = ((ICodeBody) item).getCastedTypes().elements(); e.hasMoreElements();) - { - String otherid = (String) e.nextElement(); - otherid = stripArray(otherid); - if (!shallIgnore(otherid)) - { - addDependency(id, otherid, 10, ostream, directed, "", specification, item, - do_not_show_dependecy_details); - } - } - - } - } - - public void acceptVariable(CodeMetaclass item, PrintWriter ostream, boolean directed, - IArchitectureSpecification specification, boolean do_not_show_dependecy_details) - { - try - { - DottyVisitorConstants.fontSize(); - DottyVisitorConstants.fontName(); - DottyVisitorConstants.edgeLengthCommand(directed); - DottyVisitorConstants.linkSymbol(directed); - Variable v = (Variable) item; - if (!super.hideAllButPublic || item.isPublic()) - { - String t = stripArray(v.getType()); - if (!shallIgnore(t)) - { - String id = t; - String otherid = v.getParent().getName(); - if (!shallIgnore(otherid)) - { - addDependency(otherid, id, 6, ostream, directed, "", specification, item, - do_not_show_dependecy_details); - } - } - } - } - catch (ClassCastException e) - { - System.err.println(e + " during visiting " + item + "\ndelete internal cache file and restart."); - throw e; - } - } -} Deleted: trunk/source/java/net/sf/jcontracts/codeparser/IDependencyFilter.java =================================================================== --- trunk/source/java/net/sf/jcontracts/codeparser/IDependencyFilter.java 2008-05-09 17:04:57 UTC (rev 46) +++ trunk/source/java/net/sf/jcontracts/codeparser/IDependencyFilter.java 2008-05-09 17:07:10 UTC (rev 47) @@ -1,37 +0,0 @@ -/* - * Copyright 1997-2000 Reto Kramer - * Copyright 2006 John Swapceinski, Johan Stuyts - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package net.sf.jcontracts.codeparser; - -import java.io.IOException; -import java.io.PrintWriter; - -import net.sf.jcontracts.idarwin.specification.openapi.IArchitectureSpecification; - -public interface IDependencyFilter -{ - - public abstract void addDependency(String s, String s1, int i, PrintWriter printwriter, boolean flag, String s2, - IArchitectureSpecification iarchitecturespecification, CodeMetaclass codemetaclass, boolean flag1); - - public abstract void addPackage(PrintWriter printwriter, CodeMetaclass codemetaclass); - - public abstract void addType(PrintWriter printwriter, CodeMetaclass codemetaclass); - - public abstract void writeHeader(PrintWriter printwriter, String s) throws IOException; - - public abstract void writeTrailer(PrintWriter printwriter); -} Deleted: trunk/source/java/net/sf/jcontracts/codeparser/IDotty_Component_Level.java =================================================================== --- trunk/source/java/net/sf/jcontracts/codeparser/IDotty_Component_Level.java 2008-05-09 17:04:57 UTC (rev 46) +++ trunk/source/java/net/sf/jcontracts/codeparser/IDotty_Component_Level.java 2008-05-09 17:07:10 UTC (rev 47) @@ -1,45 +0,0 @@ -/* - * Copyright 1997-2000 Reto Kramer - * Copyright 2006 John Swapceinski, Johan Stuyts - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package net.sf.jcontracts.codeparser; - -import java.io.PrintWriter; -import java.util.Vector; - -import net.sf.jcontracts.idarwin.specification.openapi.IArchitectureSpecification; - -public interface IDotty_Component_Level -{ - - public abstract void acceptMethod(CodeMetaclass codemetaclass, PrintWriter printwriter, boolean flag, - IArchitectureSpecification iarchitecturespecification, boolean flag1); - - public abstract void acceptTypeMetaclass(CodeMetaclass codemetaclass, PrintWriter printwriter, boolean flag, - IArchitectureSpecification iarchitecturespecification, boolean flag1); - - public abstract void acceptVariable(CodeMetaclass codemetaclass, PrintWriter printwriter, boolean flag, - IArchitectureSpecification iarchitecturespecification, boolean flag1); - - public abstract void createErrorLinks(boolean flag, PrintWriter printwriter); - - public abstract boolean getError(); - - public abstract int getNumberOfErrors(); - - public abstract int getNumberOfLinks(); - - public abstract void setIgnoranceList(Vector vector); -} This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |