1 18 package org.apache.batik.extension; 19 20 import org.apache.batik.dom.AbstractDocument; 21 import org.apache.batik.dom.util.DOMUtilities; 22 import org.w3c.dom.DOMException ; 23 24 30 public abstract class PrefixableStylableExtensionElement 31 extends StylableExtensionElement { 32 33 36 protected String prefix = null; 37 38 41 protected PrefixableStylableExtensionElement() { 42 } 43 44 49 public PrefixableStylableExtensionElement(String prefix, 50 AbstractDocument owner) { 51 super(prefix, owner); 52 setPrefix(prefix); 53 } 54 55 58 public String getNodeName() { 59 return (prefix == null || prefix.equals("")) 60 ? getLocalName() : prefix + ":" + getLocalName(); 61 } 62 63 66 public void setPrefix(String prefix) throws DOMException { 67 if (isReadonly()) { 68 throw createDOMException 69 (DOMException.NO_MODIFICATION_ALLOWED_ERR, "readonly.node", 70 new Object [] { new Integer (getNodeType()), getNodeName() }); 71 } 72 73 if (prefix != null && 74 !prefix.equals("") && 75 !DOMUtilities.isValidName(prefix)) { 76 throw createDOMException 77 (DOMException.INVALID_CHARACTER_ERR, "prefix", 78 new Object [] { new Integer (getNodeType()), 79 getNodeName(), 80 prefix }); 81 } 82 83 this.prefix = prefix; 84 } 85 } 86 | Popular Tags |