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 CharacterSet implements CharacterClassElement 21 { 22 private String set = ""; 23 private String location = null; 24 25 28 public CharacterSet() {} 29 30 35 public void setCharacters(String set) 36 { 37 this.set = set; 38 } 39 40 45 public String getCharacters() 46 { 47 return set; 48 } 49 50 55 public void setLocation(String location) 56 { 57 this.location = location; 58 } 59 60 65 public String getLocation() 66 { 67 return location; 68 } 69 70 75 public String toString() 76 { 77 return Decoder.decode(set, Decoder.CLASS); 78 } 79 80 87 public Object clone() 88 { 89 CharacterSet clone = new CharacterSet(); 90 91 clone.setCharacters(getCharacters()); 92 93 return clone; 94 } 95 96 101 public Violations validate() 102 { 103 Violations violations = new Violations(); 104 105 if ((set==null) || (set.length()==0)) 106 violations.addViolation("Character set contains no characters", getLocation()); 107 108 return violations; 109 } 110 } 111 | Popular Tags |