View Javadoc

1   /*
2    =================== DO NOT EDIT THIS FILE ====================
3    Generated by Modello 1.0.1 on 2009-09-09 03:30:24,
4    any modifications will be overwritten.
5    ==============================================================
6    */
7   
8   package org.apache.maven.settings;
9   
10  /**
11   * 
12   *         Root element of the user configuration file.
13   *       
14   * 
15   * @version $Revision$ $Date$
16   */
17  public class Settings
18      extends TrackableBase
19      implements java.io.Serializable
20  {
21  
22        //--------------------------/
23       //- Class/Member Variables -/
24      //--------------------------/
25  
26      /**
27       * 
28       *             
29       *             The local repository.
30       *             
31       *           
32       */
33      private String localRepository;
34  
35      /**
36       * 
37       *             
38       *             Whether Maven should attempt to interact with
39       * the user for input.
40       *             
41       *           
42       */
43      private boolean interactiveMode = true;
44  
45      /**
46       * 
47       *             
48       *             Whether Maven should use the plugin-registry.xml
49       * file to manage plugin versions.
50       *             
51       *           
52       */
53      private boolean usePluginRegistry = false;
54  
55      /**
56       * 
57       *             
58       *             Indicate whether maven should operate in offline
59       * mode full-time.
60       *             
61       *           
62       */
63      private boolean offline = false;
64  
65      /**
66       * Field proxies.
67       */
68      private java.util.List<Proxy> proxies;
69  
70      /**
71       * Field servers.
72       */
73      private java.util.List<Server> servers;
74  
75      /**
76       * Field mirrors.
77       */
78      private java.util.List<Mirror> mirrors;
79  
80      /**
81       * Field profiles.
82       */
83      private java.util.List<Profile> profiles;
84  
85      /**
86       * Field activeProfiles.
87       */
88      private java.util.List<String> activeProfiles;
89  
90      /**
91       * Field pluginGroups.
92       */
93      private java.util.List<String> pluginGroups;
94  
95      /**
96       * Field modelEncoding.
97       */
98      private String modelEncoding = "UTF-8";
99  
100 
101       //-----------/
102      //- Methods -/
103     //-----------/
104 
105     /**
106      * Method addActiveProfile.
107      * 
108      * @param string
109      */
110     public void addActiveProfile( String string )
111     {
112         if ( !(string instanceof String) )
113         {
114             throw new ClassCastException( "Settings.addActiveProfiles(string) parameter must be instanceof " + String.class.getName() );
115         }
116         getActiveProfiles().add( string );
117     } //-- void addActiveProfile( String )
118 
119     /**
120      * Method addMirror.
121      * 
122      * @param mirror
123      */
124     public void addMirror( Mirror mirror )
125     {
126         if ( !(mirror instanceof Mirror) )
127         {
128             throw new ClassCastException( "Settings.addMirrors(mirror) parameter must be instanceof " + Mirror.class.getName() );
129         }
130         getMirrors().add( mirror );
131     } //-- void addMirror( Mirror )
132 
133     /**
134      * Method addPluginGroup.
135      * 
136      * @param string
137      */
138     public void addPluginGroup( String string )
139     {
140         if ( !(string instanceof String) )
141         {
142             throw new ClassCastException( "Settings.addPluginGroups(string) parameter must be instanceof " + String.class.getName() );
143         }
144         getPluginGroups().add( string );
145     } //-- void addPluginGroup( String )
146 
147     /**
148      * Method addProfile.
149      * 
150      * @param profile
151      */
152     public void addProfile( Profile profile )
153     {
154         if ( !(profile instanceof Profile) )
155         {
156             throw new ClassCastException( "Settings.addProfiles(profile) parameter must be instanceof " + Profile.class.getName() );
157         }
158         getProfiles().add( profile );
159     } //-- void addProfile( Profile )
160 
161     /**
162      * Method addProxy.
163      * 
164      * @param proxy
165      */
166     public void addProxy( Proxy proxy )
167     {
168         if ( !(proxy instanceof Proxy) )
169         {
170             throw new ClassCastException( "Settings.addProxies(proxy) parameter must be instanceof " + Proxy.class.getName() );
171         }
172         getProxies().add( proxy );
173     } //-- void addProxy( Proxy )
174 
175     /**
176      * Method addServer.
177      * 
178      * @param server
179      */
180     public void addServer( Server server )
181     {
182         if ( !(server instanceof Server) )
183         {
184             throw new ClassCastException( "Settings.addServers(server) parameter must be instanceof " + Server.class.getName() );
185         }
186         getServers().add( server );
187     } //-- void addServer( Server )
188 
189     /**
190      * Method getActiveProfiles.
191      * 
192      * @return List
193      */
194     public java.util.List<String> getActiveProfiles()
195     {
196         if ( this.activeProfiles == null )
197         {
198             this.activeProfiles = new java.util.ArrayList<String>();
199         }
200 
201         return this.activeProfiles;
202     } //-- java.util.List<String> getActiveProfiles()
203 
204     /**
205      * Get the local repository.
206      * 
207      * @return String
208      */
209     public String getLocalRepository()
210     {
211         return this.localRepository;
212     } //-- String getLocalRepository()
213 
214     /**
215      * Method getMirrors.
216      * 
217      * @return List
218      */
219     public java.util.List<Mirror> getMirrors()
220     {
221         if ( this.mirrors == null )
222         {
223             this.mirrors = new java.util.ArrayList<Mirror>();
224         }
225 
226         return this.mirrors;
227     } //-- java.util.List<Mirror> getMirrors()
228 
229     /**
230      * Method getModelEncoding.
231      * 
232      * @return the current encoding used when reading/writing this
233      * model
234      */
235     public String getModelEncoding()
236     {
237         return modelEncoding;
238     } //-- String getModelEncoding()
239 
240     /**
241      * Method getPluginGroups.
242      * 
243      * @return List
244      */
245     public java.util.List<String> getPluginGroups()
246     {
247         if ( this.pluginGroups == null )
248         {
249             this.pluginGroups = new java.util.ArrayList<String>();
250         }
251 
252         return this.pluginGroups;
253     } //-- java.util.List<String> getPluginGroups()
254 
255     /**
256      * Method getProfiles.
257      * 
258      * @return List
259      */
260     public java.util.List<Profile> getProfiles()
261     {
262         if ( this.profiles == null )
263         {
264             this.profiles = new java.util.ArrayList<Profile>();
265         }
266 
267         return this.profiles;
268     } //-- java.util.List<Profile> getProfiles()
269 
270     /**
271      * Method getProxies.
272      * 
273      * @return List
274      */
275     public java.util.List<Proxy> getProxies()
276     {
277         if ( this.proxies == null )
278         {
279             this.proxies = new java.util.ArrayList<Proxy>();
280         }
281 
282         return this.proxies;
283     } //-- java.util.List<Proxy> getProxies()
284 
285     /**
286      * Method getServers.
287      * 
288      * @return List
289      */
290     public java.util.List<Server> getServers()
291     {
292         if ( this.servers == null )
293         {
294             this.servers = new java.util.ArrayList<Server>();
295         }
296 
297         return this.servers;
298     } //-- java.util.List<Server> getServers()
299 
300     /**
301      * Get whether Maven should attempt to interact with the user
302      * for input.
303      * 
304      * @return boolean
305      */
306     public boolean isInteractiveMode()
307     {
308         return this.interactiveMode;
309     } //-- boolean isInteractiveMode()
310 
311     /**
312      * Get indicate whether maven should operate in offline mode
313      * full-time.
314      * 
315      * @return boolean
316      */
317     public boolean isOffline()
318     {
319         return this.offline;
320     } //-- boolean isOffline()
321 
322     /**
323      * Get whether Maven should use the plugin-registry.xml file to
324      * manage plugin versions.
325      * 
326      * @return boolean
327      */
328     public boolean isUsePluginRegistry()
329     {
330         return this.usePluginRegistry;
331     } //-- boolean isUsePluginRegistry()
332 
333     /**
334      * Method removeActiveProfile.
335      * 
336      * @param string
337      */
338     public void removeActiveProfile( String string )
339     {
340         if ( !(string instanceof String) )
341         {
342             throw new ClassCastException( "Settings.removeActiveProfiles(string) parameter must be instanceof " + String.class.getName() );
343         }
344         getActiveProfiles().remove( string );
345     } //-- void removeActiveProfile( String )
346 
347     /**
348      * Method removeMirror.
349      * 
350      * @param mirror
351      */
352     public void removeMirror( Mirror mirror )
353     {
354         if ( !(mirror instanceof Mirror) )
355         {
356             throw new ClassCastException( "Settings.removeMirrors(mirror) parameter must be instanceof " + Mirror.class.getName() );
357         }
358         getMirrors().remove( mirror );
359     } //-- void removeMirror( Mirror )
360 
361     /**
362      * Method removePluginGroup.
363      * 
364      * @param string
365      */
366     public void removePluginGroup( String string )
367     {
368         if ( !(string instanceof String) )
369         {
370             throw new ClassCastException( "Settings.removePluginGroups(string) parameter must be instanceof " + String.class.getName() );
371         }
372         getPluginGroups().remove( string );
373     } //-- void removePluginGroup( String )
374 
375     /**
376      * Method removeProfile.
377      * 
378      * @param profile
379      */
380     public void removeProfile( Profile profile )
381     {
382         if ( !(profile instanceof Profile) )
383         {
384             throw new ClassCastException( "Settings.removeProfiles(profile) parameter must be instanceof " + Profile.class.getName() );
385         }
386         getProfiles().remove( profile );
387     } //-- void removeProfile( Profile )
388 
389     /**
390      * Method removeProxy.
391      * 
392      * @param proxy
393      */
394     public void removeProxy( Proxy proxy )
395     {
396         if ( !(proxy instanceof Proxy) )
397         {
398             throw new ClassCastException( "Settings.removeProxies(proxy) parameter must be instanceof " + Proxy.class.getName() );
399         }
400         getProxies().remove( proxy );
401     } //-- void removeProxy( Proxy )
402 
403     /**
404      * Method removeServer.
405      * 
406      * @param server
407      */
408     public void removeServer( Server server )
409     {
410         if ( !(server instanceof Server) )
411         {
412             throw new ClassCastException( "Settings.removeServers(server) parameter must be instanceof " + Server.class.getName() );
413         }
414         getServers().remove( server );
415     } //-- void removeServer( Server )
416 
417     /**
418      * Set list of manually-activated build profiles, specified in
419      * the order in which
420      *             they should be applied.
421      * 
422      * @param activeProfiles
423      */
424     public void setActiveProfiles( java.util.List<String> activeProfiles )
425     {
426         this.activeProfiles = activeProfiles;
427     } //-- void setActiveProfiles( java.util.List )
428 
429     /**
430      * Set whether Maven should attempt to interact with the user
431      * for input.
432      * 
433      * @param interactiveMode
434      */
435     public void setInteractiveMode( boolean interactiveMode )
436     {
437         this.interactiveMode = interactiveMode;
438     } //-- void setInteractiveMode( boolean )
439 
440     /**
441      * Set the local repository.
442      * 
443      * @param localRepository
444      */
445     public void setLocalRepository( String localRepository )
446     {
447         this.localRepository = localRepository;
448     } //-- void setLocalRepository( String )
449 
450     /**
451      * Set configuration of download mirrors for repositories.
452      * 
453      * @param mirrors
454      */
455     public void setMirrors( java.util.List<Mirror> mirrors )
456     {
457         this.mirrors = mirrors;
458     } //-- void setMirrors( java.util.List )
459 
460     /**
461      * Set an encoding used for reading/writing the model.
462      * 
463      * @param modelEncoding
464      */
465     public void setModelEncoding( String modelEncoding )
466     {
467         this.modelEncoding = modelEncoding;
468     } //-- void setModelEncoding( String )
469 
470     /**
471      * Set indicate whether maven should operate in offline mode
472      * full-time.
473      * 
474      * @param offline
475      */
476     public void setOffline( boolean offline )
477     {
478         this.offline = offline;
479     } //-- void setOffline( boolean )
480 
481     /**
482      * Set list of groupIds to search for a plugin when that plugin
483      *             groupId is not explicitly provided.
484      * 
485      * @param pluginGroups
486      */
487     public void setPluginGroups( java.util.List<String> pluginGroups )
488     {
489         this.pluginGroups = pluginGroups;
490     } //-- void setPluginGroups( java.util.List )
491 
492     /**
493      * Set configuration of build profiles for adjusting the build
494      *             according to environmental parameters.
495      * 
496      * @param profiles
497      */
498     public void setProfiles( java.util.List<Profile> profiles )
499     {
500         this.profiles = profiles;
501     } //-- void setProfiles( java.util.List )
502 
503     /**
504      * Set configuration for different proxy profiles. Multiple
505      * proxy profiles
506      *             might come in handy for anyone working from a
507      * notebook or other
508      *             mobile platform, to enable easy switching of
509      * entire proxy
510      *             configurations by simply specifying the profile
511      * id, again either from
512      *             the command line or from the defaults section
513      * below.
514      * 
515      * @param proxies
516      */
517     public void setProxies( java.util.List<Proxy> proxies )
518     {
519         this.proxies = proxies;
520     } //-- void setProxies( java.util.List )
521 
522     /**
523      * Set configuration of server-specific settings, mainly
524      * authentication
525      *             method. This allows configuration of
526      * authentication on a per-server
527      *             basis.
528      * 
529      * @param servers
530      */
531     public void setServers( java.util.List<Server> servers )
532     {
533         this.servers = servers;
534     } //-- void setServers( java.util.List )
535 
536     /**
537      * Set whether Maven should use the plugin-registry.xml file to
538      * manage plugin versions.
539      * 
540      * @param usePluginRegistry
541      */
542     public void setUsePluginRegistry( boolean usePluginRegistry )
543     {
544         this.usePluginRegistry = usePluginRegistry;
545     } //-- void setUsePluginRegistry( boolean )
546 
547 
548             
549     public Boolean getInteractiveMode()
550     {
551         return Boolean.valueOf( isInteractiveMode() );
552     }
553 
554     private Proxy activeProxy;
555 
556     /**
557      * Reset the <code>activeProxy</code> field to <code>null</code>
558      */
559     public void flushActiveProxy()
560     {
561         this.activeProxy = null;
562     }
563 
564     /**
565      * @return the first active proxy
566      */
567     public synchronized Proxy getActiveProxy()
568     {
569         if(activeProxy == null)
570         {
571             java.util.List proxies = getProxies();
572             if ( proxies != null && !proxies.isEmpty() )
573             {
574                 for ( java.util.Iterator it = proxies.iterator(); it.hasNext(); )
575                 {
576                     Proxy proxy = (Proxy) it.next();
577                     if ( proxy.isActive() )
578                     {
579                         activeProxy = proxy;
580                         break;
581                     }
582                 }
583             }
584         }
585 
586         return activeProxy;
587     }
588 
589     public Server getServer( String serverId )
590     {
591         Server match = null;
592 
593         java.util.List servers = getServers();
594         if ( servers != null && serverId != null )
595         {
596             for ( java.util.Iterator it = servers.iterator(); it.hasNext(); )
597             {
598                 Server server = (Server) it.next();
599                 if ( serverId.equals( server.getId() ) )
600                 {
601                     match = server;
602                     break;
603                 }
604             }
605         }
606 
607         return match;
608     }
609 
610     @Deprecated
611     public Mirror getMirrorOf( String repositoryId )
612     {
613         Mirror match = null;
614 
615         java.util.List mirrors = getMirrors();
616         if ( mirrors != null && repositoryId != null )
617         {
618             for ( java.util.Iterator it = mirrors.iterator(); it.hasNext(); )
619             {
620                 Mirror mirror = (Mirror) it.next();
621                 if ( repositoryId.equals( mirror.getMirrorOf() ) )
622                 {
623                     match = mirror;
624                     break;
625                 }
626             }
627         }
628 
629         return match;
630     }
631 
632     private java.util.Map profileMap;
633 
634     /**
635      * Reset the <code>profileMap</code> field to <code>null</code>
636      */
637     public void flushProfileMap()
638     {
639         this.profileMap = null;
640     }
641 
642     /**
643      * @return a Map of profiles field with <code>Profile#getId()</code> as key
644      * @see org.apache.maven.settings.Profile#getId()
645      */
646     public java.util.Map getProfilesAsMap()
647     {
648         if ( profileMap == null )
649         {
650             profileMap = new java.util.LinkedHashMap();
651 
652             if ( getProfiles() != null )
653             {
654                 for ( java.util.Iterator it = getProfiles().iterator(); it.hasNext(); )
655                 {
656                     Profile profile = (Profile) it.next();
657 
658                     profileMap.put( profile.getId(), profile );
659                 }
660             }
661         }
662 
663         return profileMap;
664     }
665 
666     private RuntimeInfo runtimeInfo;
667 
668     public void setRuntimeInfo( RuntimeInfo runtimeInfo )
669     {
670         this.runtimeInfo = runtimeInfo;
671     }
672 
673     public RuntimeInfo getRuntimeInfo()
674     {
675         return runtimeInfo;
676     }
677             
678           
679 }