1 5 package com.opensymphony.webwork.views.xslt; 6 7 import org.w3c.dom.*; 8 9 import java.util.ArrayList ; 10 import java.util.Iterator ; 11 import java.util.LinkedList ; 12 import java.util.List ; 13 14 15 20 public abstract class DefaultElementAdapter extends DefaultAdapterNode implements AdapterNode, Element { 21 23 private List adapters; 24 25 27 public DefaultElementAdapter(DOMAdapter rootAdapter, AdapterNode parent, String propertyName, Object value) { 28 super(rootAdapter, parent, propertyName, value); 29 } 30 31 33 38 39 public void setAttribute(String string, String string1) throws DOMException { 41 operationNotSupported(); 42 } 43 44 49 public String getAttribute(String string) { 50 return ""; 51 } 52 53 public void setAttributeNS(String string, String string1, String string2) throws DOMException { 54 operationNotSupported(); 55 } 56 57 public String getAttributeNS(String string, String string1) { 58 return null; 59 } 60 61 public Attr setAttributeNode(Attr attr) throws DOMException { 62 operationNotSupported(); 63 64 return null; 65 } 66 67 public Attr getAttributeNode(String string) { 68 return null; 69 } 70 71 public Attr setAttributeNodeNS(Attr attr) throws DOMException { 72 operationNotSupported(); 73 74 return null; 75 } 76 77 public Attr getAttributeNodeNS(String string, String string1) { 78 operationNotSupported(); 79 80 return null; 81 } 82 83 public NodeList getChildNodes() { 84 return getElementsByTagName("*"); 85 } 86 87 public NodeList getElementsByTagName(String tagName) { 88 initChildrenIfNessecary(); 89 90 if (tagName.equals("*")) { 91 return new CollectionNodeList(getAdapters()); 92 } else { 93 LinkedList filteredChildren = new LinkedList (); 94 95 for (Iterator i = getAdapters().iterator(); i.hasNext();) { 96 AdapterNode adapterNode = (AdapterNode) i.next(); 97 98 if (adapterNode.getNodeName().equals(tagName)) { 99 filteredChildren.add(adapterNode); 100 } 101 } 102 103 return new CollectionNodeList(filteredChildren); 104 } 105 } 106 107 public NodeList getElementsByTagNameNS(String string, String string1) { 108 return null; 109 } 110 111 public Node getFirstChild() { 112 return (getChildNodes().getLength() > 0) ? getChildNodes().item(0) : null; 113 } 114 115 public Node getLastChild() { 116 return (getChildNodes().getLength() > 0) ? getChildNodes().item(getChildNodes().getLength() - 1) : null; 117 } 118 119 public Node getNextSibling(AdapterNode child) { 120 int index = getAdapters().indexOf(child); 121 122 if (index < 0) { 123 throw new RuntimeException (child + " is no child of " + this); 124 } 125 126 int siblingIndex = index + 1; 127 Node sibling = ((0 < siblingIndex) && (siblingIndex < getAdapters().size())) ? ((Node) getAdapters().get(siblingIndex)) : null; 128 129 return sibling; 130 } 131 132 public String getNodeName() { 133 return getTagName(); 134 } 135 136 public short getNodeType() { 137 return Node.ELEMENT_NODE; 138 } 139 140 public String getTagName() { 141 return getPropertyName(); 142 } 143 144 public boolean hasAttribute(String string) { 145 return false; 146 } 147 148 public boolean hasAttributeNS(String string, String string1) { 149 return false; 150 } 151 152 public boolean hasChildNodes() { 153 return getElementsByTagName("*").getLength() > 0; 154 } 155 156 public void removeAttribute(String string) throws DOMException { 157 operationNotSupported(); 158 } 159 160 public void removeAttributeNS(String string, String string1) throws DOMException { 161 operationNotSupported(); 162 } 163 164 public Attr removeAttributeNode(Attr attr) throws DOMException { 165 operationNotSupported(); 166 167 return null; 168 } 169 170 protected List getAdapters() { 171 initChildrenIfNessecary(); 172 173 return adapters; 174 } 175 176 protected abstract List buildChildrenAdapters(); 177 178 protected void initChildrenIfNessecary() { 179 if (adapters == null) { 180 adapters = new ArrayList (); 181 182 synchronized (adapters) { 183 adapters = buildChildrenAdapters(); 184 } 185 } 186 } 187 188 189 192 public String getBaseURI() { 193 return null; 195 } 196 197 200 public short compareDocumentPosition(Node other) throws DOMException { 201 return 0; 203 } 204 205 208 public String getTextContent() throws DOMException { 209 return null; 211 } 212 213 216 public void setTextContent(String textContent) throws DOMException { 217 219 } 220 221 224 public boolean isSameNode(Node other) { 225 return false; 227 } 228 229 232 public String lookupPrefix(String namespaceURI) { 233 return null; 235 } 236 237 240 public boolean isDefaultNamespace(String namespaceURI) { 241 return false; 243 } 244 245 248 public String lookupNamespaceURI(String prefix) { 249 return null; 251 } 252 253 256 public boolean isEqualNode(Node arg) { 257 return false; 259 } 260 261 264 public Object getFeature(String feature, String version) { 265 return null; 267 } 268 269 272 public Object setUserData(String key, Object data, UserDataHandler handler) { 273 return null; 275 } 276 277 280 public Object getUserData(String key) { 281 return null; 283 } 284 285 288 public TypeInfo getSchemaTypeInfo() { 289 return null; 291 } 292 293 296 public void setIdAttribute(String name, boolean isId) throws DOMException { 297 299 } 300 301 304 public void setIdAttributeNS(String namespaceURI, String localName, boolean isId) throws DOMException { 305 307 } 308 309 312 public void setIdAttributeNode(Attr idAttr, boolean isId) throws DOMException { 313 315 } 316 317 318 319 320 321 } 322 | Popular Tags |