1 8 9 package net.sourceforge.chaperon.model.pattern; 10 11 import net.sourceforge.chaperon.common.Decoder; 12 import net.sourceforge.chaperon.model.Violations; 13 14 20 public class CharacterInterval implements CharacterClassElement 21 { 22 private char minimum = 'a'; 23 private char maximum = 'z'; 24 private String location = null; 25 26 29 public CharacterInterval() {} 30 31 36 public void setMinimum(char minimum) 37 { 38 this.minimum = minimum; 39 } 40 41 46 public char getMinimum() 47 { 48 return this.minimum; 49 } 50 51 56 public void setMaximum(char maximum) 57 { 58 this.maximum = maximum; 59 } 60 61 66 public char getMaximum() 67 { 68 return this.maximum; 69 } 70 71 76 public void setLocation(String location) 77 { 78 this.location = location; 79 } 80 81 86 public String getLocation() 87 { 88 return location; 89 } 90 91 96 public String toString() 97 { 98 StringBuffer buffer = new StringBuffer (); 99 100 buffer.append(Decoder.decode(this.minimum, Decoder.CLASS)); 101 buffer.append("-"); 102 buffer.append(Decoder.decode(this.maximum, Decoder.CLASS)); 103 return buffer.toString(); 104 } 105 106 113 public Object clone() 114 { 115 CharacterInterval clone = new CharacterInterval(); 116 117 clone.setMinimum(getMinimum()); 118 clone.setMaximum(getMaximum()); 119 120 return clone; 121 } 122 123 128 public Violations validate() 129 { 130 Violations violations = new Violations(); 131 132 if (minimum>maximum) 133 violations.addViolation("Minimum is greater than the maximum", getLocation()); 134 135 if (minimum==maximum) 136 violations.addViolation("Minimum is equal than the maximum", getLocation()); 137 138 return violations; 139 } 140 } 141 | Popular Tags |