From d8a465fc5d383ffdbb4a89762193246bdd9cfa72 Mon Sep 17 00:00:00 2001 From: Andrea Aime Date: Tue, 3 Jan 2006 21:34:49 +0000 Subject: [PATCH] First cut to association/dependency inference. Needs discussion, sharing the code so that you can play with it if you want and examine the inference code behaviour. --- src/gr/spinellis/umlgraph/doclet/Options.java | 34 +++++++++++++++++-- src/org/umlgraph/doclet/Options.java | 34 +++++++++++++++++-- 2 files changed, 64 insertions(+), 4 deletions(-) diff --git a/src/gr/spinellis/umlgraph/doclet/Options.java b/src/gr/spinellis/umlgraph/doclet/Options.java index 1f36d33..472916e 100644 --- a/src/gr/spinellis/umlgraph/doclet/Options.java +++ b/src/gr/spinellis/umlgraph/doclet/Options.java @@ -34,6 +34,7 @@ import java.util.regex.PatternSyntaxException; */ class Options implements Cloneable, OptionProvider { private Vector hidePatterns; + private Vector hideInferPatterns; // PrintWriter w; boolean showQualified; boolean showAttributes; @@ -66,6 +67,8 @@ class Options implements Cloneable, OptionProvider { String guilOpen = "\u00ab"; /** Guillemot right (close) */ String guilClose = "\u00bb"; + boolean inferAssociations; + boolean inferDependencies; Options() { showQualified = false; @@ -95,6 +98,9 @@ class Options implements Cloneable, OptionProvider { useGuillemot = true; findViews = false; viewName = null; + inferAssociations = false; + inferDependencies = false; + hideInferPatterns = new Vector(); } public Object clone() { @@ -136,7 +142,9 @@ class Options implements Cloneable, OptionProvider { option.equals("-all") || option.equals("-noguillemot") || option.equals("-hideall") || - option.equals("-views")) + option.equals("-views") || + option.equals("-inferAssociations") || + option.equals("-inferDependencies")) return 1; else if(option.equals("-nodefillcolor") || @@ -288,6 +296,14 @@ class Options implements Cloneable, OptionProvider { outputDirectory = opt[1]; } else if (opt[0].equals("-!d")) { outputDirectory = "."; + } else if(opt[0].equals("-inferassoc")) { + inferAssociations = true; + } else if(opt[0].equals("-!inferassoc")) { + inferAssociations = false; + } else if(opt[0].equals("-inferdep")) { + inferDependencies = true; + } else if(opt[0].equals("-!inferdep")) { + inferDependencies = false; } else ; // Do nothing, javadoc will handle the option or complain, if needed. } @@ -325,7 +341,21 @@ class Options implements Cloneable, OptionProvider { } return false; } - + + /** + * Check if the supplied string matches an entity specified with + * the -hideinfer parameter + * @param s + * @return + */ + public boolean machesHideInferExpression(String s) { + for (Pattern hidePattern : hideInferPatterns) { + Matcher m = hidePattern.matcher(s); + if (m.find()) + return true; + } + return false; + } // ---------------------------------------------------------------- // OptionProvider methods diff --git a/src/org/umlgraph/doclet/Options.java b/src/org/umlgraph/doclet/Options.java index 1f36d33..472916e 100644 --- a/src/org/umlgraph/doclet/Options.java +++ b/src/org/umlgraph/doclet/Options.java @@ -34,6 +34,7 @@ import java.util.regex.PatternSyntaxException; */ class Options implements Cloneable, OptionProvider { private Vector hidePatterns; + private Vector hideInferPatterns; // PrintWriter w; boolean showQualified; boolean showAttributes; @@ -66,6 +67,8 @@ class Options implements Cloneable, OptionProvider { String guilOpen = "\u00ab"; /** Guillemot right (close) */ String guilClose = "\u00bb"; + boolean inferAssociations; + boolean inferDependencies; Options() { showQualified = false; @@ -95,6 +98,9 @@ class Options implements Cloneable, OptionProvider { useGuillemot = true; findViews = false; viewName = null; + inferAssociations = false; + inferDependencies = false; + hideInferPatterns = new Vector(); } public Object clone() { @@ -136,7 +142,9 @@ class Options implements Cloneable, OptionProvider { option.equals("-all") || option.equals("-noguillemot") || option.equals("-hideall") || - option.equals("-views")) + option.equals("-views") || + option.equals("-inferAssociations") || + option.equals("-inferDependencies")) return 1; else if(option.equals("-nodefillcolor") || @@ -288,6 +296,14 @@ class Options implements Cloneable, OptionProvider { outputDirectory = opt[1]; } else if (opt[0].equals("-!d")) { outputDirectory = "."; + } else if(opt[0].equals("-inferassoc")) { + inferAssociations = true; + } else if(opt[0].equals("-!inferassoc")) { + inferAssociations = false; + } else if(opt[0].equals("-inferdep")) { + inferDependencies = true; + } else if(opt[0].equals("-!inferdep")) { + inferDependencies = false; } else ; // Do nothing, javadoc will handle the option or complain, if needed. } @@ -325,7 +341,21 @@ class Options implements Cloneable, OptionProvider { } return false; } - + + /** + * Check if the supplied string matches an entity specified with + * the -hideinfer parameter + * @param s + * @return + */ + public boolean machesHideInferExpression(String s) { + for (Pattern hidePattern : hideInferPatterns) { + Matcher m = hidePattern.matcher(s); + if (m.find()) + return true; + } + return false; + } // ---------------------------------------------------------------- // OptionProvider methods