Ignore:
Timestamp:
2002-11-26T14:02:44+13:00 (22 years ago)
Author:
kjdon
Message:

added method for param display element

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/gsdl3/src/java/org/greenstone/gsdl3/util/GSXML.java

    r3512 r3573  
    88
    99import java.util.HashMap;
     10//import java.util.Locale;
    1011
    1112/** various functions for extracting info out of GS XML */
     
    5758    public static final String SUBACTION_ATT = "subaction";
    5859    public static final String ADDRESS_ATT = "address";
    59    
     60    public static final String PARAM_SHORTNAME_ATT = "shortname";
     61
    6062    // parameter types
    6163    public static final String PARAM_TYPE_INTEGER = "integer";
    6264    public static final String PARAM_TYPE_BOOLEAN = "boolean";
    6365    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";
    6575
    6676    // request types
     
    343353
    344354
    345     public static Element createParameter(Document owner, String param_name,
     355    public static Element createParameter(Document owner, String name,
    346356                      String type, String default_value,
    347                       String []values) {
     357                      String []options) {
    348358
    349359
    350360    Element p = owner.createElement(PARAM_ELEM);
    351     p.setAttribute(NAME_ATT, param_name);
     361    p.setAttribute(NAME_ATT, name);
    352362    p.setAttribute(TYPE_ATT, type);
    353363    if (default_value != null) {
    354364        p.setAttribute(DEFAULT_ATT, default_value);
    355365    }
    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++) {
    358368        Element e = owner.createElement(PARAM_OPTION_ELEM);
    359         e.setAttribute(NAME_ATT, values[i]);
     369        e.setAttribute(NAME_ATT, options[i]);
    360370        p.appendChild(e);
    361371        }
    362372    }
    363373    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;
    364397    }
    365398
Note: See TracChangeset for help on using the changeset viewer.