1 28 29 package com.idaremedia.antx.parameters; 30 31 import com.idaremedia.antx.helpers.Strings; 32 import com.idaremedia.antx.helpers.Tk; 33 34 66 67 public final class PropertySource extends EnumSkeleton 68 { 69 70 public static final int ALL_INDEX = 0; 71 72 public static final int ALLlite_INDEX = ALL_INDEX+1; 73 74 75 public static final int COMMAND_INDEX = ALLlite_INDEX+1; 76 77 public static final int CONTROL_INDEX = COMMAND_INDEX+1; 78 79 80 public static final int SCRIPT_INDEX = CONTROL_INDEX+1; 81 82 public static final int SCRIPTlite_INDEX = SCRIPT_INDEX+1; 83 84 85 public static final int JRE_INDEX = SCRIPTlite_INDEX+1; 86 87 public static final int FIXTURE_INDEX = JRE_INDEX+1; 88 89 90 91 public static final PropertySource ALL= 92 new PropertySource("all",ALL_INDEX); 93 94 95 public static final PropertySource ALLlite= 96 new PropertySource("all--",ALLlite_INDEX); 97 98 99 public static final PropertySource COMMAND= 100 new PropertySource("command",COMMAND_INDEX); 101 102 103 public static final PropertySource CONTROL= 104 new PropertySource("control",CONTROL_INDEX); 105 106 107 public static final PropertySource SCRIPT= 108 new PropertySource("script",SCRIPT_INDEX); 109 110 111 public static final PropertySource SCRIPTlite= 112 new PropertySource("script--",SCRIPTlite_INDEX); 113 114 115 public static final PropertySource JRE= 116 new PropertySource("jre",JRE_INDEX); 117 118 119 public static final PropertySource FIXTURE= 120 new PropertySource("fixture",FIXTURE_INDEX); 121 122 123 124 127 public PropertySource() 128 { 129 super(); 130 } 131 132 133 138 private PropertySource(String v, int i) 139 { 140 super(v); 141 } 142 143 144 149 public String [] getValues() 150 { 151 return new String [] {"all", "all--", 152 "command", "control", 153 "script", "script--", 154 "jre", "fixture"}; 155 }; 156 157 158 159 165 public static PropertySource from(int i) 166 { 167 if (i==COMMAND.index) { return COMMAND; } 168 if (i==ALL.index) { return ALL; } 169 if (i==ALLlite.index) { return ALLlite; } 170 if (i==CONTROL.index) { return CONTROL; } 171 if (i==SCRIPT.index) { return SCRIPT; } 172 if (i==SCRIPTlite.index) { return SCRIPTlite; } 173 if (i==FIXTURE.index) { return FIXTURE; } 174 if (i==JRE.index) { return JRE; } 175 return null; 176 } 177 178 179 186 public static PropertySource from(int i, PropertySource dflt) 187 { 188 PropertySource choice= from(i); 189 return (choice==null) ? dflt : choice; 190 } 191 192 193 198 public static PropertySource from(String s) 199 { 200 if (s!=null && s.length()>1) { 201 s = Tk.lowercaseFrom(s); 202 if (Character.isDigit(s.charAt(0))) { 203 try { return from(Integer.parseInt(s)); } 204 catch(Exception nfx) {} 205 } else { 206 if (COMMAND.value.equals(s)) { return COMMAND; } 210 if (Strings.USER.equals(s)) { return COMMAND; } 211 if (ALL.value.equals(s)) { return ALL; } 212 if (ALLlite.value.equals(s)) { return ALLlite; } 213 if (SCRIPT.value.equals(s)) { return SCRIPT; } 214 if (SCRIPTlite.value.equals(s)) { return SCRIPTlite; } 215 if (CONTROL.value.equals(s)) { return CONTROL; } 216 if (FIXTURE.value.equals(s)) { return FIXTURE; } 217 if (JRE.value.equals(s)) { return JRE; } 218 if (Strings.DEFAULT.equals(s)) { return ALL; } 219 if ("commandline".equals(s)) { return COMMAND; } if ("system".equals(s)) { return JRE; } 221 if ("antx".equals(s)) { return FIXTURE; } 222 } 223 } 224 return null; 225 } 226 227 228 235 public static PropertySource from(String s, PropertySource dflt) 236 { 237 PropertySource choice= from(s); 238 return (choice==null) ? dflt : choice; 239 } 240 } 241 242 243 | Popular Tags |