1 23 24 package com.sun.enterprise.tools.verifier; 25 26 import java.util.ArrayList ; 27 import java.util.List ; 28 29 import org.w3c.dom.Document ; 30 import org.w3c.dom.DocumentType ; 31 import org.w3c.dom.NodeList ; 32 import com.sun.enterprise.tools.verifier.web.TagDescriptor; 33 import com.sun.enterprise.tools.verifier.web.FunctionDescriptor; 34 35 41 public class TagLibDescriptor { 42 public static final String TAG = "tag"; public static final String LISTENER_CLASS = "listener-class"; public static final String FUNCTION = "function"; 46 private Document doc = null; 47 private String version = null; 48 private String uri = null; 49 50 public TagLibDescriptor(Document doc, String version, String uri) { 51 this.doc = doc; 52 this.version = version; 53 this.uri = uri; 54 } 55 58 public String getSpecVersion() { 59 return this.version; 60 } 61 62 65 public String getUri() { 66 return this.uri; 67 } 68 69 public String getPublicID() { 70 DocumentType docType = doc.getDoctype(); 71 return ((docType == null) ? null : docType.getPublicId()); 72 } 73 74 77 public String getSystemID() { 78 DocumentType docType = doc.getDoctype(); 79 return ((docType == null) ? null : docType.getSystemId()); 80 } 81 82 public String [] getListenerClasses(){ 83 NodeList nl = doc.getElementsByTagName(LISTENER_CLASS); 84 String [] classes = null; 85 if (nl != null) { 86 int size = nl.getLength(); 87 classes = new String [size]; 88 for (int i = 0; i < size; i++) { 89 classes[i] = nl.item(i).getFirstChild().getNodeValue(); 90 } 91 } 92 return classes; 93 } 94 95 100 public TagDescriptor[] getTagDescriptors() { 101 NodeList nl = doc.getElementsByTagName(TAG); 102 TagDescriptor[] tagdescriptor = null; 103 if (nl != null) { 104 int size = nl.getLength(); 105 tagdescriptor = new TagDescriptor[size]; 106 for (int i = 0; i < size; i++) { 107 tagdescriptor[i] = new TagDescriptor(nl.item(i)); 108 } 109 } 110 return tagdescriptor; 111 } 112 113 118 public FunctionDescriptor[] getFunctionDescriptors() { 119 NodeList nl = doc.getElementsByTagName(FUNCTION); 120 List <FunctionDescriptor> list = new ArrayList <FunctionDescriptor>(); 121 if (nl != null) { 122 int size = nl.getLength(); 123 for (int i = 0; i < size; i++) { 124 list.add(new FunctionDescriptor(nl.item(i))); 125 } 126 } 127 return list.toArray(new FunctionDescriptor[0]); 128 } 129 } 130 | Popular Tags |