1 18 package org.apache.batik.dom; 19 20 import java.io.Serializable ; 21 22 import org.apache.batik.dom.events.DocumentEventSupport; 23 import org.apache.batik.dom.util.HashTable; 24 import org.w3c.dom.DOMImplementation ; 25 26 33 34 public abstract class AbstractDOMImplementation 35 implements DOMImplementation , 36 Serializable { 37 38 41 protected final HashTable features = new HashTable(); 42 { 43 registerFeature("XML", new String [] { "1.0", "2.0" }); 44 registerFeature("Events", "2.0"); 45 registerFeature("MouseEvents", "2.0"); 46 registerFeature("MutationEvents", "2.0"); 47 registerFeature("Traversal", "2.0"); 48 registerFeature("UIEvents", "2.0"); 49 } 50 51 54 protected void registerFeature(String name, Object value) { 55 features.put(name.toLowerCase(), value); 56 } 57 58 61 protected AbstractDOMImplementation() { 62 } 63 64 68 public boolean hasFeature(String feature, String version) { 69 Object v = features.get(feature.toLowerCase()); 70 if (v == null) { 71 return false; 72 } 73 if (version == null || version.length() == 0) { 74 return true; 75 } 76 if (v instanceof String ) { 77 return version.equals(v); 78 } else { 79 String [] va = (String [])v; 80 for (int i = 0; i < va.length; i++) { 81 if (version.equals(va[i])) { 82 return true; 83 } 84 } 85 return false; 86 } 87 } 88 89 92 public DocumentEventSupport createDocumentEventSupport() { 93 return new DocumentEventSupport(); 94 } 95 } 96 | Popular Tags |