1 /***
2 * Copyright (c) 2002, CodeStreet LLC. All rights reserved.<p>
3 * Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following
4 * conditions are met:<p>
5 * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
6 * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer
7 * in the documentation and/or other materials provided with the distribution. Neither the name of CodeStreet LLC. nor the
8 * names of its contributors may be used to endorse or promote products derived from this software without specific prior written
9 * permission.<p>
10 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT
11 * NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
12 * THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
13 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
14 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
15 * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.<p>
16 */
17
18 package com.codestreet.messageforge;
19
20 /***
21 * Interface supported by all RMsg objects. This interface is patterned on the
22 * <tt>MapMessage</tt> interface found in the JMS messaging library.
23 * @author Jawaid Hakim.
24 */
25 public interface RMapMessage extends java.io.Serializable
26 {
27 /***
28 * Apply a functor to all fields in the message.
29 * @param func Functor
30 * @return The number of fields to which the functor was applied.
31 * @see RFunctor
32 */
33 int apply(RFunctor func) throws ProtocolException, FieldValidationException;
34
35 /***
36 * Apply a functor to a named field in the message.
37 * @param func Functor
38 * @return <tt>true</tt> if the named field was found and the
39 * functor was applied to it.
40 * @see RFunctor
41 */
42 boolean apply(RFunctor func, String name) throws ProtocolException, FieldValidationException;
43
44 /***
45 * Get the value of a datetime field. A reference to the data is returned so
46 * be careful about modifying the data through the reference.
47 * @param name Field name.
48 * @return Date
49 */
50 java.util.Date getDate(String name) throws FieldValidationException;
51
52 /***
53 * Get the name of the message.
54 * @return Message name.
55 */
56 String getName();
57
58 /***
59 * Get the value of a boolean field.
60 * @param name Field name.
61 * @return Field value.
62 */
63 boolean getBoolean(String name) throws FieldValidationException;
64
65 /***
66 * Get the value of a opaque field. A reference to the data is returned so
67 * be careful about modifying the data through the reference.
68 * @param name Field name.
69 * @return Field value.
70 */
71 byte[] getBytes(String name) throws FieldValidationException;
72
73 /***
74 * Get the value of a float field.
75 * @param name Field name.
76 * @return Field value.
77 * @see RFldF32
78 */
79 float getFloat(String name) throws FieldValidationException;
80
81
82 /***
83 * Get the value of a double field.
84 * @param name Field name.
85 * @return Field value.
86 */
87 double getDouble(String name) throws FieldValidationException;
88
89
90 /***
91 * Get the value of a byte field.
92 * @param name Field name.
93 * @return Field value.
94 */
95 byte getByte(String name) throws FieldValidationException;
96
97 /***
98 * Get the value of a short field.
99 * @param name Field name.
100 * @return Field value.
101 */
102 short getShort(String name) throws FieldValidationException;
103
104
105 /***
106 * Get the value of a integer field.
107 * @param name Field name.
108 * @return Field value.
109 */
110 int getInt(String name) throws FieldValidationException;
111
112
113 /***
114 * Get the value of a long field.
115 * @param name Field name.
116 * @return Field value.
117 */
118 long getLong(String name) throws FieldValidationException;
119
120 /***
121 * Get the value of a string field.
122 * @param name Field name.
123 * @return Field value.
124 */
125 String getString(String name) throws FieldValidationException;
126
127 /***
128 * Get the value of a memos field.
129 * @param name Field name.
130 * @return Field value.
131 */
132 String getMemo(String name) throws FieldValidationException;
133
134 /***
135 * Get the value of a <tt>RFldTibrvMsg</tt> field.
136 * @param name Field name.
137 * @return Field value.
138 */
139 Object getTibrvMsg(String name) throws FieldValidationException;
140
141 /***
142 * Get the value of a Opaque field.
143 * @param name Field name.
144 * @return Field value.
145 */
146 byte[] getOpaque(String name) throws FieldValidationException;
147
148 /***
149 * Get the value of a field. A reference to the data is returned so
150 * be careful about modifying the data through the reference.
151 * @param name Field name.
152 * @return Field value.
153 */
154 Object getFieldValueAsObject(String name) throws FieldValidationException;
155
156 /***
157 * Get field value as string.
158 * @param name Field name.
159 * @return Field value.
160 */
161 String getFieldValueAsString(String name) throws FieldValidationException;
162
163 /***
164 * Set the value of a datetime field.
165 * @param name Field name.
166 * @param val Field value.
167 * @see RFldDatetime
168 */
169 void setDate(String name, java.util.Date val) throws FieldValidationException;
170
171 /***
172 * Set the value of a datetime field.
173 * @param name Field name.
174 * @param val Field value.
175 * @see RFldDatetime
176 */
177 void setDate(String name, long val) throws FieldValidationException;
178
179 /***
180 * Get the value of a boolean field.
181 * @param name Field name.
182 * @param val Field value.
183 * @see RFldBool
184 */
185 void setBoolean(String name, boolean val) throws FieldValidationException;
186
187
188 /***
189 * Set the value of a float field.
190 * @param name Field name.
191 * @param val Field value.
192 * @see RFldF32
193 */
194 void setFloat(String name, float val) throws FieldValidationException;
195
196
197 /***
198 * Set the value of a double field.
199 * @param name Field name.
200 * @param val Field value.
201 * @see RFldF64
202 */
203 void setDouble(String name, double val) throws FieldValidationException;
204
205
206 /***
207 * Set the value of a short field.
208 * @param name Field name.
209 * @param val Field value.
210 * @see RFldI16
211 */
212 void setShort(String name, short val) throws FieldValidationException;
213
214 /***
215 * Set the value of a integer field.
216 * @param name Field name.
217 * @param val Field value.
218 * @see RFldI32
219 */
220 void setInt(String name, int val) throws FieldValidationException;
221
222 /***
223 * Set the value of a long field.
224 * @param name Field name.
225 * @param val Field value.
226 * @see RFldI64
227 */
228 void setLong(String name, long val) throws FieldValidationException;
229
230 /***
231 * Set the value of a field from an object.
232 * @param name Field name.
233 * @param val Field value.
234 * @see RFld
235 */
236 void setFieldFromObject(String name, Object val) throws FieldValidationException;
237 //would like to change to setObject
238
239 /***
240 * Get the value of a string field.
241 * @param name Field name.
242 * @param val Field value.
243 * @see RFldString
244 */
245 void setString(String name, String val) throws FieldValidationException;
246
247 /***
248 * Get the value of a memo field.
249 * @param name Field name.
250 * @param val Field value.
251 * @see RFldString
252 */
253 void setMemo(String name, String val) throws FieldValidationException;
254
255 /***
256 * Get the value of a <tt>RFldTibrvMsg</tt> field.
257 * @param name Field name.
258 * @param val Field value.
259 * @see RFldOpaque
260 */
261 void setTibrvMsg(String name, Object val) throws FieldValidationException;
262
263 /***
264 * Get the value of a opaque field.
265 * @param name Field name.
266 * @param val Field value.
267 * @see RFldOpaque
268 */
269 void setOpaque(String name, byte[] val) throws FieldValidationException;
270
271 /***
272 * Get the value of a opaque field.
273 * @param name Field name.
274 * @param val Field value.
275 * @see RFldOpaque
276 */
277 void setBytes(String name, byte[] val) throws FieldValidationException;
278
279 //like to change to itemExists
280
281 /***
282 * Get all fields in the message.
283 * @return Iterator over all RFld fields in the message.
284 * @see #getFieldsAsArray()
285 */
286 java.util.Iterator getFields();
287
288 /***
289 * Get all fields in the message as an array.
290 * @return All fields in the message as an array.
291 * @see #getFields()
292 */
293 RFld[] getFieldsAsArray();
294
295 /***
296 * Get a named field from this message. Retuens <tt>null</tt> if the named
297 * field is not in the message.
298 * @param fldName Field name.
299 * @return Named field.
300 */
301 RFld getFieldIfExists(String fldName) throws FieldValidationException;
302
303 /***
304 * Get a named field from this message. Throws an exception if the named
305 * field is not in the message.
306 * @param fldName Field name.
307 * @return Named field.
308 */
309 RFld getField(String fldName) throws FieldValidationException;
310
311 /***
312 * Get a field to this message. Throws an exception if the named
313 * field is already in the message.
314 * @param fld Field.
315 */
316 void addField(RFld fld) throws FieldValidationException;
317
318 /***
319 * Get names of all fields in this message.
320 * @return Iterator over ames of all fields in this message.
321 */
322 java.util.Iterator getFieldNames();
323
324 /***
325 * Check if a named field exists in this message.
326 * @param name Field name.
327 * @return <tt>true</tt> if the named field exists. Otherwise
328 * returns </tt>false</tt>.
329 */
330 boolean fieldExists(String name);
331
332 /***
333 * Check if this is an empty message. An empty message is one that has not
334 * been defined externally via XML. These empty messages have their fields
335 * added dynamically by the application at run-time.
336 * @return <tt>true</tt> if this is an empty message. Otherwise returns
337 * <tt>false</tt>.
338 */
339 boolean isEmptyMsg();
340
341 /***
342 * Determine if the value of a named message field has been set.
343 * @param name Field name.
344 * @return <tt>true</tt> if the value of a named message field has been
345 * set. Otherwise, returns <tt>false</tt>.
346 */
347 boolean isValSet(String name) throws FieldValidationException;
348
349 /***
350 * Determine if a named message field is locked.
351 * @param name Field name.
352 * @return <tt>true</tt> if the named field is locked. Otherwise,
353 * returns <tt>false</tt>.
354 */
355 boolean isLocked(String name) throws FieldValidationException;
356
357
358 /***
359 * Determine if a named message field has constrains on it.
360 *
361 * @param name Field name.
362 * @return <tt>true</tt> if the named field is constrained. Otherwise,
363 * returns <tt>false</tt>.
364 */
365 boolean isConstrained(String name) throws FieldValidationException;
366 }
This page was automatically generated by Maven