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