1
2
3
4
5
6
7
8
9
10
11 package org.apache.maven.doxia.site.decoration;
12
13
14
15
16
17
18
19
20
21 @SuppressWarnings( "all" )
22 public class DecorationModel
23 implements java.io.Serializable, java.lang.Cloneable
24 {
25
26
27
28
29
30
31
32
33 private String name;
34
35
36
37
38
39
40
41
42 private String combineSelf = "merge";
43
44
45
46
47 private Banner bannerLeft;
48
49
50
51
52 private Banner bannerRight;
53
54
55
56
57 private PublishDate publishDate;
58
59
60
61
62 private Version version;
63
64
65
66
67
68
69
70
71 private String edit;
72
73
74
75
76 private java.util.List<Logo> poweredBy;
77
78
79
80
81 private Skin skin;
82
83
84
85
86 private Body body;
87
88
89
90
91
92
93
94
95
96
97
98 private Object custom;
99
100
101
102
103 private long lastModified = 0L;
104
105
106
107
108 private String modelEncoding = "UTF-8";
109
110
111
112
113
114
115
116
117
118
119
120 public void addPoweredBy( Logo logo )
121 {
122 getPoweredBy().add( logo );
123 }
124
125
126
127
128
129
130 public DecorationModel clone()
131 {
132 try
133 {
134 DecorationModel copy = (DecorationModel) super.clone();
135
136 if ( this.bannerLeft != null )
137 {
138 copy.bannerLeft = (Banner) this.bannerLeft.clone();
139 }
140
141 if ( this.bannerRight != null )
142 {
143 copy.bannerRight = (Banner) this.bannerRight.clone();
144 }
145
146 if ( this.publishDate != null )
147 {
148 copy.publishDate = (PublishDate) this.publishDate.clone();
149 }
150
151 if ( this.version != null )
152 {
153 copy.version = (Version) this.version.clone();
154 }
155
156 if ( this.poweredBy != null )
157 {
158 copy.poweredBy = new java.util.ArrayList<Logo>();
159 for ( Logo item : this.poweredBy )
160 {
161 copy.poweredBy.add( ( (Logo) item).clone() );
162 }
163 }
164
165 if ( this.skin != null )
166 {
167 copy.skin = (Skin) this.skin.clone();
168 }
169
170 if ( this.body != null )
171 {
172 copy.body = (Body) this.body.clone();
173 }
174
175 if ( this.custom != null )
176 {
177 copy.custom = new org.codehaus.plexus.util.xml.Xpp3Dom( (org.codehaus.plexus.util.xml.Xpp3Dom) this.custom );
178 }
179
180 return copy;
181 }
182 catch ( java.lang.Exception ex )
183 {
184 throw (java.lang.RuntimeException) new java.lang.UnsupportedOperationException( getClass().getName()
185 + " does not support clone()" ).initCause( ex );
186 }
187 }
188
189
190
191
192
193
194
195 public boolean equals( Object other )
196 {
197 if ( this == other )
198 {
199 return true;
200 }
201
202 if ( !( other instanceof DecorationModel ) )
203 {
204 return false;
205 }
206
207 DecorationModel that = (DecorationModel) other;
208 boolean result = true;
209
210 result = result && ( getName() == null ? that.getName() == null : getName().equals( that.getName() ) );
211 result = result && ( getBannerLeft() == null ? that.getBannerLeft() == null : getBannerLeft().equals( that.getBannerLeft() ) );
212 result = result && ( getBannerRight() == null ? that.getBannerRight() == null : getBannerRight().equals( that.getBannerRight() ) );
213 result = result && ( getPublishDate() == null ? that.getPublishDate() == null : getPublishDate().equals( that.getPublishDate() ) );
214 result = result && ( getVersion() == null ? that.getVersion() == null : getVersion().equals( that.getVersion() ) );
215 result = result && ( getEdit() == null ? that.getEdit() == null : getEdit().equals( that.getEdit() ) );
216 result = result && ( getPoweredBy() == null ? that.getPoweredBy() == null : getPoweredBy().equals( that.getPoweredBy() ) );
217 result = result && ( getSkin() == null ? that.getSkin() == null : getSkin().equals( that.getSkin() ) );
218 result = result && ( getBody() == null ? that.getBody() == null : getBody().equals( that.getBody() ) );
219 result = result && ( getCustom() == null ? that.getCustom() == null : getCustom().equals( that.getCustom() ) );
220
221 return result;
222 }
223
224
225
226
227
228
229 public Banner getBannerLeft()
230 {
231 return this.bannerLeft;
232 }
233
234
235
236
237
238
239 public Banner getBannerRight()
240 {
241 return this.bannerRight;
242 }
243
244
245
246
247
248
249 public Body getBody()
250 {
251 return this.body;
252 }
253
254
255
256
257
258
259
260
261 public String getCombineSelf()
262 {
263 return this.combineSelf;
264 }
265
266
267
268
269
270
271
272
273
274
275
276 public Object getCustom()
277 {
278 return this.custom;
279 }
280
281
282
283
284
285
286
287
288 public String getEdit()
289 {
290 return this.edit;
291 }
292
293
294
295
296
297
298
299 public long getLastModified()
300 {
301 return this.lastModified;
302 }
303
304
305
306
307
308
309 public String getModelEncoding()
310 {
311 return this.modelEncoding;
312 }
313
314
315
316
317
318
319 public String getName()
320 {
321 return this.name;
322 }
323
324
325
326
327
328
329 public java.util.List<Logo> getPoweredBy()
330 {
331 if ( this.poweredBy == null )
332 {
333 this.poweredBy = new java.util.ArrayList<Logo>();
334 }
335
336 return this.poweredBy;
337 }
338
339
340
341
342
343
344 public Skin getSkin()
345 {
346 return this.skin;
347 }
348
349
350
351
352
353
354 public int hashCode()
355 {
356 int result = 17;
357
358 result = 37 * result + ( name != null ? name.hashCode() : 0 );
359 result = 37 * result + ( bannerLeft != null ? bannerLeft.hashCode() : 0 );
360 result = 37 * result + ( bannerRight != null ? bannerRight.hashCode() : 0 );
361 result = 37 * result + ( publishDate != null ? publishDate.hashCode() : 0 );
362 result = 37 * result + ( version != null ? version.hashCode() : 0 );
363 result = 37 * result + ( edit != null ? edit.hashCode() : 0 );
364 result = 37 * result + ( poweredBy != null ? poweredBy.hashCode() : 0 );
365 result = 37 * result + ( skin != null ? skin.hashCode() : 0 );
366 result = 37 * result + ( body != null ? body.hashCode() : 0 );
367 result = 37 * result + ( custom != null ? custom.hashCode() : 0 );
368
369 return result;
370 }
371
372
373
374
375
376
377 public void removePoweredBy( Logo logo )
378 {
379 getPoweredBy().remove( logo );
380 }
381
382
383
384
385
386
387 public void setBannerLeft( Banner bannerLeft )
388 {
389 this.bannerLeft = bannerLeft;
390 }
391
392
393
394
395
396
397 public void setBannerRight( Banner bannerRight )
398 {
399 this.bannerRight = bannerRight;
400 }
401
402
403
404
405
406
407 public void setBody( Body body )
408 {
409 this.body = body;
410 }
411
412
413
414
415
416
417
418
419 public void setCombineSelf( String combineSelf )
420 {
421 this.combineSelf = combineSelf;
422 }
423
424
425
426
427
428
429
430
431
432
433
434 public void setCustom( Object custom )
435 {
436 this.custom = custom;
437 }
438
439
440
441
442
443
444
445
446 public void setEdit( String edit )
447 {
448 this.edit = edit;
449 }
450
451
452
453
454
455
456
457 public void setLastModified( long lastModified )
458 {
459 this.lastModified = lastModified;
460 }
461
462
463
464
465
466
467 public void setModelEncoding( String modelEncoding )
468 {
469 this.modelEncoding = modelEncoding;
470 }
471
472
473
474
475
476
477 public void setName( String name )
478 {
479 this.name = name;
480 }
481
482
483
484
485
486
487 public void setPoweredBy( java.util.List<Logo> poweredBy )
488 {
489 this.poweredBy = poweredBy;
490 }
491
492
493
494
495
496
497 public void setPublishDate( PublishDate publishDate )
498 {
499 this.publishDate = publishDate;
500 }
501
502
503
504
505
506
507 public void setSkin( Skin skin )
508 {
509 this.skin = skin;
510 }
511
512
513
514
515
516
517 public void setVersion( Version version )
518 {
519 this.version = version;
520 }
521
522
523
524
525
526
527 public java.lang.String toString()
528 {
529 StringBuilder buf = new StringBuilder( 128 );
530
531 buf.append( "name = '" );
532 buf.append( getName() );
533 buf.append( "'" );
534 buf.append( "\n" );
535 buf.append( "bannerLeft = '" );
536 buf.append( getBannerLeft() );
537 buf.append( "'" );
538 buf.append( "\n" );
539 buf.append( "bannerRight = '" );
540 buf.append( getBannerRight() );
541 buf.append( "'" );
542 buf.append( "\n" );
543 buf.append( "publishDate = '" );
544 buf.append( getPublishDate() );
545 buf.append( "'" );
546 buf.append( "\n" );
547 buf.append( "version = '" );
548 buf.append( getVersion() );
549 buf.append( "'" );
550 buf.append( "\n" );
551 buf.append( "edit = '" );
552 buf.append( getEdit() );
553 buf.append( "'" );
554 buf.append( "\n" );
555 buf.append( "poweredBy = '" );
556 buf.append( getPoweredBy() );
557 buf.append( "'" );
558 buf.append( "\n" );
559 buf.append( "skin = '" );
560 buf.append( getSkin() );
561 buf.append( "'" );
562 buf.append( "\n" );
563 buf.append( "body = '" );
564 buf.append( getBody() );
565 buf.append( "'" );
566 buf.append( "\n" );
567 buf.append( "custom = '" );
568 buf.append( getCustom() );
569 buf.append( "'" );
570
571 return buf.toString();
572 }
573
574
575
576 public static final String MERGE = "merge";
577
578 public static final String OVERRIDE = "override";
579
580 public boolean isMergeParent()
581 {
582 return !OVERRIDE.equals( combineSelf );
583 }
584
585 public PublishDate getPublishDate()
586 {
587 if ( publishDate == null )
588 return new PublishDate();
589 else
590 return publishDate;
591 }
592
593 public boolean isDefaultPublishDate()
594 {
595 return publishDate == null;
596 }
597
598 public Version getVersion()
599 {
600 if ( version == null )
601 return new Version();
602 else
603 return version;
604 }
605
606 public boolean isDefaultVersion()
607 {
608 return version == null;
609 }
610
611 private java.util.Map<String, Menu> menusByRef;
612
613
614
615
616
617 public Menu getMenuRef( String key )
618 {
619 if ( menusByRef == null )
620 {
621 menusByRef = new java.util.HashMap<String, Menu>();
622
623 if ( body != null )
624 {
625 for ( Menu menu : body.getMenus() )
626 {
627 if ( menu.getRef() != null )
628 {
629 menusByRef.put( menu.getRef(), menu );
630 }
631 }
632 }
633 }
634 return menusByRef.get( key );
635 }
636
637
638
639
640 public void removeMenuRef( String key )
641 {
642 if ( body != null )
643 {
644 for ( java.util.Iterator<Menu> i = body.getMenus().iterator(); i.hasNext(); )
645 {
646 Menu menu = i.next();
647 if ( key.equals( menu.getRef() ) )
648 {
649 i.remove();
650 }
651 }
652 }
653 }
654
655
656
657
658 public java.util.List<Menu> getMenus()
659 {
660 java.util.List menus;
661 if ( body != null && body.getMenus() != null )
662 {
663 menus = body.getMenus();
664 }
665 else
666 {
667 menus = java.util.Collections.emptyList();
668 }
669 return menus;
670 }
671
672
673 }