Changeset 3573 for trunk/gsdl3/src/java/org/greenstone/gsdl3/util
- Timestamp:
- 2002-11-26T14:02:44+13:00 (22 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/gsdl3/src/java/org/greenstone/gsdl3/util/GSXML.java
r3512 r3573 8 8 9 9 import java.util.HashMap; 10 //import java.util.Locale; 10 11 11 12 /** various functions for extracting info out of GS XML */ … … 57 58 public static final String SUBACTION_ATT = "subaction"; 58 59 public static final String ADDRESS_ATT = "address"; 59 60 public static final String PARAM_SHORTNAME_ATT = "shortname"; 61 60 62 // parameter types 61 63 public static final String PARAM_TYPE_INTEGER = "integer"; 62 64 public static final String PARAM_TYPE_BOOLEAN = "boolean"; 63 65 public static final String PARAM_TYPE_ENUM = "enum"; 64 public static final String PARAM_TYPE_INPUT = "input"; 66 public static final String PARAM_TYPE_ENUM_SINGLE = "enum_single"; 67 public static final String PARAM_TYPE_ENUM_MULTI = "enum_multi"; 68 public static final String PARAM_TYPE_STRING = "string"; 69 70 71 // stuff for text strings 72 public static final String DISPLAY_ELEM = "display"; 73 public static final String DISPLAY_NAME_ELEM = "name"; 74 public static final String DISPLAY_SUBMIT_ELEM = "submit"; 65 75 66 76 // request types … … 343 353 344 354 345 public static Element createParameter(Document owner, String param_name,355 public static Element createParameter(Document owner, String name, 346 356 String type, String default_value, 347 String [] values) {357 String []options) { 348 358 349 359 350 360 Element p = owner.createElement(PARAM_ELEM); 351 p.setAttribute(NAME_ATT, param_name);361 p.setAttribute(NAME_ATT, name); 352 362 p.setAttribute(TYPE_ATT, type); 353 363 if (default_value != null) { 354 364 p.setAttribute(DEFAULT_ATT, default_value); 355 365 } 356 if (type. equals(PARAM_TYPE_ENUM) && values!=null) {357 for (int i=0; i< values.length; i++) {366 if (type.startsWith(PARAM_TYPE_ENUM) && options!=null) { 367 for (int i=0; i<options.length; i++) { 358 368 Element e = owner.createElement(PARAM_OPTION_ELEM); 359 e.setAttribute(NAME_ATT, values[i]);369 e.setAttribute(NAME_ATT, options[i]); 360 370 p.appendChild(e); 361 371 } 362 372 } 363 373 return p; 374 } 375 376 /** creates a parm elem containing the text strings 377 * <param><name>xxx<name><option name='x'>yyy</option><option name='y'>zzz</option></param> 378 */ 379 public static Element createParameterDisplay(Document owner, String name, 380 String name_text, 381 String []options, 382 String []option_texts) { 383 384 385 Element param = owner.createElement(PARAM_ELEM); 386 param.setAttribute(NAME_ATT, name); 387 param.appendChild(createTextElement(owner, DISPLAY_NAME_ELEM, name_text)); 388 if (options != null) { 389 for (int i=0; i<options.length; i++) { 390 Element e = GSXML.createTextElement(owner, PARAM_OPTION_ELEM, option_texts[i]); 391 e.setAttribute(NAME_ATT, options[i]); 392 param.appendChild(e); 393 } 394 } 395 396 return param; 364 397 } 365 398
Note:
See TracChangeset
for help on using the changeset viewer.