View Javadoc

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