View Javadoc

1   /*
2    * $Id$
3    */
4   
5   package org.apache.maven.plugin.registry;
6   
7     //---------------------------------/
8    //- Imported classes and packages -/
9   //---------------------------------/
10  
11  import java.util.Date;
12  
13  /**
14   * Policy for updating a single plugin.
15   * 
16   * @version $Revision$ $Date$
17   */
18  public class Plugin extends TrackableBase 
19  implements java.io.Serializable
20  {
21  
22  
23        //--------------------------/
24       //- Class/Member Variables -/
25      //--------------------------/
26  
27      /**
28       * Field groupId.
29       */
30      private String groupId;
31  
32      /**
33       * Field artifactId.
34       */
35      private String artifactId;
36  
37      /**
38       * [format: yyyy-MM-dd.HH:mm:ss Z] Specifies the date/time at
39       * which this plugin was last checked.
40       */
41      private String lastChecked;
42  
43      /**
44       * The current version of this plugin, to be used until the
45       * appropriate update actions happen.
46       */
47      private String useVersion;
48  
49      /**
50       * Field rejectedVersions.
51       */
52      private java.util.List rejectedVersions;
53  
54  
55        //-----------/
56       //- Methods -/
57      //-----------/
58  
59      /**
60       * Method addRejectedVersion.
61       * 
62       * @param string
63       */
64      public void addRejectedVersion( String string )
65      {
66          if ( !(string instanceof String) )
67          {
68              throw new ClassCastException( "Plugin.addRejectedVersions(string) parameter must be instanceof " + String.class.getName() );
69          }
70          getRejectedVersions().add( string );
71      } //-- void addRejectedVersion( String ) 
72  
73      /**
74       * Get the artifactId field.
75       * 
76       * @return String
77       */
78      public String getArtifactId()
79      {
80          return this.artifactId;
81      } //-- String getArtifactId() 
82  
83      /**
84       * Get the groupId field.
85       * 
86       * @return String
87       */
88      public String getGroupId()
89      {
90          return this.groupId;
91      } //-- String getGroupId() 
92  
93      /**
94       * Get [format: yyyy-MM-dd.HH:mm:ss Z] Specifies the date/time
95       * at which this plugin was last checked.
96       * 
97       * @return String
98       */
99      public String getLastChecked()
100     {
101         return this.lastChecked;
102     } //-- String getLastChecked() 
103 
104     /**
105      * Method getRejectedVersions.
106      * 
107      * @return java.util.List
108      */
109     public java.util.List getRejectedVersions()
110     {
111         if ( this.rejectedVersions == null )
112         {
113             this.rejectedVersions = new java.util.ArrayList();
114         }
115     
116         return this.rejectedVersions;
117     } //-- java.util.List getRejectedVersions() 
118 
119     /**
120      * Get the current version of this plugin, to be used until the
121      * appropriate update actions happen.
122      * 
123      * @return String
124      */
125     public String getUseVersion()
126     {
127         return this.useVersion;
128     } //-- String getUseVersion() 
129 
130     /**
131      * Method removeRejectedVersion.
132      * 
133      * @param string
134      */
135     public void removeRejectedVersion( String string )
136     {
137         if ( !(string instanceof String) )
138         {
139             throw new ClassCastException( "Plugin.removeRejectedVersions(string) parameter must be instanceof " + String.class.getName() );
140         }
141         getRejectedVersions().remove( string );
142     } //-- void removeRejectedVersion( String ) 
143 
144     /**
145      * Set the artifactId field.
146      * 
147      * @param artifactId
148      */
149     public void setArtifactId( String artifactId )
150     {
151         this.artifactId = artifactId;
152     } //-- void setArtifactId( String ) 
153 
154     /**
155      * Set the groupId field.
156      * 
157      * @param groupId
158      */
159     public void setGroupId( String groupId )
160     {
161         this.groupId = groupId;
162     } //-- void setGroupId( String ) 
163 
164     /**
165      * Set [format: yyyy-MM-dd.HH:mm:ss Z] Specifies the date/time
166      * at which this plugin was last checked.
167      * 
168      * @param lastChecked
169      */
170     public void setLastChecked( String lastChecked )
171     {
172         this.lastChecked = lastChecked;
173     } //-- void setLastChecked( String ) 
174 
175     /**
176      * Set the list of versions for this plugin that the user
177      * declined to "install".
178      * 
179      * @param rejectedVersions
180      */
181     public void setRejectedVersions( java.util.List rejectedVersions )
182     {
183         this.rejectedVersions = rejectedVersions;
184     } //-- void setRejectedVersions( java.util.List ) 
185 
186     /**
187      * Set the current version of this plugin, to be used until the
188      * appropriate update actions happen.
189      * 
190      * @param useVersion
191      */
192     public void setUseVersion( String useVersion )
193     {
194         this.useVersion = useVersion;
195     } //-- void setUseVersion( String ) 
196 
197 
198     public static final String LAST_CHECKED_DATE_FORMAT = "yyyy-MM-dd.HH:mm:ss Z";
199     
200     public String getKey()
201     {
202         return getGroupId() + ":" + getArtifactId();
203     }
204           
205     private String modelEncoding = "UTF-8";
206 
207     /**
208      * Set an encoding used for reading/writing the model.
209      *
210      * @param modelEncoding the encoding used when reading/writing the model.
211      */
212     public void setModelEncoding( String modelEncoding )
213     {
214         this.modelEncoding = modelEncoding;
215     }
216 
217     /**
218      * @return the current encoding used when reading/writing this model.
219      */
220     public String getModelEncoding()
221     {
222         return modelEncoding;
223     }
224 }