1 package org.apache.fulcrum.intake.xmlmodel; 2 3 56 57 import org.xml.sax.Attributes ; 58 import org.apache.fulcrum.intake.validator.Constraint; 59 60 66 public class Rule 67 implements Constraint, java.io.Serializable 68 { 69 private String name; 70 private String value; 71 private String message; 72 private XmlField parent; 73 74 77 public Rule() 78 { 79 } 80 81 84 public void loadFromXML (Attributes attrib) 85 { 86 setName(attrib.getValue("name")); 87 setValue(attrib.getValue("value")); 88 } 89 90 93 public void setName(String newName) 94 { 95 name = newName; 96 } 97 100 public String getName() 101 { 102 return name; 103 } 104 105 108 public void setValue(String newValue) 109 { 110 value = newValue; 111 } 112 115 public String getValue() 116 { 117 return value; 118 } 119 120 123 public void setMessage(String newMessage) 124 { 125 message = newMessage; 126 } 127 128 131 public String getMessage() 132 { 133 return message; 134 } 135 136 139 public void setField(XmlField parent) 140 { 141 this.parent = parent; 142 } 143 144 147 public XmlField getField() 148 { 149 return parent; 150 } 151 152 156 public String toString() 157 { 158 StringBuffer result = new StringBuffer (100); 159 160 result.append("<rule name=\""+name+"\"") 161 .append(" value=\""+value+"\""); 162 163 164 if (message == null) 165 { 166 result.append(" />\n"); 167 } 168 else 169 { 170 result.append(">") 171 .append(message) 172 .append("</rule>\n"); 173 } 174 175 return result.toString(); 176 } 177 178 } 179 180 181 182 | Popular Tags |