Changeset 3509


Ignore:
Timestamp:
2002-10-30T10:37:02+13:00 (21 years ago)
Author:
kjdon
Message:

made all the xml elem names etc constants

File:
1 edited

Legend:

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

    r3488 r3509  
    1212public class GSXML {
    1313
     14    // greenstone xml elements
     15    public static final String MESSAGE_ELEM = "message";
     16    public static final String REQUEST_ELEM = "request";
     17    public static final String RESPONSE_ELEM = "response";
     18    public static final String COLLECTION_ELEM = "collection";
     19    public static final String SERVICE_ELEM = "service";
     20    public static final String CLUSTER_ELEM = "serviceCluster";
     21    public static final String SITE_ELEM = "site";
     22    public static final String PARAM_ELEM = "param";
     23    public static final String OPTION_ELEM = "option";
     24    public static final String CONTENT_ELEM = "content";
     25    public static final String RESOURCE_ELEM = "resource";
     26    public static final String METADATA_ELEM = "metadata";
     27    public static final String SERVICE_IMPL_ELEM = "servicesImpl";
     28    // add on to another elem type to get a list of that type
     29    public static final String LIST_MODIFIER = "List";
     30
     31    //public static final String
     32    //public static final String
     33
     34    // greenstone xml attributes
     35    public static final String NAME_ATT = "name";
     36    public static final String TO_ATT = "to";
     37    public static final String FROM_ATT = "from";
     38    public static final String LANG_ATT = "lang";
     39    public static final String TYPE_ATT = "type";
     40    public static final String VALUE_ATT = "value";
     41    public static final String DEFAULT_ATT = "default";
     42    public static final String INFO_ATT = "info";
     43    // parameter types
    1444    public static final String PARAM_TYPE_INTEGER = "integer";
    1545    public static final String PARAM_TYPE_BOOLEAN = "boolean";
    1646    public static final String PARAM_TYPE_ENUM = "enum";
    1747    public static final String PARAM_TYPE_INPUT = "input";
    18   // takes a node with a resource elements inside it and extracts all the
    19   // HASh oids - name att for resource
     48
     49    // request types
     50    public static final String REQUEST_TYPE_DESCRIBE = "describe";
     51    public static final String REQUEST_TYPE_CONFIGURE = "configure";
     52    public static final String REQUEST_TYPE_QUERY = "query";
     53    // public static final String REQUEST_TYPE_
     54   
     55    // takes a node with a resource elements inside it and extracts all the
     56    // HASh oids - name att for resource
    2057    public static String [] getResourceNameList(Element content) {
    2158   
    2259    Node n = content.getFirstChild();
    23     while (n!=null && !n.getNodeName().equals("resourceList")) {
     60    while (n!=null && !n.getNodeName().equals(RESOURCE_ELEM+LIST_MODIFIER)) {
    2461        n = n.getNextSibling();
    2562    }
     
    3471    for (int i=0; i<numdocs; i++) {
    3572        Element e = (Element)docs.item(i);
    36         String id = e.getAttribute("name");
     73        String id = e.getAttribute(NAME_ATT);
    3774        // check that its a valid id - ie starts with HASH
    3875        // need to change this if use different ids
     
    4885    public static String [] getMetaNameList(Element content) {
    4986    Node n = content.getFirstChild();
    50     while (n!=null && !n.getNodeName().equals("metadataList")) {
     87    while (n!=null &&
     88           !n.getNodeName().equals(METADATA_ELEM+LIST_MODIFIER)) {
    5189        n = n.getNextSibling();
    5290    }
     
    6098    for (int i=0; i<numelems; i++) {
    6199        Element e = (Element)elems.item(i);
    62         String id = e.getAttribute("name");
     100        String id = e.getAttribute(NAME_ATT);
    63101        ids[i] = id;
    64102    }
     
    70108    public static HashMap extractParams(Element xml) {
    71109
    72     if (!xml.getNodeName().equals("paramList")) {
     110    if (!xml.getNodeName().equals(PARAM_ELEM+LIST_MODIFIER)) {
    73111        System.err.println("GSXML:paramList element should have been passed to extractParams, instead it was "+xml.getNodeName());
    74112        return null;
     
    78116    for (int i=0; i<params.getLength(); i++) {
    79117        Element param = (Element)params.item(i);
    80         String name=param.getAttribute("name");
    81         String value=param.getAttribute("value");
     118        String name=param.getAttribute(NAME_ATT);
     119        String value=param.getAttribute(VALUE_ATT);
    82120        if (value.equals("")) { // the value is in the content of the param
    83121        value=getNodeText(param);
     
    90128
    91129    public static String getValue(Element e) {
    92     String val = e.getAttribute("value");
     130    String val = e.getAttribute(VALUE_ATT);
    93131    if (val ==null || val.equals("")) {
    94132        // have to get it out of the text
     
    112150    /** creates a new document Element */
    113151    public static Element createResourceElement(Document owner, String oid) {
    114     Element e = owner.createElement("resource");
    115     e.setAttribute("name", oid);
     152    Element e = owner.createElement(RESOURCE_ELEM);
     153    e.setAttribute(NAME_ATT, oid);
    116154   
    117155    return e;
Note: See TracChangeset for help on using the changeset viewer.