1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416
| 1. /**
2. * This file is generated by BorlandXML.
3. */
4.
5. package xml;
6.
7. import java.util.*;
8.
9. /**
10. * The Book class represents the element "book" with the content
11. * model defined as follows:
12. * <p>
13. * <!ELEMENT book (author,title,publisher,price)><br>
14. */
15. public class Book extends com.borland.xml.toolkit.XmlObject
16. {
17. /** element-type name of this element. */
18. public static String _tagName = "book";
19. /** Defines a Author object */
20. protected Author _objAuthor;
21. /** Defines a Title object */
22. protected Title _objTitle;
23. /** Defines a Publisher object */
24. protected Publisher _objPublisher;
25. /** Defines a Price object */
26. protected Price _objPrice;
27.
28. /**
29. * Creates an empty Book object
30. */
31. public Book()
32. {
33. super();
34. }
35.
36. /**
37. * Gets the text content of Author object.
38. */
39. public String getAuthorText()
40. {
41. return _objAuthor==null ? null : _objAuthor.getText();
42. }
43.
44. /**
45. * Replaces the existing text of Author object with a new text.
46. * If you pass a <code>null</code> to this method, the Author object is
47. * cleared and will not be marshaled.
48. * @param text New text.
49. */
50. public void setAuthorText(String text)
51. {
52. if( text == null )
53. {
54. this._objAuthor = null;
55. return;
56. }
57.
58. if( this._objAuthor == null )
59. this._objAuthor = new Author();
60.
61. this._objAuthor.setText(text);
62. this._objAuthor._setParent(this);
63. }
64.
65. /**
66. * Gets the Author object.
67. */
68. public Author getAuthor()
69. {
70. return _objAuthor;
71. }
72.
73. /**
74. * Replaces the existing Author object with a new object.
75. * If you pass a <code>null</code> to this method, the Author object is
76. * cleared and will not be marshaled.
77. * @param obj New Author object.
78. */
79. public void setAuthor(Author obj)
80. {
81. this._objAuthor = obj;
82. if( obj == null )
83. return;
84.
85. obj._setParent(this);
86. }
87. /**
88. * Gets the text content of Title object.
89. */
90. public String getTitleText()
91. {
92. return _objTitle==null ? null : _objTitle.getText();
93. }
94.
95. /**
96. * Replaces the existing text of Title object with a new text.
97. * If you pass a <code>null</code> to this method, the Title object is
98. * cleared and will not be marshaled.
99. * @param text New text.
100. */
101. public void setTitleText(String text)
102. {
103. if( text == null )
104. {
105. this._objTitle = null;
106. return;
107. }
108.
109. if( this._objTitle == null )
110. this._objTitle = new Title();
111.
112. this._objTitle.setText(text);
113. this._objTitle._setParent(this);
114. }
115.
116. /**
117. * Gets the Title object.
118. */
119. public Title getTitle()
120. {
121. return _objTitle;
122. }
123.
124. /**
125. * Replaces the existing Title object with a new object.
126. * If you pass a <code>null</code> to this method, the Title object is
127. * cleared and will not be marshaled.
128. * @param obj New Title object.
129. */
130. public void setTitle(Title obj)
131. {
132. this._objTitle = obj;
133. if( obj == null )
134. return;
135.
136. obj._setParent(this);
137. }
138. /**
139. * Gets the text content of Publisher object.
140. */
141. public String getPublisherText()
142. {
143. return _objPublisher==null ? null : _objPublisher.getText();
144. }
145.
146. /**
147. * Replaces the existing text of Publisher object with a new text.
148. * If you pass a <code>null</code> to this method, the Publisher object is
149. * cleared and will not be marshaled.
150. * @param text New text.
151. */
152. public void setPublisherText(String text)
153. {
154. if( text == null )
155. {
156. this._objPublisher = null;
157. return;
158. }
159.
160. if( this._objPublisher == null )
161. this._objPublisher = new Publisher();
162.
163. this._objPublisher.setText(text);
164. this._objPublisher._setParent(this);
165. }
166.
167. /**
168. * Gets the Publisher object.
169. */
170. public Publisher getPublisher()
171. {
172. return _objPublisher;
173. }
174.
175. /**
176. * Replaces the existing Publisher object with a new object.
177. * If you pass a <code>null</code> to this method, the Publisher object is
178. * cleared and will not be marshaled.
179. * @param obj New Publisher object.
180. */
181. public void setPublisher(Publisher obj)
182. {
183. this._objPublisher = obj;
184. if( obj == null )
185. return;
186.
187. obj._setParent(this);
188. }
189. /**
190. * Gets the text content of Price object.
191. */
192. public String getPriceText()
193. {
194. return _objPrice==null ? null : _objPrice.getText();
195. }
196.
197. /**
198. * Replaces the existing text of Price object with a new text.
199. * If you pass a <code>null</code> to this method, the Price object is
200. * cleared and will not be marshaled.
201. * @param text New text.
202. */
203. public void setPriceText(String text)
204. {
205. if( text == null )
206. {
207. this._objPrice = null;
208. return;
209. }
210.
211. if( this._objPrice == null )
212. this._objPrice = new Price();
213.
214. this._objPrice.setText(text);
215. this._objPrice._setParent(this);
216. }
217.
218. /**
219. * Gets the Price object.
220. */
221. public Price getPrice()
222. {
223. return _objPrice;
224. }
225.
226. /**
227. * Replaces the existing Price object with a new object.
228. * If you pass a <code>null</code> to this method, the Price object is
229. * cleared and will not be marshaled.
230. * @param obj New Price object.
231. */
232. public void setPrice(Price obj)
233. {
234. this._objPrice = obj;
235. if( obj == null )
236. return;
237.
238. obj._setParent(this);
239. }
240.
241. /**
242. * Marshals this object to an element.
243. */
244. public com.borland.xml.toolkit.Element marshal()
245. {
246. com.borland.xml.toolkit.Element elem = new com.borland.xml.toolkit.Element(get_TagName());
247. /** Marshals a Author object to an element */
248. if( _objAuthor != null )
249. {
250. elem.addComment(_objAuthor._marshalCommentList());
251. elem.addContent(_objAuthor.marshal());
252. }
253. /** Marshals a Title object to an element */
254. if( _objTitle != null )
255. {
256. elem.addComment(_objTitle._marshalCommentList());
257. elem.addContent(_objTitle.marshal());
258. }
259. /** Marshals a Publisher object to an element */
260. if( _objPublisher != null )
261. {
262. elem.addComment(_objPublisher._marshalCommentList());
263. elem.addContent(_objPublisher.marshal());
264. }
265. /** Marshals a Price object to an element */
266. if( _objPrice != null )
267. {
268. elem.addComment(_objPrice._marshalCommentList());
269. elem.addContent(_objPrice.marshal());
270. }
271.
272. elem.addComment(this._marshalBottomCommentList());
273. return elem;
274. }
275.
276. /**
277. * Unmarshals the specified "book" element back to a Book object.
278. */
279. public static Book unmarshal(com.borland.xml.toolkit.Element elem)
280. {
281. if( elem == null )
282. return null;
283.
284. Book __objBook = new Book();
285.
286. ArrayList __comments = null;
287. Iterator it = elem.getChildObjects().iterator();
288. while( it.hasNext() )
289. {
290. Object __obj = it.next();
291. if( __obj instanceof com.borland.xml.toolkit.Comment )
292. {
293. if( __comments == null )
294. __comments = new ArrayList(2);
295.
296. __comments.add(__obj);
297. }
298. else if( __obj instanceof com.borland.xml.toolkit.Element )
299. {
300. com.borland.xml.toolkit.Element __e = (com.borland.xml.toolkit.Element)__obj;
301. String __name = __e.getName();
302. if( __name.equals(Author._tagName) )
303. {
304. /** Unmarshals the child element back to a Author object */
305. Author __objAuthor = Author.unmarshal(__e);
306. __objBook.setAuthor(__objAuthor);
307. __objAuthor._unmarshalCommentList(__comments);
308. }
309. if( __name.equals(Title._tagName) )
310. {
311. /** Unmarshals the child element back to a Title object */
312. Title __objTitle = Title.unmarshal(__e);
313. __objBook.setTitle(__objTitle);
314. __objTitle._unmarshalCommentList(__comments);
315. }
316. if( __name.equals(Publisher._tagName) )
317. {
318. /** Unmarshals the child element back to a Publisher object */
319. Publisher __objPublisher = Publisher.unmarshal(__e);
320. __objBook.setPublisher(__objPublisher);
321. __objPublisher._unmarshalCommentList(__comments);
322. }
323. if( __name.equals(Price._tagName) )
324. {
325. /** Unmarshals the child element back to a Price object */
326. Price __objPrice = Price.unmarshal(__e);
327. __objBook.setPrice(__objPrice);
328. __objPrice._unmarshalCommentList(__comments);
329. }
330.
331. __comments = null;
332. }
333. }
334. __objBook._unmarshalBottomCommentList(__comments);
335. return __objBook;
336. }
337.
338. /**
339. * Validates this object. If you pass <code>true</code> to this method, it
340. * checks for the first error and stops. On the other hand, if you pass
341. * <code>false</code> to this method, it collects all the errors by
342. * visiting every available elements.
343. * @param firstError <code>true</code> to exit this method when the first error
344. * is found; <code>false</code> to collect all errors.
345. * @return com.borland.xml.toolkit.ErrorList A list that contains one or more errors.
346. * @see com.borland.xml.toolkit.XmlObject#validate()
347. * @see com.borland.xml.toolkit.XmlObject#isValid()
348. * @see com.borland.xml.toolkit.ErrorList
349. */
350. public com.borland.xml.toolkit.ErrorList validate(boolean firstError)
351. {
352. com.borland.xml.toolkit.ErrorList errors = new com.borland.xml.toolkit.ErrorList();
353.
354. /** Author is mandatory */
355. if( _objAuthor != null )
356. errors.add(_objAuthor.validate(firstError));
357. else
358. errors.add(new com.borland.xml.toolkit.ElementError(this, Author.class));
359. if( firstError && errors.size() > 0 )
360. return errors;
361. /** Title is mandatory */
362. if( _objTitle != null )
363. errors.add(_objTitle.validate(firstError));
364. else
365. errors.add(new com.borland.xml.toolkit.ElementError(this, Title.class));
366. if( firstError && errors.size() > 0 )
367. return errors;
368. /** Publisher is mandatory */
369. if( _objPublisher != null )
370. errors.add(_objPublisher.validate(firstError));
371. else
372. errors.add(new com.borland.xml.toolkit.ElementError(this, Publisher.class));
373. if( firstError && errors.size() > 0 )
374. return errors;
375. /** Price is mandatory */
376. if( _objPrice != null )
377. errors.add(_objPrice.validate(firstError));
378. else
379. errors.add(new com.borland.xml.toolkit.ElementError(this, Price.class));
380. if( firstError && errors.size() > 0 )
381. return errors;
382.
383. return errors.size()==0 ? null : errors;
384. }
385.
386. /**
387. * Returns a list containing all child elements. Each element in the list is a subclass
388. * of XmlObject.
389. */
390. public java.util.List _getChildren()
391. {
392. java.util.List children = new java.util.ArrayList();
393. /** adds _objAuthor */
394. if( _objAuthor != null )
395. children.add(_objAuthor);
396. /** adds _objTitle */
397. if( _objTitle != null )
398. children.add(_objTitle);
399. /** adds _objPublisher */
400. if( _objPublisher != null )
401. children.add(_objPublisher);
402. /** adds _objPrice */
403. if( _objPrice != null )
404. children.add(_objPrice);
405. return children;
406. }
407.
408.
409. /**
410. * Gets the element-type name.
411. */
412. public String get_TagName()
413. {
414. return _tagName;
415. }
416. } |
Partager