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   * common base class that contains code to track the source for
15   * this instance (USER|GLOBAL).
16   * 
17   * @version $Revision$ $Date$
18   */
19  public class TrackableBase implements java.io.Serializable {
20  
21  
22      public static final String USER_LEVEL = "user-level";
23      public static final String GLOBAL_LEVEL = "global-level";
24      
25      private String sourceLevel = USER_LEVEL;
26      private boolean sourceLevelSet = false;
27      
28      public void setSourceLevel( String sourceLevel )
29      {
30          if ( sourceLevelSet )
31          {
32              throw new IllegalStateException( "Cannot reset sourceLevel attribute; it is already set to: " + sourceLevel );
33          }
34          else if ( !( USER_LEVEL.equals( sourceLevel ) || GLOBAL_LEVEL.equals( sourceLevel ) ) )
35          {
36              throw new IllegalArgumentException( "sourceLevel must be one of: {" + USER_LEVEL + "," + GLOBAL_LEVEL + "}" );
37          }
38          else
39          {
40              this.sourceLevel = sourceLevel;
41              this.sourceLevelSet = true;
42          }
43      }
44      
45      public String getSourceLevel()
46      {
47          return sourceLevel;
48      }
49            
50      private String modelEncoding = "UTF-8";
51  
52      /**
53       * Set an encoding used for reading/writing the model.
54       *
55       * @param modelEncoding the encoding used when reading/writing the model.
56       */
57      public void setModelEncoding( String modelEncoding )
58      {
59          this.modelEncoding = modelEncoding;
60      }
61  
62      /**
63       * @return the current encoding used when reading/writing this model.
64       */
65      public String getModelEncoding()
66      {
67          return modelEncoding;
68      }
69  }