View Javadoc
1   /*
2    * Copyright 2004 Diogo Quintela (dquintela@users.sourceforge.net)
3    *
4    * Licensed under the Apache License, Version 2.0 (the "License");
5    * you may not use this file except in compliance with the License.
6    * You may obtain a copy of the License at
7    *
8    *     http://www.apache.org/licenses/LICENSE-2.0
9    *
10   * Unless required by applicable law or agreed to in writing, software
11   * distributed under the License is distributed on an "AS IS" BASIS,
12   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13   * See the License for the specific language governing permissions and
14   * limitations under the License.
15   */
16  package net.sf.whatsnew.options;
17  
18  import java.util.HashMap;
19  import java.util.Map;
20  
21  import net.sf.whatsnew.exceptions.*;
22  import net.sf.whatsnew.mode.Mode;
23  
24  
25  /***
26   * <p>Application options</p>
27   * 
28   * @author <a href="mailto:dquintela@users.sourceforge.net">Diogo Quintela</a>
29   * @version $Id: Options.java,v 1.1 2004/05/13 01:22:30 dquintela Exp $
30   */
31  public class Options {
32      /*** File name */
33      public static final Option FILE = new StringOption(null);
34  
35      /*** Application Mode */
36      public static final Option MODE = new IntegerOption(Mode.CHANGE);
37  
38      /*** Release Version  */
39      public static final Option RELEASE_VERSION = new StringOption(null);
40  
41      /*** Release date format (@see java.text.SimpleDateFormat)  */
42      public static final Option RELEASE_DATE_FORMAT = new StringOption(null);
43  
44      /*** Release string format  */
45      public static final Option RELEASE_FORMAT = new StringOption(null);
46      
47      /*** Change message  */
48      public static final Option CHANGE_MESSAGE = new StringOption(null);
49  
50      /*** Options values */
51      private Map values = new HashMap();
52  
53      /***
54       * Set an option
55       *
56       * @param option The option
57       * @param value It's value
58       *
59       * @throws InvalidOptionValue If the value is not a valid value
60       */
61      public void setValue(
62          Option option,
63          Object value)
64      throws InvalidOptionValue {
65          values.put(option, option.getValue(value));
66      }
67  
68      /***
69       * Get the value option, if exists
70       *
71       * @param option The option to consult
72       *
73       * @return The optionValue
74       */
75      public OptionValue getValue(Option option) {
76          return (OptionValue) values.get(option);
77      }
78  }
79  // EOF