From: <js...@us...> - 2006-11-27 20:15:59
|
Revision: 35 http://svn.sourceforge.net/jcontracts/?rev=35&view=rev Author: jstuyts Date: 2006-11-27 12:15:57 -0800 (Mon, 27 Nov 2006) Log Message: ----------- Formatted code. Modified Paths: -------------- trunk/source/java/net/sf/jcontracts/idarwin/specification/impl/primitive_language/ArchitectureSpecification.java trunk/source/java/net/sf/jcontracts/idarwin/specification/impl/primitive_language/ArchitectureSpecificationFilter.java trunk/source/java/net/sf/jcontracts/idarwin/specification/impl/primitive_language/CompositePattern.java trunk/source/java/net/sf/jcontracts/idarwin/specification/impl/primitive_language/Dependency.java trunk/source/java/net/sf/jcontracts/idarwin/specification/impl/primitive_language/DependencyConstraint.java trunk/source/java/net/sf/jcontracts/idarwin/specification/impl/primitive_language/DependencyConstraintExporter.java trunk/source/java/net/sf/jcontracts/idarwin/specification/impl/primitive_language/DifferencePattern.java trunk/source/java/net/sf/jcontracts/idarwin/specification/impl/primitive_language/Group.java trunk/source/java/net/sf/jcontracts/idarwin/specification/impl/primitive_language/Idiom.java trunk/source/java/net/sf/jcontracts/idarwin/specification/impl/primitive_language/IdiomFactory.java trunk/source/java/net/sf/jcontracts/idarwin/specification/impl/primitive_language/IsolateIdiom.java trunk/source/java/net/sf/jcontracts/idarwin/specification/impl/primitive_language/LanguageFactory.java trunk/source/java/net/sf/jcontracts/idarwin/specification/impl/primitive_language/LayerIdiom.java trunk/source/java/net/sf/jcontracts/idarwin/specification/impl/primitive_language/PSpecLexer.java trunk/source/java/net/sf/jcontracts/idarwin/specification/impl/primitive_language/PSpecParser.java trunk/source/java/net/sf/jcontracts/idarwin/specification/impl/primitive_language/PSpecTokenTypes.java trunk/source/java/net/sf/jcontracts/idarwin/specification/impl/primitive_language/Pattern.java trunk/source/java/net/sf/jcontracts/idarwin/specification/impl/primitive_language/PatternFactory.java trunk/source/java/net/sf/jcontracts/idarwin/specification/impl/primitive_language/PatternSyntaxException.java trunk/source/java/net/sf/jcontracts/idarwin/specification/impl/primitive_language/SetPattern.java trunk/source/java/net/sf/jcontracts/idarwin/specification/impl/primitive_language/SingleDependencyConstraint.java trunk/source/java/net/sf/jcontracts/idarwin/specification/impl/primitive_language/SingularPattern.java trunk/source/java/net/sf/jcontracts/idarwin/specification/impl/primitive_language/StrictlyLayerIdiom.java Modified: trunk/source/java/net/sf/jcontracts/idarwin/specification/impl/primitive_language/ArchitectureSpecification.java =================================================================== --- trunk/source/java/net/sf/jcontracts/idarwin/specification/impl/primitive_language/ArchitectureSpecification.java 2006-11-27 20:14:50 UTC (rev 34) +++ trunk/source/java/net/sf/jcontracts/idarwin/specification/impl/primitive_language/ArchitectureSpecification.java 2006-11-27 20:15:57 UTC (rev 35) @@ -14,414 +14,526 @@ import net.sf.jcontracts.util.JavaEvaluator; import antlr.ParserException; -public class ArchitectureSpecification - implements IArchitectureSpecification { +public class ArchitectureSpecification implements IArchitectureSpecification +{ - protected Vector rules; - protected Vector groups; - protected Vector unusedRules; + protected Vector rules; - public ArchitectureSpecification() { - rules = new Vector(); - groups = new Vector(); - unusedRules = new Vector(); - } + protected Vector groups; - public ArchitectureSpecification(Vector setOfRules) { - rules = new Vector(); - groups = new Vector(); - unusedRules = new Vector(); - rules = setOfRules; - sort(); - for (int k = 0; k < rules.size(); k++) { - SingleDependencyConstraint d = (SingleDependencyConstraint)rules.elementAt(k); - d.annotate("" + k); - } + protected Vector unusedRules; - } + public ArchitectureSpecification() + { + rules = new Vector(); + groups = new Vector(); + unusedRules = new Vector(); + } - public void addConstraint(SingleDependencyConstraint rule) { - rules.addElement(rule); - sort(); - for (int k = 0; k < rules.size(); k++) { - SingleDependencyConstraint d = (SingleDependencyConstraint)rules.elementAt(k); - if (d == rule) { + public ArchitectureSpecification(Vector setOfRules) + { + rules = new Vector(); + groups = new Vector(); + unusedRules = new Vector(); + rules = setOfRules; + sort(); + for (int k = 0; k < rules.size(); k++) + { + SingleDependencyConstraint d = (SingleDependencyConstraint) rules.elementAt(k); d.annotate("" + k); - } - } + } - } + } - public boolean addGroup(Group g) { - boolean found = false; - String probe_name; - for (Enumeration e = groups.elements(); !found && e.hasMoreElements(); found = probe_name.equals(g.getLabel())) { - Group probe = (Group)e.nextElement(); - probe_name = probe.getLabel(); - } + public void addConstraint(SingleDependencyConstraint rule) + { + rules.addElement(rule); + sort(); + for (int k = 0; k < rules.size(); k++) + { + SingleDependencyConstraint d = (SingleDependencyConstraint) rules.elementAt(k); + if (d == rule) + { + d.annotate("" + k); + } + } - if (found) { - throw new RuntimeException("iDarwin: error duplicate definition of group: " + g.getLabel() + " (" + g + ")"); - } else { - groups.addElement(g); - return !found; - } - } + } - public boolean check(IDependency dependency, StringBuffer consoleErrorBuf, StringBuffer screenErrorBuf) { - String source_item = dependency.getSource(); - String target_item = dependency.getTarget(); - String relationType = dependency.getType(); - boolean checkPassed = true; - boolean passed = false; - for (Enumeration e = rules.elements(); !passed && e.hasMoreElements();) { - SingleDependencyConstraint c = (SingleDependencyConstraint)e.nextElement(); - if (!c.check(dependency)) { - ruleWasUsed(c); - checkPassed = false; - screenErrorBuf.append(c.toStringForDottyErrorDisplay()); - consoleErrorBuf.append("in " + dependency.getLocation() + "\n"); - consoleErrorBuf.append("the dependency " + source_item + " -" + relationType + "-> " + target_item + "\n"); - consoleErrorBuf.append("violates the constraint " + c + "\n"); - } else - if (c.match(dependency)) { - passed = true; - ruleWasUsed(c); - } - } + public boolean addGroup(Group g) + { + boolean found = false; + String probe_name; + for (Enumeration e = groups.elements(); !found && e.hasMoreElements(); found = probe_name.equals(g.getLabel())) + { + Group probe = (Group) e.nextElement(); + probe_name = probe.getLabel(); + } - return checkPassed; - } + if (found) + { + throw new RuntimeException("iDarwin: error duplicate definition of group: " + g.getLabel() + " (" + g + ")"); + } + else + { + groups.addElement(g); + return !found; + } + } - public net.sf.jcontracts.idarwin.specification.openapi.IArchitectureSpecification composeWith(net.sf.jcontracts.idarwin.specification.openapi.IArchitectureSpecification other) throws IllFormedSpecificationException { - net.sf.jcontracts.idarwin.specification.openapi.IArchitectureSpecification result = null; - if (other == null) { - result = this; - } else - if (other instanceof ArchitectureSpecification) { - ArchitectureSpecification spec = new ArchitectureSpecification(); - for (int i = 0; i < ((ArchitectureSpecification)other).getGroups().size(); i++) { - boolean succ = spec.addGroup((Group)((ArchitectureSpecification)other).getGroups().elementAt(i)); - if (!succ) { - throw new IllFormedSpecificationException(""); + public boolean check(IDependency dependency, StringBuffer consoleErrorBuf, StringBuffer screenErrorBuf) + { + String source_item = dependency.getSource(); + String target_item = dependency.getTarget(); + String relationType = dependency.getType(); + boolean checkPassed = true; + boolean passed = false; + for (Enumeration e = rules.elements(); !passed && e.hasMoreElements();) + { + SingleDependencyConstraint c = (SingleDependencyConstraint) e.nextElement(); + if (!c.check(dependency)) + { + ruleWasUsed(c); + checkPassed = false; + screenErrorBuf.append(c.toStringForDottyErrorDisplay()); + consoleErrorBuf.append("in " + dependency.getLocation() + "\n"); + consoleErrorBuf.append("the dependency " + source_item + " -" + relationType + "-> " + target_item + + "\n"); + consoleErrorBuf.append("violates the constraint " + c + "\n"); } - } + else if (c.match(dependency)) + { + passed = true; + ruleWasUsed(c); + } + } - for (int i = 0; i < groups.size(); i++) { - boolean succ = spec.addGroup((Group)groups.elementAt(i)); - if (!succ) { - throw new IllFormedSpecificationException(""); + return checkPassed; + } + + public net.sf.jcontracts.idarwin.specification.openapi.IArchitectureSpecification composeWith( + net.sf.jcontracts.idarwin.specification.openapi.IArchitectureSpecification other) + throws IllFormedSpecificationException + { + net.sf.jcontracts.idarwin.specification.openapi.IArchitectureSpecification result = null; + if (other == null) + { + result = this; + } + else if (other instanceof ArchitectureSpecification) + { + ArchitectureSpecification spec = new ArchitectureSpecification(); + for (int i = 0; i < ((ArchitectureSpecification) other).getGroups().size(); i++) + { + boolean succ = spec.addGroup((Group) ((ArchitectureSpecification) other).getGroups().elementAt(i)); + if (!succ) + { + throw new IllFormedSpecificationException(""); + } } - } - IRule rs[] = getRules(); - for (int i = 0; i < rs.length; i++) { - spec.addConstraint((SingleDependencyConstraint)rs[i]); - } + for (int i = 0; i < groups.size(); i++) + { + boolean succ = spec.addGroup((Group) groups.elementAt(i)); + if (!succ) + { + throw new IllFormedSpecificationException(""); + } + } - rs = ((IArchitectureSpecification)other).getRules(); - for (int i = 0; i < rs.length; i++) { - spec.addConstraint((SingleDependencyConstraint)rs[i]); - } + IRule rs[] = getRules(); + for (int i = 0; i < rs.length; i++) + { + spec.addConstraint((SingleDependencyConstraint) rs[i]); + } - String wellFormedExpl = getWellFormedStatement(); - if (wellFormedExpl != null) { - throw new IllFormedSpecificationException("The composition of two specifications leads to an ill formed result!\n" + wellFormedExpl); - } - result = spec; - } else { - throw new IllFormedSpecificationException("Incompatible architecture languages, can not be analysed together."); - } - return result; - } + rs = ((IArchitectureSpecification) other).getRules(); + for (int i = 0; i < rs.length; i++) + { + spec.addConstraint((SingleDependencyConstraint) rs[i]); + } - public Vector getGroups() { - return groups; - } + String wellFormedExpl = getWellFormedStatement(); + if (wellFormedExpl != null) + { + throw new IllFormedSpecificationException( + "The composition of two specifications leads to an ill formed result!\n" + wellFormedExpl); + } + result = spec; + } + else + { + throw new IllFormedSpecificationException( + "Incompatible architecture languages, can not be analysed together."); + } + return result; + } - public IRule[] getRules() { - IRule result[] = new DependencyConstraint[rules.size()]; - for (int i = 0; i < rules.size(); i++) { - result[i] = (IRule)rules.elementAt(i); - } + public Vector getGroups() + { + return groups; + } - return result; - } + public IRule[] getRules() + { + IRule result[] = new DependencyConstraint[rules.size()]; + for (int i = 0; i < rules.size(); i++) + { + result[i] = (IRule) rules.elementAt(i); + } - public IRule[] getUnusedRules() { - IRule result[] = new DependencyConstraint[unusedRules.size()]; - for (int i = 0; i < unusedRules.size(); i++) { - result[i] = (IRule)unusedRules.elementAt(i); - } + return result; + } - return result; - } + public IRule[] getUnusedRules() + { + IRule result[] = new DependencyConstraint[unusedRules.size()]; + for (int i = 0; i < unusedRules.size(); i++) + { + result[i] = (IRule) unusedRules.elementAt(i); + } - public IRule[] getUsedRules() { - IRule result[] = new DependencyConstraint[rules.size() - unusedRules.size()]; - int j = 0; - for (int i = 0; i < rules.size(); i++) { - IRule r = (IRule)rules.elementAt(i); - if (!unusedRules.contains(r)) { - result[j++] = r; - } - } + return result; + } - return result; - } + public IRule[] getUsedRules() + { + IRule result[] = new DependencyConstraint[rules.size() - unusedRules.size()]; + int j = 0; + for (int i = 0; i < rules.size(); i++) + { + IRule r = (IRule) rules.elementAt(i); + if (!unusedRules.contains(r)) + { + result[j++] = r; + } + } - public String getWellFormedStatement() { - StringBuffer buf = new StringBuffer(); - for (int i = 0; i < rules.size() - 1; i++) { - for (int j = i + 1; j < rules.size(); j++) { - DependencyConstraint ri = (DependencyConstraint)rules.elementAt(i); - DependencyConstraint rj = (DependencyConstraint)rules.elementAt(j); - if (ri.isContradictionTo(rj)) { - buf.append("Rule contradiction found among (sensitive to order of evaluation):\n " + ri + "\n " + rj); - buf.append("\n"); + return result; + } + + public String getWellFormedStatement() + { + StringBuffer buf = new StringBuffer(); + for (int i = 0; i < rules.size() - 1; i++) + { + for (int j = i + 1; j < rules.size(); j++) + { + DependencyConstraint ri = (DependencyConstraint) rules.elementAt(i); + DependencyConstraint rj = (DependencyConstraint) rules.elementAt(j); + if (ri.isContradictionTo(rj)) + { + buf.append("Rule contradiction found among (sensitive to order of evaluation):\n " + ri + "\n " + + rj); + buf.append("\n"); + } } - } - } + } - String result = buf.toString(); - if (result.equals("")) { - result = null; - } - return result; - } + String result = buf.toString(); + if (result.equals("")) + { + result = null; + } + return result; + } - public void idiomBlockOneWay(String label, String layers[]) { - for (int i = 0; i < layers.length - 1; i++) { - String below = "{"; - for (int j = i + 1; j < layers.length; j++) { - below = below + layers[j]; - if (j < layers.length - 1) { - below = below + ", "; + public void idiomBlockOneWay(String label, String layers[]) + { + for (int i = 0; i < layers.length - 1; i++) + { + String below = "{"; + for (int j = i + 1; j < layers.length; j++) + { + below = below + layers[j]; + if (j < layers.length - 1) + { + below = below + ", "; + } } - } - below = below + "}"; - addConstraint(SingleDependencyConstraint.newNeg(layers[i], below, label)); - } + below = below + "}"; + addConstraint(SingleDependencyConstraint.newNeg(layers[i], below, label)); + } - } + } - public void idiomIsolate(String label, String layers[]) { - String reversedlayers[] = new String[layers.length]; - for (int i = 0; i < layers.length; i++) { - reversedlayers[layers.length - i - 1] = layers[i]; - } + public void idiomIsolate(String label, String layers[]) + { + String reversedlayers[] = new String[layers.length]; + for (int i = 0; i < layers.length; i++) + { + reversedlayers[layers.length - i - 1] = layers[i]; + } - idiomBlockOneWay(label, layers); - idiomBlockOneWay(label, reversedlayers); - } + idiomBlockOneWay(label, layers); + idiomBlockOneWay(label, reversedlayers); + } - public void idiomStrictlyLayer(String label, String layers[]) { - idiomBlockOneWay(label, layers); - for (int i = layers.length - 1; i >= 2; i--) { - String below = "{"; - for (int j = i - 2; j >= 0; j--) { - below = below + layers[j]; - if (j > 0) { - below = below + ", "; + public void idiomStrictlyLayer(String label, String layers[]) + { + idiomBlockOneWay(label, layers); + for (int i = layers.length - 1; i >= 2; i--) + { + String below = "{"; + for (int j = i - 2; j >= 0; j--) + { + below = below + layers[j]; + if (j > 0) + { + below = below + ", "; + } } - } - below = below + "}"; - addConstraint(SingleDependencyConstraint.newNeg(layers[i], below, label)); - } + below = below + "}"; + addConstraint(SingleDependencyConstraint.newNeg(layers[i], below, label)); + } - } + } - public void idiomTransparent(String label, String layers[]) { - String s = layers[0]; - for (int i = 1; i < layers.length; i++) { - s = s + layers[i]; - } + public void idiomTransparent(String label, String layers[]) + { + String s = layers[0]; + for (int i = 1; i < layers.length; i++) + { + s = s + layers[i]; + } - for (int i = 0; i < layers.length - 1; i++) { - for (int j = i + 1; j < layers.length; j++) { - addConstraint(SingleDependencyConstraint.newPos(layers[i], layers[j], label + " (" + layers[i] + " may * " + layers[j] + ")")); - } + for (int i = 0; i < layers.length - 1; i++) + { + for (int j = i + 1; j < layers.length; j++) + { + addConstraint(SingleDependencyConstraint.newPos(layers[i], layers[j], label + " (" + layers[i] + + " may * " + layers[j] + ")")); + } - } + } - for (int i = 0; i < layers.length - 1; i++) { - for (int j = i + 1; j < layers.length; j++) { - addConstraint(SingleDependencyConstraint.newPos(layers[j], layers[i], label + " (" + layers[j] + " may * " + layers[i] + ")")); - } + for (int i = 0; i < layers.length - 1; i++) + { + for (int j = i + 1; j < layers.length; j++) + { + addConstraint(SingleDependencyConstraint.newPos(layers[j], layers[i], label + " (" + layers[j] + + " may * " + layers[i] + ")")); + } - } + } - } + } - public boolean isEmpty() { - return rules.isEmpty(); - } + public boolean isEmpty() + { + return rules.isEmpty(); + } - boolean isMoreSpecificThan(IRule other) { - return false; - } + boolean isMoreSpecificThan(IRule other) + { + return false; + } - public IArchitectureExporter newArchitectureExporter(String filename) throws IOException { - return new DependencyConstraintExporter(filename); - } + public IArchitectureExporter newArchitectureExporter(String filename) throws IOException + { + return new DependencyConstraintExporter(filename); + } - public IDependency newDependency(String source, String target, String type, String location) { - return new Dependency(source, target, type, location); - } + public IDependency newDependency(String source, String target, String type, String location) + { + return new Dependency(source, target, type, location); + } - public IArchitectureSpecificationFilter newSpecificationFilter(String criteria[]) { - return new ArchitectureSpecificationFilter(criteria); - } + public IArchitectureSpecificationFilter newSpecificationFilter(String criteria[]) + { + return new ArchitectureSpecificationFilter(criteria); + } - public void parseFrom(String specLines[]) { - for (int i = 0; i < specLines.length; i++) { - StringBufferInputStream is = new StringBufferInputStream(specLines[i]); - PSpecLexer speclexer = new PSpecLexer(is); - PSpecParser specparser = new PSpecParser(speclexer); - try { - SingleDependencyConstraint rule = specparser.rule(); - addConstraint(rule); - } - catch (ParserException e) { - System.err.println("Specification parser exception: " + e); - System.err.println("\nin specification:\n" + specLines[i]); - throw new RuntimeException(e.toString()); - } - } + public void parseFrom(String specLines[]) + { + for (int i = 0; i < specLines.length; i++) + { + StringBufferInputStream is = new StringBufferInputStream(specLines[i]); + PSpecLexer speclexer = new PSpecLexer(is); + PSpecParser specparser = new PSpecParser(speclexer); + try + { + SingleDependencyConstraint rule = specparser.rule(); + addConstraint(rule); + } + catch (ParserException e) + { + System.err.println("Specification parser exception: " + e); + System.err.println("\nin specification:\n" + specLines[i]); + throw new RuntimeException(e.toString()); + } + } - } + } - public void parseFrom(String specification) throws IllFormedSpecificationException { - try { - ArchitectureSpecification archspec = (ArchitectureSpecification)JavaEvaluator.evalWithPrefix(specification, "import net.sf.jcontracts.idarwin.specification.impl.primitive_language.ArchitectureSpecification;\n"); - IRule rs[] = archspec.getRules(); - for (int i = 0; i < rs.length; i++) { - addConstraint((SingleDependencyConstraint)rs[i]); - } + public void parseFrom(String specification) throws IllFormedSpecificationException + { + try + { + ArchitectureSpecification archspec = (ArchitectureSpecification) JavaEvaluator + .evalWithPrefix(specification, + "import net.sf.jcontracts.idarwin.specification.impl.primitive_language.ArchitectureSpecification;\n"); + IRule rs[] = archspec.getRules(); + for (int i = 0; i < rs.length; i++) + { + addConstraint((SingleDependencyConstraint) rs[i]); + } - } - catch (Exception _ex) { - throw new RuntimeException(_ex); - } - } + } + catch (Exception _ex) + { + throw new RuntimeException(_ex); + } + } - public void parseGroupsFrom(String gs[]) { - for (int i = 0; i < gs.length; i++) { - StringBufferInputStream is = new StringBufferInputStream(gs[i]); - PSpecLexer speclexer = new PSpecLexer(is); - PSpecParser specparser = new PSpecParser(speclexer); - try { - Group g = specparser.group(); - addGroup(g); - } - catch (ParserException e) { - System.err.println("Specification parser exception: " + e); - System.err.println("\nin group definition:\n" + gs[i]); - throw new RuntimeException(e.toString()); - } - } + public void parseGroupsFrom(String gs[]) + { + for (int i = 0; i < gs.length; i++) + { + StringBufferInputStream is = new StringBufferInputStream(gs[i]); + PSpecLexer speclexer = new PSpecLexer(is); + PSpecParser specparser = new PSpecParser(speclexer); + try + { + Group g = specparser.group(); + addGroup(g); + } + catch (ParserException e) + { + System.err.println("Specification parser exception: " + e); + System.err.println("\nin group definition:\n" + gs[i]); + throw new RuntimeException(e.toString()); + } + } - } + } - public void parseIdiomsFrom(String ids[]) { - for (int i = 0; i < ids.length; i++) { - StringBufferInputStream is = new StringBufferInputStream(ids[i]); - PSpecLexer speclexer = new PSpecLexer(is); - PSpecParser specparser = new PSpecParser(speclexer); - try { - Idiom idiom = specparser.idiom(); - idiom.expand(this); - } - catch (ParserException e) { - System.err.println("Specification parser exception: " + e); - System.err.println("\nin idiom definition:\n" + ids[i]); - throw new RuntimeException(e.toString()); - } - } + public void parseIdiomsFrom(String ids[]) + { + for (int i = 0; i < ids.length; i++) + { + StringBufferInputStream is = new StringBufferInputStream(ids[i]); + PSpecLexer speclexer = new PSpecLexer(is); + PSpecParser specparser = new PSpecParser(speclexer); + try + { + Idiom idiom = specparser.idiom(); + idiom.expand(this); + } + catch (ParserException e) + { + System.err.println("Specification parser exception: " + e); + System.err.println("\nin idiom definition:\n" + ids[i]); + throw new RuntimeException(e.toString()); + } + } - } + } - public void prepareForCheck() throws IllFormedSpecificationException { - Vector substitutedrules = new Vector(); - SingleDependencyConstraint sdc; - for (Enumeration e = rules.elements(); e.hasMoreElements(); unusedRules.addElement(sdc)) { - sdc = (SingleDependencyConstraint)e.nextElement(); - try { - substitutedrules.addElement(sdc.substitute(groups)); - } - catch (IllFormedSpecificationException _ex) { - throw new RuntimeException(_ex); - } - sdc = sdc.substitute(groups); - } + public void prepareForCheck() throws IllFormedSpecificationException + { + Vector substitutedrules = new Vector(); + SingleDependencyConstraint sdc; + for (Enumeration e = rules.elements(); e.hasMoreElements(); unusedRules.addElement(sdc)) + { + sdc = (SingleDependencyConstraint) e.nextElement(); + try + { + substitutedrules.addElement(sdc.substitute(groups)); + } + catch (IllFormedSpecificationException _ex) + { + throw new RuntimeException(_ex); + } + sdc = sdc.substitute(groups); + } - rules = substitutedrules; - } + rules = substitutedrules; + } - public String reportAfterAllChecks() { - StringBuffer buf = new StringBuffer(); - if (unusedRules.size() > 0) { - buf.append("The following " + unusedRules.size() + " out of " + rules.size() + " rules were not used:\n"); - for (Enumeration e = unusedRules.elements(); e.hasMoreElements(); buf.append("\n")) { - DependencyConstraint t = (DependencyConstraint)e.nextElement(); - buf.append("- "); - buf.append(t.toString()); - } + public String reportAfterAllChecks() + { + StringBuffer buf = new StringBuffer(); + if (unusedRules.size() > 0) + { + buf.append("The following " + unusedRules.size() + " out of " + rules.size() + " rules were not used:\n"); + for (Enumeration e = unusedRules.elements(); e.hasMoreElements(); buf.append("\n")) + { + DependencyConstraint t = (DependencyConstraint) e.nextElement(); + buf.append("- "); + buf.append(t.toString()); + } - } else { - buf.append("All rules were used at least once."); - } - return buf.toString(); - } + } + else + { + buf.append("All rules were used at least once."); + } + return buf.toString(); + } - private void ruleWasUsed(SingleDependencyConstraint c) { - unusedRules.removeElement(c); - } + private void ruleWasUsed(SingleDependencyConstraint c) + { + unusedRules.removeElement(c); + } - private void sort() { - SingleDependencyConstraint arr[] = new SingleDependencyConstraint[rules.size()]; - for (int k = 0; k < rules.size(); k++) { - arr[k] = (SingleDependencyConstraint)rules.elementAt(k); - } + private void sort() + { + SingleDependencyConstraint arr[] = new SingleDependencyConstraint[rules.size()]; + for (int k = 0; k < rules.size(); k++) + { + arr[k] = (SingleDependencyConstraint) rules.elementAt(k); + } - for (int i = 0; i < rules.size() - 1; i++) { - boolean swapped = false; - for (int j = i + 1; j < rules.size() && !swapped;) { - if (arr[j].isMoreSpecificThan(arr[i])) { - SingleDependencyConstraint tmp = arr[i]; - arr[i] = arr[j]; - arr[j] = tmp; - swapped = true; - i = -1; - j = 0; - } else { - j++; + for (int i = 0; i < rules.size() - 1; i++) + { + boolean swapped = false; + for (int j = i + 1; j < rules.size() && !swapped;) + { + if (arr[j].isMoreSpecificThan(arr[i])) + { + SingleDependencyConstraint tmp = arr[i]; + arr[i] = arr[j]; + arr[j] = tmp; + swapped = true; + i = -1; + j = 0; + } + else + { + j++; + } } - } - } + } - rules = new Vector(); - for (int k = 0; k < arr.length; k++) { - rules.addElement(arr[k]); - } + rules = new Vector(); + for (int k = 0; k < arr.length; k++) + { + rules.addElement(arr[k]); + } - } + } - public String toString() { - StringBuffer buf = new StringBuffer(); - if (rules.size() <= 0) { - buf.append("An empty specification (no rules)"); - buf.append("\n"); - } else { - for (Enumeration e = rules.elements(); e.hasMoreElements(); buf.append("\n")) { - buf.append(e.nextElement()); - } + public String toString() + { + StringBuffer buf = new StringBuffer(); + if (rules.size() <= 0) + { + buf.append("An empty specification (no rules)"); + buf.append("\n"); + } + else + { + for (Enumeration e = rules.elements(); e.hasMoreElements(); buf.append("\n")) + { + buf.append(e.nextElement()); + } - } - return buf.toString(); - } + } + return buf.toString(); + } } Modified: trunk/source/java/net/sf/jcontracts/idarwin/specification/impl/primitive_language/ArchitectureSpecificationFilter.java =================================================================== --- trunk/source/java/net/sf/jcontracts/idarwin/specification/impl/primitive_language/ArchitectureSpecificationFilter.java 2006-11-27 20:14:50 UTC (rev 34) +++ trunk/source/java/net/sf/jcontracts/idarwin/specification/impl/primitive_language/ArchitectureSpecificationFilter.java 2006-11-27 20:15:57 UTC (rev 35) @@ -5,32 +5,41 @@ import net.sf.jcontracts.idarwin.specification.openapi.IArchitectureSpecificationFilter; import net.sf.jcontracts.idarwin.specification.openapi.IllFormedSpecificationException; +public class ArchitectureSpecificationFilter implements IArchitectureSpecificationFilter +{ -public class ArchitectureSpecificationFilter - implements IArchitectureSpecificationFilter { + private String criteria[]; - private String criteria[]; + ArchitectureSpecificationFilter(String criteria[]) + { + this.criteria = null; + this.criteria = criteria; + } - ArchitectureSpecificationFilter(String criteria[]) { - this.criteria = null; - this.criteria = criteria; - } - - public net.sf.jcontracts.idarwin.specification.openapi.IArchitectureSpecification filter(net.sf.jcontracts.idarwin.specification.openapi.IArchitectureSpecification original) throws IllFormedSpecificationException { - IArchitectureSpecification result = null; - if (original instanceof IArchitectureSpecification) { - ArchitectureSpecification spec = new ArchitectureSpecification(); - IRule rs[] = ((IArchitectureSpecification)original).getRules(); - for (int i = 0; i < rs.length; i++) { - if (rs[i].talksAboutAnyOf(criteria)) { - spec.addConstraint((SingleDependencyConstraint)rs[i]); + public net.sf.jcontracts.idarwin.specification.openapi.IArchitectureSpecification filter( + net.sf.jcontracts.idarwin.specification.openapi.IArchitectureSpecification original) + throws IllFormedSpecificationException + { + IArchitectureSpecification result = null; + if (original instanceof IArchitectureSpecification) + { + ArchitectureSpecification spec = new ArchitectureSpecification(); + IRule rs[] = ((IArchitectureSpecification) original).getRules(); + for (int i = 0; i < rs.length; i++) + { + if (rs[i].talksAboutAnyOf(criteria)) + { + spec.addConstraint((SingleDependencyConstraint) rs[i]); + } } - } - result = spec; - } else { - throw new IllFormedSpecificationException("Can only filter specification languages that implement net.sf.jcontracts.idarwin.specification.impl.with_rules.IArchitectureSpecification."); - } - return result; - } + result = spec; + } + else + { + throw new IllFormedSpecificationException( + "Can only filter specification languages that implement net.sf.jcontracts.idarwin.specification.impl.with_rules.IArchitectureSpecification."); + } + return result; + } } Modified: trunk/source/java/net/sf/jcontracts/idarwin/specification/impl/primitive_language/CompositePattern.java =================================================================== --- trunk/source/java/net/sf/jcontracts/idarwin/specification/impl/primitive_language/CompositePattern.java 2006-11-27 20:14:50 UTC (rev 34) +++ trunk/source/java/net/sf/jcontracts/idarwin/specification/impl/primitive_language/CompositePattern.java 2006-11-27 20:15:57 UTC (rev 35) @@ -1,8 +1,9 @@ package net.sf.jcontracts.idarwin.specification.impl.primitive_language; +abstract class CompositePattern extends Pattern +{ -abstract class CompositePattern extends Pattern { - - CompositePattern() { - } + CompositePattern() + { + } } Modified: trunk/source/java/net/sf/jcontracts/idarwin/specification/impl/primitive_language/Dependency.java =================================================================== --- trunk/source/java/net/sf/jcontracts/idarwin/specification/impl/primitive_language/Dependency.java 2006-11-27 20:14:50 UTC (rev 34) +++ trunk/source/java/net/sf/jcontracts/idarwin/specification/impl/primitive_language/Dependency.java 2006-11-27 20:15:57 UTC (rev 35) @@ -2,38 +2,46 @@ import net.sf.jcontracts.idarwin.specification.openapi.IDependency; -public class Dependency - implements IDependency { +public class Dependency implements IDependency +{ - private String source; - private String location; - private String type; - private String target; + private String source; - public Dependency(String source, String target, String type, String location) { - this.source = null; - this.location = null; - this.type = null; - this.target = null; - this.source = source; - this.target = target; - this.type = type; - this.location = location; - } + private String location; - public String getLocation() { - return location; - } + private String type; - public String getSource() { - return source; - } + private String target; - public String getTarget() { - return target; - } + public Dependency(String source, String target, String type, String location) + { + this.source = null; + this.location = null; + this.type = null; + this.target = null; + this.source = source; + this.target = target; + this.type = type; + this.location = location; + } - public String getType() { - return type; - } + public String getLocation() + { + return location; + } + + public String getSource() + { + return source; + } + + public String getTarget() + { + return target; + } + + public String getType() + { + return type; + } } Modified: trunk/source/java/net/sf/jcontracts/idarwin/specification/impl/primitive_language/DependencyConstraint.java =================================================================== --- trunk/source/java/net/sf/jcontracts/idarwin/specification/impl/primitive_language/DependencyConstraint.java 2006-11-27 20:14:50 UTC (rev 34) +++ trunk/source/java/net/sf/jcontracts/idarwin/specification/impl/primitive_language/DependencyConstraint.java 2006-11-27 20:15:57 UTC (rev 35) @@ -5,51 +5,57 @@ import net.sf.jcontracts.idarwin.specification.impl.with_rules.IRule; import net.sf.jcontracts.idarwin.specification.openapi.IDependency; -public abstract class DependencyConstraint - implements IRule { +public abstract class DependencyConstraint implements IRule +{ - protected String label; + protected String label; - public boolean equals(Object obj) { - boolean result = false; - if (obj == null) { - result = false; - } else { - result = toString().equals(obj.toString()); - } - return result; - } + public boolean equals(Object obj) + { + boolean result = false; + if (obj == null) + { + result = false; + } + else + { + result = toString().equals(obj.toString()); + } + return result; + } - protected abstract void export(StringBuffer stringbuffer); + protected abstract void export(StringBuffer stringbuffer); - protected abstract void exportMarked(StringBuffer stringbuffer); + protected abstract void exportMarked(StringBuffer stringbuffer); - protected abstract Pattern getConstraints(); + protected abstract Pattern getConstraints(); - public String getLabel() { - return label; - } + public String getLabel() + { + return label; + } - protected abstract Vector getPackageNodes(); + protected abstract Vector getPackageNodes(); - protected abstract Pattern getSourcepattern(); + protected abstract Pattern getSourcepattern(); - protected abstract Pattern getTargetpattern(); + protected abstract Pattern getTargetpattern(); - protected abstract boolean isContradictionTo(DependencyConstraint dependencyconstraint); + protected abstract boolean isContradictionTo(DependencyConstraint dependencyconstraint); - protected abstract boolean isPositive(); + protected abstract boolean isPositive(); - public abstract String printLabel(); + public abstract String printLabel(); - public abstract String toStringForDottyErrorDisplay(); + public abstract String toStringForDottyErrorDisplay(); - public DependencyConstraint() { - } + public DependencyConstraint() + { + } - public abstract boolean isMoreSpecificThan(IRule irule); + public abstract boolean isMoreSpecificThan(IRule irule); - public abstract boolean talksAboutAnyOf(String as[]); + public abstract boolean talksAboutAnyOf(String as[]); - public abstract boolean check(IDependency idependency); + public abstract boolean check(IDependency idependency); } Modified: trunk/source/java/net/sf/jcontracts/idarwin/specification/impl/primitive_language/DependencyConstraintExporter.java =================================================================== --- trunk/source/java/net/sf/jcontracts/idarwin/specification/impl/primitive_language/DependencyConstraintExporter.java 2006-11-27 20:14:50 UTC (rev 34) +++ trunk/source/java/net/sf/jcontracts/idarwin/specification/impl/primitive_language/DependencyConstraintExporter.java 2006-11-27 20:15:57 UTC (rev 35) @@ -9,159 +9,194 @@ import net.sf.jcontracts.idarwin.specification.impl.with_rules.IArchitectureSpecification; import net.sf.jcontracts.idarwin.specification.openapi.IArchitectureExporter; -public class DependencyConstraintExporter - implements IArchitectureExporter { +public class DependencyConstraintExporter implements IArchitectureExporter +{ - private PrintWriter ostream; - private String title; - private int cluster_index; - private boolean boxConstraints; + private PrintWriter ostream; - public DependencyConstraintExporter(String filename) throws IOException { - ostream = null; - title = "Title goes here ..."; - cluster_index = 1; - boxConstraints = true; - ostream = new PrintWriter(new FileOutputStream(filename)); - } + private String title; - public void close() { - ostream.println("\n}"); - ostream.close(); - } + private int cluster_index; - private void endSubGraph(String label) { - if (boxConstraints) { - ostream.println("label=\"" + label + "\";"); - ostream.println("}"); - } - } + private boolean boxConstraints; - private void export(DependencyConstraint dc) { - StringBuffer buf = new StringBuffer(); - startSubGraph(); - dc.export(buf); - ostream.println(buf.toString()); - endSubGraph(dc.getLabel()); - } + public DependencyConstraintExporter(String filename) throws IOException + { + ostream = null; + title = "Title goes here ..."; + cluster_index = 1; + boxConstraints = true; + ostream = new PrintWriter(new FileOutputStream(filename)); + } - public void export(net.sf.jcontracts.idarwin.specification.openapi.IArchitectureSpecification specification) throws IOException { - Vector dcs = new Vector(); - net.sf.jcontracts.idarwin.specification.impl.with_rules.IRule usedrules[] = ((IArchitectureSpecification)specification).getUsedRules(); - for (int i = 0; i < usedrules.length; i++) { - dcs.addElement(usedrules[i]); - export((DependencyConstraint)usedrules[i]); - } + public void close() + { + ostream.println("\n}"); + ostream.close(); + } - net.sf.jcontracts.idarwin.specification.impl.with_rules.IRule unusedrules[] = ((IArchitectureSpecification)specification).getUnusedRules(); - for (int i = 0; i < unusedrules.length; i++) { - dcs.addElement(unusedrules[i]); - exportMarked((DependencyConstraint)unusedrules[i]); - } + private void endSubGraph(String label) + { + if (boxConstraints) + { + ostream.println("label=\"" + label + "\";"); + ostream.println("}"); + } + } - export(dcs); - } + private void export(DependencyConstraint dc) + { + StringBuffer buf = new StringBuffer(); + startSubGraph(); + dc.export(buf); + ostream.println(buf.toString()); + endSubGraph(dc.getLabel()); + } - private void export(Vector dcs) { - Vector allNodes = new Vector(); - for (Enumeration e = dcs.elements(); e.hasMoreElements();) { - DependencyConstraint dc = (DependencyConstraint)e.nextElement(); - for (Enumeration enum2 = dc.getPackageNodes().elements(); enum2.hasMoreElements();) { - Pattern el = (Pattern)enum2.nextElement(); - if (!allNodes.contains(el)) { - allNodes.addElement(el); - } - } + public void export(net.sf.jcontracts.idarwin.specification.openapi.IArchitectureSpecification specification) + throws IOException + { + Vector dcs = new Vector(); + net.sf.jcontracts.idarwin.specification.impl.with_rules.IRule usedrules[] = ((IArchitectureSpecification) specification) + .getUsedRules(); + for (int i = 0; i < usedrules.length; i++) + { + dcs.addElement(usedrules[i]); + export((DependencyConstraint) usedrules[i]); + } - } + net.sf.jcontracts.idarwin.specification.impl.with_rules.IRule unusedrules[] = ((IArchitectureSpecification) specification) + .getUnusedRules(); + for (int i = 0; i < unusedrules.length; i++) + { + dcs.addElement(unusedrules[i]); + exportMarked((DependencyConstraint) unusedrules[i]); + } - boolean show_package_subsumption = false; - if (show_package_subsumption) { - for (int i = 0; i < allNodes.size() - 1; i++) { - Pattern pattern = (Pattern)allNodes.elementAt(i); - for (int j = i + 1; j < allNodes.size(); j++) { - Pattern element = (Pattern)allNodes.elementAt(j); - if (pattern.match(element)) { - ostream.println(element.mangle()); - ostream.println(" -> "); - ostream.println(pattern.mangle()); - ostream.println(" [weight=20,color=black,style=dotted]\n"); - } - if (element.match(pattern)) { - ostream.println(pattern.mangle()); - ostream.println(" -> "); - ostream.println(element.mangle()); - ostream.println(" [weight=20,color=black,style=dotted]\n"); - } + export(dcs); + } + + private void export(Vector dcs) + { + Vector allNodes = new Vector(); + for (Enumeration e = dcs.elements(); e.hasMoreElements();) + { + DependencyConstraint dc = (DependencyConstraint) e.nextElement(); + for (Enumeration enum2 = dc.getPackageNodes().elements(); enum2.hasMoreElements();) + { + Pattern el = (Pattern) enum2.nextElement(); + if (!allNodes.contains(el)) + { + allNodes.addElement(el); + } } - } + } - } - for (int i = 0; i < dcs.size() - 1; i++) { - SingleDependencyConstraint c1 = (SingleDependencyConstraint)dcs.elementAt(i); - for (int j = i + 1; j < dcs.size(); j++) { - SingleDependencyConstraint c2 = (SingleDependencyConstraint)dcs.elementAt(j); - if (c1.isMoreSpecificThan(c2) && (c1.isPositive() && !c2.isPositive() || !c1.isPositive() && c2.isPositive())) { - StringBuffer buf = new StringBuffer(); - c2.exportOperatorNode(buf); - buf.append(" -> "); - c1.exportOperatorNode(buf); - buf.append(" [color=blue,label=\"except\"]\n"); - ostream.print(buf.toString()); + boolean show_package_subsumption = false; + if (show_package_subsumption) + { + for (int i = 0; i < allNodes.size() - 1; i++) + { + Pattern pattern = (Pattern) allNodes.elementAt(i); + for (int j = i + 1; j < allNodes.size(); j++) + { + Pattern element = (Pattern) allNodes.elementAt(j); + if (pattern.match(element)) + { + ostream.println(element.mangle()); + ostream.println(" -> "); + ostream.println(pattern.mangle()); + ostream.println(" [weight=20,color=black,style=dotted]\n"); + } + if (element.match(pattern)) + { + ostream.println(pattern.mangle()); + ostream.println(" -> "); + ostream.println(element.mangle()); + ostream.println(" [weight=20,color=black,style=dotted]\n"); + } + } + } - if (c2.isMoreSpecificThan(c1) && (c1.isPositive() && !c2.isPositive() || !c1.isPositive() && c2.isPositive())) { - StringBuffer buf = new StringBuffer(); - c1.exportOperatorNode(buf); - buf.append(" -> "); - c2.exportOperatorNode(buf); - buf.append(" [color=blue,label=\"except\"]\n"); - ostream.print(buf.toString()); + + } + for (int i = 0; i < dcs.size() - 1; i++) + { + SingleDependencyConstraint c1 = (SingleDependencyConstraint) dcs.elementAt(i); + for (int j = i + 1; j < dcs.size(); j++) + { + SingleDependencyConstraint c2 = (SingleDependencyConstraint) dcs.elementAt(j); + if (c1.isMoreSpecificThan(c2) + && (c1.isPositive() && !c2.isPositive() || !c1.isPositive() && c2.isPositive())) + { + StringBuffer buf = new StringBuffer(); + c2.exportOperatorNode(buf); + buf.append(" -> "); + c1.exportOperatorNode(buf); + buf.append(" [color=blue,label=\"except\"]\n"); + ostream.print(buf.toString()); + } + if (c2.isMoreSpecificThan(c1) + && (c1.isPositive() && !c2.isPositive() || !c1.isPositive() && c2.isPositive())) + { + StringBuffer buf = new StringBuffer(); + c1.exportOperatorNode(buf); + buf.append(" -> "); + c2.exportOperatorNode(buf); + buf.append(" [color=blue,label=\"except\"]\n"); + ostream.print(buf.toString()); + } + if (c1.isContradictionTo(c2)) + { + StringBuffer buf = new StringBuffer(); + c1.exportOperatorNode(buf); + buf.append(" -> "); + c2.exportOperatorNode(buf); + buf.append(" [color=orange,style=bold,label=\"ERROR\"]\n"); + ostream.print(buf.toString()); + } + if (c2.isContradictionTo(c1)) + { + StringBuffer buf = new StringBuffer(); + c1.exportOperatorNode(buf); + buf.append(" -> "); + c2.exportOperatorNode(buf); + buf.append(" [color=orange,style=bold,label=\"ERROR\"]\n"); + ostream.print(buf.toString()); + } } - if (c1.isContradictionTo(c2)) { - StringBuffer buf = new StringBuffer(); - c1.exportOperatorNode(buf); - buf.append(" -> "); - c2.exportOperatorNode(buf); - buf.append(" [color=orange,style=bold,label=\"ERROR\"]\n"); - ostream.print(buf.toString()); - } - if (c2.isContradictionTo(c1)) { - StringBuffer buf = new StringBuffer(); - c1.exportOperatorNode(buf); - buf.append(" -> "); - c2.exportOperatorNode(buf); - buf.append(" [color=orange,style=bold,label=\"ERROR\"]\n"); - ostream.print(buf.toString()); - } - } - } + } - } + } - private void exportMarked(DependencyConstraint dc) { - StringBuffer buf = new StringBuffer(); - startSubGraph(); - dc.exportMarked(buf); - ostream.println(buf.toString()); - endSubGraph(dc.getLabel()); - } + private void exportMarked(DependencyConstraint dc) + { + StringBuffer buf = new StringBuffer(); + startSubGraph(); + dc.exportMarked(buf); + ostream.println(buf.toString()); + endSubGraph(dc.getLabel()); + } - public void open() { - new StringBuffer(); - ostream.println("digraph \"" + title + "\" {"); - ostream.println("fontsize=12;"); - ostream.println("fontname=\"Helvetica\""); - } + public void open() + { + new StringBuffer(); + ostream.println("digraph \"" + title + "\" {"); + ostream.println("fontsize=12;"); + ostream.println("fontname=\"Helvetica\""); + } - private void startSubGraph() { - if (boxConstraints) { - ostream.println("subgraph cluster_" + cluster_index + " {"); - ostream.println("color=gray;"); - ostream.println("fontname=Helvetica;"); - ostream.println("fontsize=12;"); - cluster_index++; - } - } + private void startSubGraph() + { + if (boxConstraints) + { + ostream.println("subgraph cluster_" + cluster_index + " {"); + ostream.println("color=gray;"); + ostream.println("fontname=Helvetica;"); + ostream.println("fontsize=12;"); + cluster_index++; + } + } } Modified: trunk/source/java/net/sf/jcontracts/idarwin/specification/impl/primitive_language/DifferencePattern.java =================================================================== --- trunk/source/java/net/sf/jcontracts/idarwin/specification/impl/primitive_language/DifferencePattern.java 2006-11-27 20:14:50 UTC (rev 34) +++ trunk/source/java/net/sf/jcontracts/idarwin/specification/impl/primitive_language/DifferencePattern.java 2006-11-27 20:15:57 UTC (rev 35) @@ -1,58 +1,70 @@ package net.sf.jcontracts.idarwin.specification.impl.primitive_language; +class DifferencePattern extends CompositePattern +{ -class DifferencePattern extends CompositePattern { + private Pattern positive; - private Pattern positive; - private Pattern negative; + private Pattern negative; - DifferencePattern(Pattern positive, Pattern negative) { - this.positive = null; - this.negative = null; - this.positive = positive; - this.negative = negative; - } + DifferencePattern(Pattern positive, Pattern negative) + { + this.positive = null; + this.negative = null; + this.positive = positive; + this.negative = negative; + } - String mangle() { - return positive.mangle() + "__" + negative.mangle(); - } + String mangle() + { + return positive.mangle() + "__" + negative.mangle(); + } - public boolean match(Pattern p) { - boolean res = positive.match(p) && !negative.match(p); - return res; - } + public boolean match(Pattern p) + { + boolean res = positive.match(p) && !negative.match(p); + return res; + } - public boolean match(String s) { - return positive.match(s) && !negative.match(s); - } + public boolean match(String s) + { + return positive.match(s) && !negative.match(s); + } - boolean specifiesASingleType() { - return false; - } + boolean specifiesASingleType() + { + return false; + } - public boolean talksAboutAnyOf(String criteria[]) { - boolean found = false; - if (criteria == null) { - found = true; - } else { - found = negative.talksAboutAnyOf(criteria) || positive.talksAboutAnyOf(criteria); - } - return found; - } + public boolean talksAboutAnyOf(String criteria[]) + { + boolean found = false; + if (criteria == null) + { + found = true; + } + else + { + found = negative.talksAboutAnyOf(criteria) || positive.talksAboutAnyOf(criteria); + } + return found; + } - public String toDisplayString() { - StringBuffer sb = new StringBuffer(); - sb.append(positive.toDisplayString()); - sb.append("\\n\\\\n"); - sb.append(negative.toDisplayString()); - return sb.toString(); - } + public String toDisplayString() + { + StringBuffer sb = new StringBuffer(); + sb.append(positive.toDisplayString()); + sb.append("\\n\\\\n"); + sb.append(negative.toDisplayString()); + return sb.toString(); + } - public String toString() { - StringBuffer sb = new StringBuffer(); - sb.append(positive); - sb.append(" \\ "); - sb.append(negative); - return sb.toString(); - } + public String toString() + { + StringBuffer sb = new StringBuffer(); + sb.append(positive); + sb.append(" \\ "); + sb.append(negative); + return sb.toString(); + } } Modified: trunk/source/java/net/sf/jcontracts/idarwin/specification/impl/primitive_language/Group.java =================================================================== --- trunk/source/java/net/sf/jcontracts/idarwin/specification/impl/primitive_language/Group.java 2006-11-27 20:14:50 UTC (rev 34) +++ trunk/source/java/net/sf/jcontracts/idarwin/specification/impl/primitive_language/Group.java 2006-11-27 20:15:57 UTC (rev 35) @@ -1,73 +1,85 @@ package net.sf.jcontracts.idarwin.specification.impl.primitive_language; +public class Group +{ -public class Group { + private Pattern pattern; - private Pattern pattern; - private String label; + private String label; - public Group(String label, Pattern pattern) { - this.pattern = null; - this.label = null; - this.pattern = pattern; - this.label = label; - } + public Group(String label, Pattern pattern) + { + this.pattern = null; + this.label = null; + this.pattern = pattern; + this.label = label; + } - private String basicRemoveIfsubstitutedIn(String r) { - StringBuffer buf = new StringBuffer(); - String tag = "[" + label + "]"; - String inset = ""; - int lastpos = 0; - for (int pos = -1; (pos = r.indexOf(tag, lastpos)) != -1;) { - buf.append(r.substring(lastpos, pos... [truncated message content] |