View Javadoc
1   // =================== DO NOT EDIT THIS FILE ====================
2   // Generated by Modello 2.1.2,
3   // any modifications will be overwritten.
4   // ==============================================================
5   
6   package org.apache.maven.doxia.site;
7   
8   /**
9    * 
10   *          The <code>&lt;site&gt;</code> element is the root of
11   * the site decoration descriptor.
12   *       
13   * 
14   * @version $Revision$ $Date$
15   */
16  @SuppressWarnings( "all" )
17  public class SiteModel
18      implements java.io.Serializable, java.lang.Cloneable
19  {
20  
21        //--------------------------/
22       //- Class/Member Variables -/
23      //--------------------------/
24  
25      /**
26       * The full name of the project site.
27       */
28      private String name;
29  
30      /**
31       * 
32       *              Whether to inherit configuration from a parent
33       * project site descriptor (<code>merge</code>)
34       *            or not (<code>override</code>).
35       *            
36       */
37      private String combineSelf = "merge";
38  
39      /**
40       * Banner logo on the masthead of the site to the left.
41       */
42      private Banner bannerLeft;
43  
44      /**
45       * Banner logo on the masthead of the site to the right.
46       */
47      private Banner bannerRight;
48  
49      /**
50       * Modify the date published display properties.
51       */
52      private PublishDate publishDate;
53  
54      /**
55       * Modify the version published display properties.
56       */
57      private Version version;
58  
59      /**
60       * 
61       *             The base url to edit Doxia document sources.
62       *             In general, <code>${project.scm.url}</code>
63       * value should do the job.
64       *           
65       */
66      private String edit;
67  
68      /**
69       * Field poweredBy.
70       */
71      private java.util.List<Logo> poweredBy;
72  
73      /**
74       * The artifact containing the skin for the site.
75       */
76      private Skin skin;
77  
78      /**
79       * The main site content.
80       */
81      private Body body;
82  
83      /**
84       * 
85       *             Custom configuration for use with customized
86       * Velocity templates. Data from this field are
87       *             accessible in Velocity template from
88       * <code>$site.custom</code> variable as DOM content.
89       *             Example: <code>$site.custom.getChild(
90       * 'customElement' ).getValue()</code>
91       *           
92       */
93      private Object custom;
94  
95      /**
96       * Timestamp of the last modification of this site model.
97       */
98      private long lastModified = 0L;
99  
100     /**
101      * Field modelEncoding.
102      */
103     private String modelEncoding = "UTF-8";
104 
105 
106       //-----------/
107      //- Methods -/
108     //-----------/
109 
110     /**
111      * Method addPoweredBy.
112      * 
113      * @param logo a logo object.
114      */
115     public void addPoweredBy( Logo logo )
116     {
117         getPoweredBy().add( logo );
118     } //-- void addPoweredBy( Logo )
119 
120     /**
121      * Method clone.
122      * 
123      * @return SiteModel
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     } //-- SiteModel clone()
183 
184     /**
185      * Method equals.
186      * 
187      * @param other a other object.
188      * @return boolean
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     } //-- boolean equals( Object )
218 
219     /**
220      * Get banner logo on the masthead of the site to the left.
221      * 
222      * @return Banner
223      */
224     public Banner getBannerLeft()
225     {
226         return this.bannerLeft;
227     } //-- Banner getBannerLeft()
228 
229     /**
230      * Get banner logo on the masthead of the site to the right.
231      * 
232      * @return Banner
233      */
234     public Banner getBannerRight()
235     {
236         return this.bannerRight;
237     } //-- Banner getBannerRight()
238 
239     /**
240      * Get the main site content.
241      * 
242      * @return Body
243      */
244     public Body getBody()
245     {
246         return this.body;
247     } //-- Body getBody()
248 
249     /**
250      * Get whether to inherit configuration from a parent project
251      * site descriptor (<code>merge</code>)
252      *            or not (<code>override</code>).
253      * 
254      * @return String
255      */
256     public String getCombineSelf()
257     {
258         return this.combineSelf;
259     } //-- String getCombineSelf()
260 
261     /**
262      * Get custom configuration for use with customized Velocity
263      * templates. Data from this field are
264      *             accessible in Velocity template from
265      * <code>$site.custom</code> variable as DOM content.
266      *             Example: <code>$site.custom.getChild(
267      * 'customElement' ).getValue()</code>
268      * 
269      * @return Object
270      */
271     public Object getCustom()
272     {
273         return this.custom;
274     } //-- Object getCustom()
275 
276     /**
277      * Get the base url to edit Doxia document sources.
278      *             In general, <code>${project.scm.url}</code>
279      * value should do the job.
280      * 
281      * @return String
282      */
283     public String getEdit()
284     {
285         return this.edit;
286     } //-- String getEdit()
287 
288     /**
289      * Get timestamp of the last modification of this site model.
290      * 
291      * @return long
292      */
293     public long getLastModified()
294     {
295         return this.lastModified;
296     } //-- long getLastModified()
297 
298     /**
299      * Get the modelEncoding field.
300      * 
301      * @return String
302      */
303     public String getModelEncoding()
304     {
305         return this.modelEncoding;
306     } //-- String getModelEncoding()
307 
308     /**
309      * Get the full name of the project site.
310      * 
311      * @return String
312      */
313     public String getName()
314     {
315         return this.name;
316     } //-- String getName()
317 
318     /**
319      * Method getPoweredBy.
320      * 
321      * @return List
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     } //-- java.util.List<Logo> getPoweredBy()
332 
333     /**
334      * Get the artifact containing the skin for the site.
335      * 
336      * @return Skin
337      */
338     public Skin getSkin()
339     {
340         return this.skin;
341     } //-- Skin getSkin()
342 
343     /**
344      * Method hashCode.
345      * 
346      * @return int
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     } //-- int hashCode()
365 
366     /**
367      * Method removePoweredBy.
368      * 
369      * @param logo a logo object.
370      */
371     public void removePoweredBy( Logo logo )
372     {
373         getPoweredBy().remove( logo );
374     } //-- void removePoweredBy( Logo )
375 
376     /**
377      * Set banner logo on the masthead of the site to the left.
378      * 
379      * @param bannerLeft a bannerLeft object.
380      */
381     public void setBannerLeft( Banner bannerLeft )
382     {
383         this.bannerLeft = bannerLeft;
384     } //-- void setBannerLeft( Banner )
385 
386     /**
387      * Set banner logo on the masthead of the site to the right.
388      * 
389      * @param bannerRight a bannerRight object.
390      */
391     public void setBannerRight( Banner bannerRight )
392     {
393         this.bannerRight = bannerRight;
394     } //-- void setBannerRight( Banner )
395 
396     /**
397      * Set the main site content.
398      * 
399      * @param body a body object.
400      */
401     public void setBody( Body body )
402     {
403         this.body = body;
404     } //-- void setBody( Body )
405 
406     /**
407      * Set whether to inherit configuration from a parent project
408      * site descriptor (<code>merge</code>)
409      *            or not (<code>override</code>).
410      * 
411      * @param combineSelf a combineSelf object.
412      */
413     public void setCombineSelf( String combineSelf )
414     {
415         this.combineSelf = combineSelf;
416     } //-- void setCombineSelf( String )
417 
418     /**
419      * Set custom configuration for use with customized Velocity
420      * templates. Data from this field are
421      *             accessible in Velocity template from
422      * <code>$site.custom</code> variable as DOM content.
423      *             Example: <code>$site.custom.getChild(
424      * 'customElement' ).getValue()</code>
425      * 
426      * @param custom a custom object.
427      */
428     public void setCustom( Object custom )
429     {
430         this.custom = custom;
431     } //-- void setCustom( Object )
432 
433     /**
434      * Set the base url to edit Doxia document sources.
435      *             In general, <code>${project.scm.url}</code>
436      * value should do the job.
437      * 
438      * @param edit a edit object.
439      */
440     public void setEdit( String edit )
441     {
442         this.edit = edit;
443     } //-- void setEdit( String )
444 
445     /**
446      * Set timestamp of the last modification of this site model.
447      * 
448      * @param lastModified a lastModified object.
449      */
450     public void setLastModified( long lastModified )
451     {
452         this.lastModified = lastModified;
453     } //-- void setLastModified( long )
454 
455     /**
456      * Set the modelEncoding field.
457      * 
458      * @param modelEncoding a modelEncoding object.
459      */
460     public void setModelEncoding( String modelEncoding )
461     {
462         this.modelEncoding = modelEncoding;
463     } //-- void setModelEncoding( String )
464 
465     /**
466      * Set the full name of the project site.
467      * 
468      * @param name a name object.
469      */
470     public void setName( String name )
471     {
472         this.name = name;
473     } //-- void setName( String )
474 
475     /**
476      * Set powered by logos list.
477      * 
478      * @param poweredBy a poweredBy object.
479      */
480     public void setPoweredBy( java.util.List<Logo> poweredBy )
481     {
482         this.poweredBy = poweredBy;
483     } //-- void setPoweredBy( java.util.List )
484 
485     /**
486      * Set modify the date published display properties.
487      * 
488      * @param publishDate a publishDate object.
489      */
490     public void setPublishDate( PublishDate publishDate )
491     {
492         this.publishDate = publishDate;
493     } //-- void setPublishDate( PublishDate )
494 
495     /**
496      * Set the artifact containing the skin for the site.
497      * 
498      * @param skin a skin object.
499      */
500     public void setSkin( Skin skin )
501     {
502         this.skin = skin;
503     } //-- void setSkin( Skin )
504 
505     /**
506      * Set modify the version published display properties.
507      * 
508      * @param version a version object.
509      */
510     public void setVersion( Version version )
511     {
512         this.version = version;
513     } //-- void setVersion( Version )
514 
515     /**
516      * Method toString.
517      * 
518      * @return String
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     } //-- java.lang.String toString()
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      * @param key not null
608      * @return the menu ref defined by the given key.
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      * @param key not null
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      * @return the menus list or EMPTY_LIST.
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      * @since 1.7
669      * @see SiteUtils#isLink
670      */
671     public boolean isLink( String href )
672     {
673         return SiteUtils.isLink( href );
674     }
675           
676     
677     /**
678      * @since 1.8
679      * @see SiteUtils#getCustomChild
680      */
681     public Object getCustomChild( String path )
682     {
683         return SiteUtils.getCustomChild( (org.codehaus.plexus.util.xml.Xpp3Dom) custom, path );
684     }
685 
686     /**
687      * @since 1.8
688      * @see SiteUtils#getCustomValue
689      */
690     public String getCustomValue( String path )
691     {
692         return SiteUtils.getCustomValue( (org.codehaus.plexus.util.xml.Xpp3Dom) custom, path );
693     }
694 
695     /**
696      * @since 1.8
697      * @see SiteUtils#getCustomValue
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 }