langtools/src/share/classes/com/sun/tools/javac/util/Options.java
changeset 11314 b612aaca08d0
parent 11052 65b9fa7eaf55
child 22163 3651128c74eb
equal deleted inserted replaced
11313:b23c3e1f32b2 11314:b612aaca08d0
    24  */
    24  */
    25 
    25 
    26 package com.sun.tools.javac.util;
    26 package com.sun.tools.javac.util;
    27 
    27 
    28 import java.util.*;
    28 import java.util.*;
    29 import com.sun.tools.javac.main.OptionName;
    29 import com.sun.tools.javac.main.Option;
    30 import static com.sun.tools.javac.main.OptionName.*;
    30 import static com.sun.tools.javac.main.Option.*;
    31 
    31 
    32 /** A table of all command-line options.
    32 /** A table of all command-line options.
    33  *  If an option has an argument, the option name is mapped to the argument.
    33  *  If an option has an argument, the option name is mapped to the argument.
    34  *  If a set option has no argument, it is mapped to itself.
    34  *  If a set option has no argument, it is mapped to itself.
    35  *
    35  *
    69     }
    69     }
    70 
    70 
    71     /**
    71     /**
    72      * Get the value for an option.
    72      * Get the value for an option.
    73      */
    73      */
    74     public String get(OptionName name) {
    74     public String get(Option option) {
    75         return values.get(name.optionName);
    75         return values.get(option.text);
    76     }
    76     }
    77 
    77 
    78     /**
    78     /**
    79      * Get the boolean value for an option, patterned after Boolean.getBoolean,
    79      * Get the boolean value for an option, patterned after Boolean.getBoolean,
    80      * essentially will return true, iff the value exists and is set to "true".
    80      * essentially will return true, iff the value exists and is set to "true".
    99     }
    99     }
   100 
   100 
   101     /**
   101     /**
   102      * Check if the value for an option has been set.
   102      * Check if the value for an option has been set.
   103      */
   103      */
   104     public boolean isSet(OptionName name) {
   104     public boolean isSet(Option option) {
   105         return (values.get(name.optionName) != null);
   105         return (values.get(option.text) != null);
   106     }
   106     }
   107 
   107 
   108     /**
   108     /**
   109      * Check if the value for a choice option has been set to a specific value.
   109      * Check if the value for a choice option has been set to a specific value.
   110      */
   110      */
   111     public boolean isSet(OptionName name, String value) {
   111     public boolean isSet(Option option, String value) {
   112         return (values.get(name.optionName + value) != null);
   112         return (values.get(option.text + value) != null);
   113     }
   113     }
   114 
   114 
   115     /**
   115     /**
   116      * Check if the value for an undocumented option has not been set.
   116      * Check if the value for an undocumented option has not been set.
   117      */
   117      */
   120     }
   120     }
   121 
   121 
   122     /**
   122     /**
   123      * Check if the value for an option has not been set.
   123      * Check if the value for an option has not been set.
   124      */
   124      */
   125     public boolean isUnset(OptionName name) {
   125     public boolean isUnset(Option option) {
   126         return (values.get(name.optionName) == null);
   126         return (values.get(option.text) == null);
   127     }
   127     }
   128 
   128 
   129     /**
   129     /**
   130      * Check if the value for a choice option has not been set to a specific value.
   130      * Check if the value for a choice option has not been set to a specific value.
   131      */
   131      */
   132     public boolean isUnset(OptionName name, String value) {
   132     public boolean isUnset(Option option, String value) {
   133         return (values.get(name.optionName + value) == null);
   133         return (values.get(option.text + value) == null);
   134     }
   134     }
   135 
   135 
   136     public void put(String name, String value) {
   136     public void put(String name, String value) {
   137         values.put(name, value);
   137         values.put(name, value);
   138     }
   138     }
   139 
   139 
   140     public void put(OptionName name, String value) {
   140     public void put(Option option, String value) {
   141         values.put(name.optionName, value);
   141         values.put(option.text, value);
   142     }
   142     }
   143 
   143 
   144     public void putAll(Options options) {
   144     public void putAll(Options options) {
   145         values.putAll(options.values);
   145         values.putAll(options.values);
   146     }
   146     }