%line | %branch | |||||||||
---|---|---|---|---|---|---|---|---|---|---|
org.apache.turbine.util.FormMessage |
|
|
1 | package org.apache.turbine.util; |
|
2 | ||
3 | /* |
|
4 | * Copyright 2001-2005 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.util.Vector; |
|
20 | ||
21 | /** |
|
22 | * A message class for holding information about a message that |
|
23 | * relates to a specific form and field. Used together with |
|
24 | * FormMessages class. |
|
25 | * |
|
26 | * @author <a href="mailto:neeme@one.lv">Neeme Praks</a> |
|
27 | * @version $Id: FormMessage.java 264148 2005-08-29 14:21:04Z henning $ |
|
28 | */ |
|
29 | public class FormMessage |
|
30 | { |
|
31 | private String message; |
|
32 | private String formName; |
|
33 | private Vector fieldNames; |
|
34 | ||
35 | /** |
|
36 | * Constructor. |
|
37 | */ |
|
38 | public FormMessage() |
|
39 | 4 | { |
40 | 4 | fieldNames = new Vector(); |
41 | 4 | } |
42 | ||
43 | /** |
|
44 | * Constructor. |
|
45 | * |
|
46 | * @param formName A String with the form name. |
|
47 | */ |
|
48 | public FormMessage(String formName) |
|
49 | { |
|
50 | 4 | this(); |
51 | 4 | setFormName(formName); |
52 | 4 | } |
53 | ||
54 | /** |
|
55 | * Constructor. |
|
56 | * |
|
57 | * @param formName A String with the form name. |
|
58 | * @param fieldName A String with the field name. |
|
59 | */ |
|
60 | public FormMessage(String formName, |
|
61 | String fieldName) |
|
62 | { |
|
63 | 4 | this(formName); |
64 | 4 | setFieldName(fieldName); |
65 | 4 | } |
66 | ||
67 | /** |
|
68 | * Constructor. |
|
69 | * |
|
70 | * @param formName A String with the form name. |
|
71 | * @param fieldName A String with the field name. |
|
72 | * @param message A String with the message. |
|
73 | */ |
|
74 | public FormMessage(String formName, |
|
75 | String fieldName, |
|
76 | String message) |
|
77 | { |
|
78 | 4 | this(formName, fieldName); |
79 | 4 | setMessage(message); |
80 | 4 | } |
81 | ||
82 | /** |
|
83 | * Return the message. |
|
84 | * |
|
85 | * @return A String with the message. |
|
86 | */ |
|
87 | public String getMessage() |
|
88 | { |
|
89 | 4 | return message; |
90 | } |
|
91 | ||
92 | /** |
|
93 | * Return the form name. |
|
94 | * |
|
95 | * @return A String with the form name. |
|
96 | */ |
|
97 | public String getFormName() |
|
98 | { |
|
99 | 4 | return formName; |
100 | } |
|
101 | ||
102 | /** |
|
103 | * Return the field names. |
|
104 | * |
|
105 | * @return A String[] with the field names. |
|
106 | */ |
|
107 | public String[] getFieldNames() |
|
108 | { |
|
109 | 16 | String[] result = new String[fieldNames.size()]; |
110 | 16 | fieldNames.copyInto(result); |
111 | 16 | return result; |
112 | } |
|
113 | ||
114 | /** |
|
115 | * Set the message. |
|
116 | * |
|
117 | * @param message A String with the message. |
|
118 | */ |
|
119 | public void setMessage(String message) |
|
120 | { |
|
121 | 4 | this.message = message; |
122 | 4 | } |
123 | ||
124 | /** |
|
125 | * Set the form name. |
|
126 | * |
|
127 | * @param formName A String with the form name. |
|
128 | */ |
|
129 | public void setFormName(String formName) |
|
130 | { |
|
131 | 4 | this.formName = formName; |
132 | 4 | } |
133 | ||
134 | /** |
|
135 | * Adds one field name. |
|
136 | * |
|
137 | * @param fieldName A String with the field name. |
|
138 | */ |
|
139 | public void setFieldName(String fieldName) |
|
140 | { |
|
141 | 6 | fieldNames.addElement(fieldName); |
142 | 6 | } |
143 | ||
144 | /** |
|
145 | * Write out the contents of the message in a friendly manner. |
|
146 | * |
|
147 | */ |
|
148 | public String toString() |
|
149 | { |
|
150 | 4 | StringBuffer sb = new StringBuffer("formName:" + getFormName() + ", fieldNames:"); |
151 | 10 | for (int i = 0; i< getFieldNames().length; i++){ |
152 | 6 | sb.append(getFieldNames()[i] + " "); |
153 | } |
|
154 | 4 | sb.append(", message:" + getMessage()); |
155 | ||
156 | 4 | return sb.toString(); |
157 | } |
|
158 | } |
This report is generated by jcoverage, Maven and Maven JCoverage Plugin. |