View Javadoc
1   /*
2    =================== DO NOT EDIT THIS FILE ====================
3    
4    Generated by Modello 2.4.0,
5    
6    any modifications will be overwritten.
7    
8    ==============================================================
9    */
10  
11  package org.apache.maven.doxia.site;
12  
13  /**
14   * 
15   *          The <code>&lt;site&gt;</code> element is the root of
16   * the site decoration descriptor.
17   *       
18   * 
19   * @version $Revision$ $Date$
20   */
21  @SuppressWarnings( "all" )
22  public class SiteModel
23      implements java.io.Serializable, java.lang.Cloneable
24  {
25  
26        //--------------------------/
27       //- Class/Member Variables -/
28      //--------------------------/
29  
30      /**
31       * The full name of the project site.
32       */
33      private String name;
34  
35      /**
36       * 
37       *              Whether to inherit configuration from a parent
38       * project site descriptor (<code>merge</code>)
39       *            or not (<code>override</code>).
40       *            
41       */
42      private String combineSelf = "merge";
43  
44      /**
45       * 
46       *              Whether this "site.xml" should inherit from a
47       * parent "site.xml". If set to "true" it fails the build in
48       * case a parent site descriptor cannot be retrieved.
49       *              It does not necessarily need to be the direct
50       * parent but just a site descriptor anywhere in the parent
51       * hierarchy.
52       *            
53       */
54      private boolean requireParent = false;
55  
56      /**
57       * Banner logo on the masthead of the site to the left.
58       */
59      private Banner bannerLeft;
60  
61      /**
62       * Banner logo on the masthead of the site to the right.
63       */
64      private Banner bannerRight;
65  
66      /**
67       * Modify the date published display properties.
68       */
69      private PublishDate publishDate;
70  
71      /**
72       * Modify the version published display properties.
73       */
74      private Version version;
75  
76      /**
77       * 
78       *             The base url to edit Doxia document sources.
79       *             In general, <code>${project.scm.url}</code>
80       * value should do the job.
81       *           
82       */
83      private String edit;
84  
85      /**
86       * Field poweredBy.
87       */
88      private java.util.List<Logo> poweredBy;
89  
90      /**
91       * The artifact containing the skin for the site.
92       */
93      private Skin skin;
94  
95      /**
96       * The main site content.
97       */
98      private Body body;
99  
100     /**
101      * 
102      *             Custom configuration for use with customized
103      * Velocity templates. Data from this field are
104      *             accessible in Velocity template from
105      * <code>$site.custom</code> variable as DOM content.
106      *             Example: <code>$site.custom.getChild(
107      * 'customElement' ).getValue()</code>
108      *           
109      */
110     private Object custom;
111 
112     /**
113      * Timestamp of the last modification of this site model.
114      */
115     private long lastModified = 0L;
116 
117     /**
118      * Field modelEncoding.
119      */
120     private String modelEncoding = "UTF-8";
121 
122 
123       //-----------/
124      //- Methods -/
125     //-----------/
126 
127     /**
128      * Method addPoweredBy.
129      * 
130      * @param logo a logo object.
131      */
132     public void addPoweredBy( Logo logo )
133     {
134         getPoweredBy().add( logo );
135     } //-- void addPoweredBy( Logo )
136 
137     /**
138      * Method clone.
139      * 
140      * @return SiteModel
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     } //-- SiteModel clone()
200 
201     /**
202      * Method equals.
203      * 
204      * @param other a other object.
205      * @return boolean
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     } //-- boolean equals( Object )
235 
236     /**
237      * Get banner logo on the masthead of the site to the left.
238      * 
239      * @return Banner
240      */
241     public Banner getBannerLeft()
242     {
243         return this.bannerLeft;
244     } //-- Banner getBannerLeft()
245 
246     /**
247      * Get banner logo on the masthead of the site to the right.
248      * 
249      * @return Banner
250      */
251     public Banner getBannerRight()
252     {
253         return this.bannerRight;
254     } //-- Banner getBannerRight()
255 
256     /**
257      * Get the main site content.
258      * 
259      * @return Body
260      */
261     public Body getBody()
262     {
263         return this.body;
264     } //-- Body getBody()
265 
266     /**
267      * Get whether to inherit configuration from a parent project
268      * site descriptor (<code>merge</code>)
269      *            or not (<code>override</code>).
270      * 
271      * @return String
272      */
273     public String getCombineSelf()
274     {
275         return this.combineSelf;
276     } //-- String getCombineSelf()
277 
278     /**
279      * Get custom configuration for use with customized Velocity
280      * templates. Data from this field are
281      *             accessible in Velocity template from
282      * <code>$site.custom</code> variable as DOM content.
283      *             Example: <code>$site.custom.getChild(
284      * 'customElement' ).getValue()</code>
285      * 
286      * @return Object
287      */
288     public Object getCustom()
289     {
290         return this.custom;
291     } //-- Object getCustom()
292 
293     /**
294      * Get the base url to edit Doxia document sources.
295      *             In general, <code>${project.scm.url}</code>
296      * value should do the job.
297      * 
298      * @return String
299      */
300     public String getEdit()
301     {
302         return this.edit;
303     } //-- String getEdit()
304 
305     /**
306      * Get timestamp of the last modification of this site model.
307      * 
308      * @return long
309      */
310     public long getLastModified()
311     {
312         return this.lastModified;
313     } //-- long getLastModified()
314 
315     /**
316      * Get the modelEncoding field.
317      * 
318      * @return String
319      */
320     public String getModelEncoding()
321     {
322         return this.modelEncoding;
323     } //-- String getModelEncoding()
324 
325     /**
326      * Get the full name of the project site.
327      * 
328      * @return String
329      */
330     public String getName()
331     {
332         return this.name;
333     } //-- String getName()
334 
335     /**
336      * Method getPoweredBy.
337      * 
338      * @return List
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     } //-- java.util.List<Logo> getPoweredBy()
349 
350     /**
351      * Get the artifact containing the skin for the site.
352      * 
353      * @return Skin
354      */
355     public Skin getSkin()
356     {
357         return this.skin;
358     } //-- Skin getSkin()
359 
360     /**
361      * Method hashCode.
362      * 
363      * @return int
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     } //-- int hashCode()
382 
383     /**
384      * Get whether this "site.xml" should inherit from a parent
385      * "site.xml". If set to "true" it fails the build in case a
386      * parent site descriptor cannot be retrieved.
387      *              It does not necessarily need to be the direct
388      * parent but just a site descriptor anywhere in the parent
389      * hierarchy.
390      * 
391      * @return boolean
392      */
393     public boolean isRequireParent()
394     {
395         return this.requireParent;
396     } //-- boolean isRequireParent()
397 
398     /**
399      * Method removePoweredBy.
400      * 
401      * @param logo a logo object.
402      */
403     public void removePoweredBy( Logo logo )
404     {
405         getPoweredBy().remove( logo );
406     } //-- void removePoweredBy( Logo )
407 
408     /**
409      * Set banner logo on the masthead of the site to the left.
410      * 
411      * @param bannerLeft a bannerLeft object.
412      */
413     public void setBannerLeft( Banner bannerLeft )
414     {
415         this.bannerLeft = bannerLeft;
416     } //-- void setBannerLeft( Banner )
417 
418     /**
419      * Set banner logo on the masthead of the site to the right.
420      * 
421      * @param bannerRight a bannerRight object.
422      */
423     public void setBannerRight( Banner bannerRight )
424     {
425         this.bannerRight = bannerRight;
426     } //-- void setBannerRight( Banner )
427 
428     /**
429      * Set the main site content.
430      * 
431      * @param body a body object.
432      */
433     public void setBody( Body body )
434     {
435         this.body = body;
436     } //-- void setBody( Body )
437 
438     /**
439      * Set whether to inherit configuration from a parent project
440      * site descriptor (<code>merge</code>)
441      *            or not (<code>override</code>).
442      * 
443      * @param combineSelf a combineSelf object.
444      */
445     public void setCombineSelf( String combineSelf )
446     {
447         this.combineSelf = combineSelf;
448     } //-- void setCombineSelf( String )
449 
450     /**
451      * Set custom configuration for use with customized Velocity
452      * templates. Data from this field are
453      *             accessible in Velocity template from
454      * <code>$site.custom</code> variable as DOM content.
455      *             Example: <code>$site.custom.getChild(
456      * 'customElement' ).getValue()</code>
457      * 
458      * @param custom a custom object.
459      */
460     public void setCustom( Object custom )
461     {
462         this.custom = custom;
463     } //-- void setCustom( Object )
464 
465     /**
466      * Set the base url to edit Doxia document sources.
467      *             In general, <code>${project.scm.url}</code>
468      * value should do the job.
469      * 
470      * @param edit a edit object.
471      */
472     public void setEdit( String edit )
473     {
474         this.edit = edit;
475     } //-- void setEdit( String )
476 
477     /**
478      * Set timestamp of the last modification of this site model.
479      * 
480      * @param lastModified a lastModified object.
481      */
482     public void setLastModified( long lastModified )
483     {
484         this.lastModified = lastModified;
485     } //-- void setLastModified( long )
486 
487     /**
488      * Set the modelEncoding field.
489      * 
490      * @param modelEncoding a modelEncoding object.
491      */
492     public void setModelEncoding( String modelEncoding )
493     {
494         this.modelEncoding = modelEncoding;
495     } //-- void setModelEncoding( String )
496 
497     /**
498      * Set the full name of the project site.
499      * 
500      * @param name a name object.
501      */
502     public void setName( String name )
503     {
504         this.name = name;
505     } //-- void setName( String )
506 
507     /**
508      * Set powered by logos list.
509      * 
510      * @param poweredBy a poweredBy object.
511      */
512     public void setPoweredBy( java.util.List<Logo> poweredBy )
513     {
514         this.poweredBy = poweredBy;
515     } //-- void setPoweredBy( java.util.List )
516 
517     /**
518      * Set modify the date published display properties.
519      * 
520      * @param publishDate a publishDate object.
521      */
522     public void setPublishDate( PublishDate publishDate )
523     {
524         this.publishDate = publishDate;
525     } //-- void setPublishDate( PublishDate )
526 
527     /**
528      * Set whether this "site.xml" should inherit from a parent
529      * "site.xml". If set to "true" it fails the build in case a
530      * parent site descriptor cannot be retrieved.
531      *              It does not necessarily need to be the direct
532      * parent but just a site descriptor anywhere in the parent
533      * hierarchy.
534      * 
535      * @param requireParent a requireParent object.
536      */
537     public void setRequireParent( boolean requireParent )
538     {
539         this.requireParent = requireParent;
540     } //-- void setRequireParent( boolean )
541 
542     /**
543      * Set the artifact containing the skin for the site.
544      * 
545      * @param skin a skin object.
546      */
547     public void setSkin( Skin skin )
548     {
549         this.skin = skin;
550     } //-- void setSkin( Skin )
551 
552     /**
553      * Set modify the version published display properties.
554      * 
555      * @param version a version object.
556      */
557     public void setVersion( Version version )
558     {
559         this.version = version;
560     } //-- void setVersion( Version )
561 
562     /**
563      * Method toString.
564      * 
565      * @return String
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     } //-- java.lang.String toString()
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      * @param key not null
655      * @return the menu ref defined by the given key.
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      * @param key not null
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      * @return the menus list or EMPTY_LIST.
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      * @since 1.7
716      * @see SiteUtils#isLink
717      */
718     public boolean isLink( String href )
719     {
720         return SiteUtils.isLink( href );
721     }
722           
723     
724     /**
725      * @since 1.8
726      * @see SiteUtils#getCustomChild
727      */
728     public Object getCustomChild( String path )
729     {
730         return SiteUtils.getCustomChild( (org.codehaus.plexus.util.xml.Xpp3Dom) custom, path );
731     }
732 
733     /**
734      * @since 1.8
735      * @see SiteUtils#getCustomValue
736      */
737     public String getCustomValue( String path )
738     {
739         return SiteUtils.getCustomValue( (org.codehaus.plexus.util.xml.Xpp3Dom) custom, path );
740     }
741 
742     /**
743      * @since 1.8
744      * @see SiteUtils#getCustomValue
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 }