1 8 9 package net.sourceforge.chaperon.model.extended; 10 11 import net.sourceforge.chaperon.model.Violations; 12 13 17 public class OneOrMore extends PatternList 18 { 19 public OneOrMore() {} 20 21 public void update() 22 { 23 super.update(); 24 25 PatternSet firstSet = getFirstSet(); 26 for (PatternIterator i = getLastSet().getPattern(); i.hasNext();) 27 { 28 Pattern lastPattern = i.next(); 29 for (PatternIterator j = firstSet.getPattern(); j.hasNext();) 30 { 31 Pattern firstPattern = j.next(); 32 lastPattern.addSuccessor(firstPattern); 33 } 34 } 35 } 36 37 42 public String toString() 43 { 44 StringBuffer buffer = new StringBuffer (); 45 46 if (getPatternCount()>0) 47 { 48 buffer.append(super.toString()); 49 buffer.append("+"); 50 } 51 52 return buffer.toString(); 53 } 54 55 public String toString(PatternSet previous, PatternSet next) 56 { 57 StringBuffer buffer = new StringBuffer (); 58 59 if (getPatternCount()>0) 60 { 61 buffer.append(super.toString(previous, next)); 62 buffer.append("+"); 63 } 64 65 return buffer.toString(); 66 } 67 68 75 public Object clone() throws CloneNotSupportedException 76 { 77 OneOrMore clone = new OneOrMore(); 78 79 for (int i = 0; i<getPatternCount(); i++) 80 clone.addPattern((Pattern)getPattern(i).clone()); 81 82 return clone; 83 } 84 85 90 public Violations validate() 91 { 92 Violations violations = new Violations(); 93 94 97 for (int i = 0; i<getPatternCount(); i++) 98 violations.addViolations(getPattern(i).validate()); 99 100 return violations; 101 } 102 } 103 | Popular Tags |