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