%line | %branch | |||||||||
---|---|---|---|---|---|---|---|---|---|---|
org.apache.turbine.services.intake.xmlmodel.Rule |
|
|
1 | package org.apache.turbine.services.intake.xmlmodel; |
|
2 | ||
3 | /* |
|
4 | * Copyright 2001-2004 The Apache Software Foundation. |
|
5 | * |
|
6 | * Licensed under the Apache License, Version 2.0 (the "License") |
|
7 | * you may not use this file except in compliance with the License. |
|
8 | * You may obtain a copy of the License at |
|
9 | * |
|
10 | * http://www.apache.org/licenses/LICENSE-2.0 |
|
11 | * |
|
12 | * Unless required by applicable law or agreed to in writing, software |
|
13 | * distributed under the License is distributed on an "AS IS" BASIS, |
|
14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
|
15 | * See the License for the specific language governing permissions and |
|
16 | * limitations under the License. |
|
17 | */ |
|
18 | ||
19 | import java.io.Serializable; |
|
20 | ||
21 | import org.apache.turbine.services.intake.validator.Constraint; |
|
22 | ||
23 | import org.xml.sax.Attributes; |
|
24 | ||
25 | /** |
|
26 | * A Class for holding data about a constraint on a property. |
|
27 | * |
|
28 | * @author <a href="mailto:jmcnally@collab.net">John McNally</a> |
|
29 | * @version $Id: Rule.java,v 1.5.2.2 2004/05/20 03:06:49 seade Exp $ |
|
30 | */ |
|
31 | public class Rule |
|
32 | implements Constraint, Serializable |
|
33 | { |
|
34 | private String name; |
|
35 | private String value; |
|
36 | private String message; |
|
37 | private XmlField parent; |
|
38 | ||
39 | /** |
|
40 | * Default Constructor |
|
41 | */ |
|
42 | public Rule() |
|
43 | 0 | { |
44 | 0 | } |
45 | ||
46 | /** |
|
47 | * Imports a column from an XML specification |
|
48 | */ |
|
49 | public void loadFromXML(Attributes attrib) |
|
50 | { |
|
51 | 0 | setName(attrib.getValue("name")); |
52 | 0 | setValue(attrib.getValue("value")); |
53 | 0 | } |
54 | ||
55 | /** |
|
56 | * Set the name of the parameter |
|
57 | */ |
|
58 | public void setName(String newName) |
|
59 | { |
|
60 | 0 | name = newName; |
61 | 0 | } |
62 | ||
63 | /** |
|
64 | * Get the name of the parameter |
|
65 | */ |
|
66 | public String getName() |
|
67 | { |
|
68 | 0 | return name; |
69 | } |
|
70 | ||
71 | /** |
|
72 | * Set the value of the parameter |
|
73 | */ |
|
74 | public void setValue(String newValue) |
|
75 | { |
|
76 | 0 | value = newValue; |
77 | 0 | } |
78 | ||
79 | /** |
|
80 | * Get the value of the parameter |
|
81 | */ |
|
82 | public String getValue() |
|
83 | { |
|
84 | 0 | return value; |
85 | } |
|
86 | ||
87 | /** |
|
88 | * Set the error message |
|
89 | */ |
|
90 | public void setMessage(String newMessage) |
|
91 | { |
|
92 | 0 | message = newMessage; |
93 | 0 | } |
94 | ||
95 | /** |
|
96 | * Get the error message |
|
97 | */ |
|
98 | public String getMessage() |
|
99 | { |
|
100 | 0 | return message; |
101 | } |
|
102 | ||
103 | /** |
|
104 | * Set the parent Field of the rule |
|
105 | */ |
|
106 | public void setField(XmlField parent) |
|
107 | { |
|
108 | 0 | this.parent = parent; |
109 | 0 | } |
110 | ||
111 | /** |
|
112 | * Get the parent Field of the rule |
|
113 | */ |
|
114 | public XmlField getField() |
|
115 | { |
|
116 | 0 | return parent; |
117 | } |
|
118 | ||
119 | /** |
|
120 | * String representation of the column. This |
|
121 | * is an xml representation. |
|
122 | */ |
|
123 | public String toString() |
|
124 | { |
|
125 | 0 | StringBuffer result = new StringBuffer(100); |
126 | ||
127 | 0 | result.append("<rule name=\"" + name + "\"") |
128 | .append(" value=\"" + value + "\""); |
|
129 | ||
130 | 0 | if (message == null) |
131 | { |
|
132 | 0 | result.append(" />\n"); |
133 | } |
|
134 | else |
|
135 | { |
|
136 | 0 | result.append(">") |
137 | .append(message) |
|
138 | .append("</rule>\n"); |
|
139 | } |
|
140 | ||
141 | 0 | return result.toString(); |
142 | } |
|
143 | ||
144 | } |
|
145 | ||
146 | ||
147 |
This report is generated by jcoverage, Maven and Maven JCoverage Plugin. |