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