View Javadoc

1   /*
2    * $Id$
3    */
4   
5   package org.apache.maven.profiles;
6   
7     //---------------------------------/
8    //- Imported classes and packages -/
9   //---------------------------------/
10  
11  import java.util.Date;
12  
13  /**
14   * 
15   *         Modifications to the build process which is keyed on
16   * some 
17   *         sort of environmental parameter.
18   *       
19   * 
20   * @version $Revision$ $Date$
21   */
22  public class Profile implements java.io.Serializable {
23  
24  
25        //--------------------------/
26       //- Class/Member Variables -/
27      //--------------------------/
28  
29      /**
30       * The ID of this build profile, for activation
31       *             purposes.
32       */
33      private String id;
34  
35      /**
36       * The conditional logic which will automatically
37       *             trigger the inclusion of this profile.
38       */
39      private Activation activation;
40  
41      /**
42       * Field properties.
43       */
44      private java.util.Properties properties;
45  
46      /**
47       * Field repositories.
48       */
49      private java.util.List repositories;
50  
51      /**
52       *  This may be removed or relocated in the near
53       *             future. It is undecided whether plugins really
54       * need a remote
55       *             repository set of their own. 
56       */
57      private java.util.List pluginRepositories;
58  
59  
60        //-----------/
61       //- Methods -/
62      //-----------/
63  
64      /**
65       * Method addPluginRepository.
66       * 
67       * @param repository
68       */
69      public void addPluginRepository( Repository repository )
70      {
71          if ( !(repository instanceof Repository) )
72          {
73              throw new ClassCastException( "Profile.addPluginRepositories(repository) parameter must be instanceof " + Repository.class.getName() );
74          }
75          getPluginRepositories().add( repository );
76      } //-- void addPluginRepository( Repository ) 
77  
78      /**
79       * Method addProperty.
80       * 
81       * @param key
82       * @param value
83       */
84      public void addProperty( String key, String value )
85      {
86          getProperties().put( key, value );
87      } //-- void addProperty( String, String ) 
88  
89      /**
90       * Method addRepository.
91       * 
92       * @param repository
93       */
94      public void addRepository( Repository repository )
95      {
96          if ( !(repository instanceof Repository) )
97          {
98              throw new ClassCastException( "Profile.addRepositories(repository) parameter must be instanceof " + Repository.class.getName() );
99          }
100         getRepositories().add( repository );
101     } //-- void addRepository( Repository ) 
102 
103     /**
104      * Get the conditional logic which will automatically
105      *             trigger the inclusion of this profile.
106      * 
107      * @return Activation
108      */
109     public Activation getActivation()
110     {
111         return this.activation;
112     } //-- Activation getActivation() 
113 
114     /**
115      * Get the ID of this build profile, for activation
116      *             purposes.
117      * 
118      * @return String
119      */
120     public String getId()
121     {
122         return this.id;
123     } //-- String getId() 
124 
125     /**
126      * Method getPluginRepositories.
127      * 
128      * @return java.util.List
129      */
130     public java.util.List getPluginRepositories()
131     {
132         if ( this.pluginRepositories == null )
133         {
134             this.pluginRepositories = new java.util.ArrayList();
135         }
136     
137         return this.pluginRepositories;
138     } //-- java.util.List getPluginRepositories() 
139 
140     /**
141      * Method getProperties.
142      * 
143      * @return java.util.Properties
144      */
145     public java.util.Properties getProperties()
146     {
147         if ( this.properties == null )
148         {
149             this.properties = new java.util.Properties();
150         }
151     
152         return this.properties;
153     } //-- java.util.Properties getProperties() 
154 
155     /**
156      * Method getRepositories.
157      * 
158      * @return java.util.List
159      */
160     public java.util.List getRepositories()
161     {
162         if ( this.repositories == null )
163         {
164             this.repositories = new java.util.ArrayList();
165         }
166     
167         return this.repositories;
168     } //-- java.util.List getRepositories() 
169 
170     /**
171      * Method removePluginRepository.
172      * 
173      * @param repository
174      */
175     public void removePluginRepository( Repository repository )
176     {
177         if ( !(repository instanceof Repository) )
178         {
179             throw new ClassCastException( "Profile.removePluginRepositories(repository) parameter must be instanceof " + Repository.class.getName() );
180         }
181         getPluginRepositories().remove( repository );
182     } //-- void removePluginRepository( Repository ) 
183 
184     /**
185      * Method removeRepository.
186      * 
187      * @param repository
188      */
189     public void removeRepository( Repository repository )
190     {
191         if ( !(repository instanceof Repository) )
192         {
193             throw new ClassCastException( "Profile.removeRepositories(repository) parameter must be instanceof " + Repository.class.getName() );
194         }
195         getRepositories().remove( repository );
196     } //-- void removeRepository( Repository ) 
197 
198     /**
199      * Set the conditional logic which will automatically
200      *             trigger the inclusion of this profile.
201      * 
202      * @param activation
203      */
204     public void setActivation( Activation activation )
205     {
206         this.activation = activation;
207     } //-- void setActivation( Activation ) 
208 
209     /**
210      * Set the ID of this build profile, for activation
211      *             purposes.
212      * 
213      * @param id
214      */
215     public void setId( String id )
216     {
217         this.id = id;
218     } //-- void setId( String ) 
219 
220     /**
221      * Set 
222      *           The lists of the remote repositories for
223      * discovering plugins
224      *         .
225      * 
226      * @param pluginRepositories
227      */
228     public void setPluginRepositories( java.util.List pluginRepositories )
229     {
230         this.pluginRepositories = pluginRepositories;
231     } //-- void setPluginRepositories( java.util.List ) 
232 
233     /**
234      * Set extended configuration specific to this profile goes
235      *             here.
236      * 
237      * @param properties
238      */
239     public void setProperties( java.util.Properties properties )
240     {
241         this.properties = properties;
242     } //-- void setProperties( java.util.Properties ) 
243 
244     /**
245      * Set the lists of the remote repositories
246      *           .
247      * 
248      * @param repositories
249      */
250     public void setRepositories( java.util.List repositories )
251     {
252         this.repositories = repositories;
253     } //-- void setRepositories( java.util.List ) 
254 
255 
256     private String modelEncoding = "UTF-8";
257 
258     /**
259      * Set an encoding used for reading/writing the model.
260      *
261      * @param modelEncoding the encoding used when reading/writing the model.
262      */
263     public void setModelEncoding( String modelEncoding )
264     {
265         this.modelEncoding = modelEncoding;
266     }
267 
268     /**
269      * @return the current encoding used when reading/writing this model.
270      */
271     public String getModelEncoding()
272     {
273         return modelEncoding;
274     }
275 }