View Javadoc

1   /*
2    * $Id$
3    */
4   
5   package org.apache.maven.model;
6   
7     //---------------------------------/
8    //- Imported classes and packages -/
9   //---------------------------------/
10  
11  import java.util.Date;
12  
13  /**
14   * Contains the plugins informations for the project.
15   * 
16   * @version $Revision$ $Date$
17   */
18  public class PluginContainer implements java.io.Serializable {
19  
20  
21        //--------------------------/
22       //- Class/Member Variables -/
23      //--------------------------/
24  
25      /**
26       * Field plugins.
27       */
28      private java.util.List plugins;
29  
30  
31        //-----------/
32       //- Methods -/
33      //-----------/
34  
35      /**
36       * Method addPlugin.
37       * 
38       * @param plugin
39       */
40      public void addPlugin( Plugin plugin )
41      {
42          if ( !(plugin instanceof Plugin) )
43          {
44              throw new ClassCastException( "PluginContainer.addPlugins(plugin) parameter must be instanceof " + Plugin.class.getName() );
45          }
46          getPlugins().add( plugin );
47      } //-- void addPlugin( Plugin ) 
48  
49      /**
50       * Method getPlugins.
51       * 
52       * @return java.util.List
53       */
54      public java.util.List getPlugins()
55      {
56          if ( this.plugins == null )
57          {
58              this.plugins = new java.util.ArrayList();
59          }
60      
61          return this.plugins;
62      } //-- java.util.List getPlugins() 
63  
64      /**
65       * Method removePlugin.
66       * 
67       * @param plugin
68       */
69      public void removePlugin( Plugin plugin )
70      {
71          if ( !(plugin instanceof Plugin) )
72          {
73              throw new ClassCastException( "PluginContainer.removePlugins(plugin) parameter must be instanceof " + Plugin.class.getName() );
74          }
75          getPlugins().remove( plugin );
76      } //-- void removePlugin( Plugin ) 
77  
78      /**
79       * Set the list of plugins to use.
80       * 
81       * @param plugins
82       */
83      public void setPlugins( java.util.List plugins )
84      {
85          this.plugins = plugins;
86      } //-- void setPlugins( java.util.List ) 
87  
88  
89              
90      java.util.Map pluginMap;
91  
92      /**
93       * Reset the <code>pluginsMap</code> field to <code>null</code>
94       */
95      public void flushPluginMap()
96      {
97          this.pluginMap = null;
98      }
99  
100     /**
101      * @return a Map of plugins field with <code>Plugins#getKey()</code> as key
102      * @see org.apache.maven.model.Plugin#getKey()
103      */
104     public java.util.Map getPluginsAsMap()
105     {
106         if ( pluginMap == null )
107         {
108             pluginMap = new java.util.LinkedHashMap();
109             if ( plugins != null )
110             {
111                 for ( java.util.Iterator it = plugins.iterator(); it.hasNext(); )
112                 {
113                     Plugin plugin = (Plugin) it.next();
114                     pluginMap.put( plugin.getKey(), plugin );
115                 }
116             }
117         }
118 
119         return pluginMap;
120     }
121             
122           
123     private String modelEncoding = "UTF-8";
124 
125     /**
126      * Set an encoding used for reading/writing the model.
127      *
128      * @param modelEncoding the encoding used when reading/writing the model.
129      */
130     public void setModelEncoding( String modelEncoding )
131     {
132         this.modelEncoding = modelEncoding;
133     }
134 
135     /**
136      * @return the current encoding used when reading/writing this model.
137      */
138     public String getModelEncoding()
139     {
140         return modelEncoding;
141     }
142 }