1 8 9 package net.sourceforge.chaperon.model.extended; 10 11 import net.sourceforge.chaperon.model.Violations; 12 13 19 public class Element extends Pattern 20 { 21 private String symbol = null; 22 private String location = null; 23 24 public Element() {} 25 26 31 public Element(String symbol) 32 { 33 this.symbol = symbol; 34 } 35 36 public void setSymbol(String symbol) 37 { 38 this.symbol = symbol; 39 } 40 41 public String getSymbol() 42 { 43 return symbol; 44 } 45 46 public boolean isNullable() 47 { 48 return false; 49 } 50 51 public PatternSet getFirstSet() 52 { 53 PatternSet set = new PatternSet(); 54 set.addPattern(this); 55 return set; 56 } 57 58 public PatternSet getLastSet() 59 { 60 PatternSet set = new PatternSet(); 61 set.addPattern(this); 62 return set; 63 } 64 65 public char[] getLimits() 66 { 67 return new char[0]; 68 } 69 70 public boolean contains(char minimum, char maximum) 71 { 72 return false; 73 } 74 75 public boolean contains(char c) 76 { 77 return false; 78 } 79 80 85 public void setLocation(String location) 86 { 87 this.location = location; 88 } 89 90 95 public String getLocation() 96 { 97 return location; 98 } 99 100 107 public Object clone() 108 { 109 Element clone = new Element(symbol); 110 111 return clone; 112 } 113 114 119 public Violations validate() 120 { 121 Violations violations = new Violations(); 122 123 if (symbol==null) 124 violations.addViolation("No symbol defined for element", location); 125 126 return violations; 127 } 128 129 public String toString() 130 { 131 StringBuffer buffer = new StringBuffer (); 132 buffer.append(symbol); 133 buffer.append("["); 134 buffer.append(index); 135 buffer.append("]"); 136 return buffer.toString(); 137 } 138 } 139 | Popular Tags |