Changeset 3509
- Timestamp:
- 2002-10-30T10:37:02+13:00 (21 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/gsdl3/src/java/org/greenstone/gsdl3/util/GSXML.java
r3488 r3509 12 12 public class GSXML { 13 13 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 14 44 public static final String PARAM_TYPE_INTEGER = "integer"; 15 45 public static final String PARAM_TYPE_BOOLEAN = "boolean"; 16 46 public static final String PARAM_TYPE_ENUM = "enum"; 17 47 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 20 57 public static String [] getResourceNameList(Element content) { 21 58 22 59 Node n = content.getFirstChild(); 23 while (n!=null && !n.getNodeName().equals( "resourceList")) {60 while (n!=null && !n.getNodeName().equals(RESOURCE_ELEM+LIST_MODIFIER)) { 24 61 n = n.getNextSibling(); 25 62 } … … 34 71 for (int i=0; i<numdocs; i++) { 35 72 Element e = (Element)docs.item(i); 36 String id = e.getAttribute( "name");73 String id = e.getAttribute(NAME_ATT); 37 74 // check that its a valid id - ie starts with HASH 38 75 // need to change this if use different ids … … 48 85 public static String [] getMetaNameList(Element content) { 49 86 Node n = content.getFirstChild(); 50 while (n!=null && !n.getNodeName().equals("metadataList")) { 87 while (n!=null && 88 !n.getNodeName().equals(METADATA_ELEM+LIST_MODIFIER)) { 51 89 n = n.getNextSibling(); 52 90 } … … 60 98 for (int i=0; i<numelems; i++) { 61 99 Element e = (Element)elems.item(i); 62 String id = e.getAttribute( "name");100 String id = e.getAttribute(NAME_ATT); 63 101 ids[i] = id; 64 102 } … … 70 108 public static HashMap extractParams(Element xml) { 71 109 72 if (!xml.getNodeName().equals( "paramList")) {110 if (!xml.getNodeName().equals(PARAM_ELEM+LIST_MODIFIER)) { 73 111 System.err.println("GSXML:paramList element should have been passed to extractParams, instead it was "+xml.getNodeName()); 74 112 return null; … … 78 116 for (int i=0; i<params.getLength(); i++) { 79 117 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); 82 120 if (value.equals("")) { // the value is in the content of the param 83 121 value=getNodeText(param); … … 90 128 91 129 public static String getValue(Element e) { 92 String val = e.getAttribute( "value");130 String val = e.getAttribute(VALUE_ATT); 93 131 if (val ==null || val.equals("")) { 94 132 // have to get it out of the text … … 112 150 /** creates a new document Element */ 113 151 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); 116 154 117 155 return e;
Note:
See TracChangeset
for help on using the changeset viewer.