1 21 22 package gnu.getopt; 23 24 import java.util.Locale ; 25 import java.util.ResourceBundle ; 26 import java.util.PropertyResourceBundle ; 27 import java.text.MessageFormat ; 28 29 30 31 43 public class LongOpt extends Object 44 { 45 46 47 48 51 52 56 public static final int NO_ARGUMENT = 0; 57 58 62 public static final int REQUIRED_ARGUMENT = 1; 63 64 68 public static final int OPTIONAL_ARGUMENT = 2; 69 70 71 72 75 76 79 protected String name; 80 81 85 protected int has_arg; 86 87 92 protected StringBuffer flag; 93 94 98 protected int val; 99 100 103 private ResourceBundle _messages = PropertyResourceBundle.getBundle( 104 "gnu/getopt/MessagesBundle", Locale.getDefault()); 105 106 107 108 111 112 123 public 124 LongOpt(String name, int has_arg, 125 StringBuffer flag, int val) throws IllegalArgumentException 126 { 127 if ((has_arg != NO_ARGUMENT) && (has_arg != REQUIRED_ARGUMENT) 129 && (has_arg != OPTIONAL_ARGUMENT)) 130 { 131 Object [] msgArgs = { new Integer (has_arg).toString() }; 132 throw new IllegalArgumentException (MessageFormat.format( 133 _messages.getString("getopt.invalidValue"), msgArgs)); 134 } 135 136 this.name = name; 138 this.has_arg = has_arg; 139 this.flag = flag; 140 this.val = val; 141 } 142 143 144 145 150 public String 151 getName() 152 { 153 return(name); 154 } 155 156 157 158 163 public int 164 getHasArg() 165 { 166 return(has_arg); 167 } 168 169 170 171 176 public StringBuffer 177 getFlag() 178 { 179 return(flag); 180 } 181 182 187 public int 188 getVal() 189 { 190 return(val); 191 } 192 193 194 195 } 197 | Popular Tags |