1 17 18 19 20 package org.apache.fop.render.ps.extensions; 21 22 import org.apache.fop.apps.FOPException; 24 import org.apache.fop.fo.FONode; 25 import org.apache.fop.fo.PropertyList; 26 import org.apache.fop.fo.ValidationException; 27 import org.apache.fop.fo.extensions.ExtensionAttachment; 28 import org.xml.sax.Attributes ; 29 import org.xml.sax.Locator ; 30 31 34 public abstract class AbstractPSExtensionObject extends FONode { 35 36 private PSSetupCode setupCode = new PSSetupCode(); 37 38 41 public AbstractPSExtensionObject(FONode parent) { 42 super(parent); 43 } 44 45 49 protected void validateChildNode(Locator loc, String nsURI, String localName) 50 throws ValidationException { 51 if (FO_URI.equals(nsURI)) { 52 invalidChildError(loc, nsURI, localName); 53 } 54 } 55 56 57 protected void addCharacters(char[] data, int start, int length, 58 PropertyList pList, Locator locator) { 59 if (setupCode.getContent() != null) { 60 StringBuffer sb = new StringBuffer (setupCode.getContent()); 61 sb.append(data, start, length - start); 62 setupCode.setContent(sb.toString()); 63 } else { 64 setupCode.setContent(new String (data, start, length - start)); 65 } 66 } 67 68 69 public String getNamespaceURI() { 70 return PSExtensionElementMapping.NAMESPACE; 71 } 72 73 74 public String getNormalNamespacePrefix() { 75 return "fox"; 76 } 77 78 79 public void processNode(String elementName, Locator locator, 80 Attributes attlist, PropertyList propertyList) 81 throws FOPException { 82 String name = attlist.getValue("name"); 83 if (name != null && name.length() > 0) { 84 setupCode.setName(name); 85 } 86 } 87 88 89 protected void endOfNode() throws FOPException { 90 super.endOfNode(); 91 String s = setupCode.getContent(); 92 if (s == null || s.length() == 0) { 93 missingChildElementError("#PCDATA"); 94 } 95 } 96 97 98 public ExtensionAttachment getExtensionAttachment() { 99 return this.setupCode; 100 } 101 102 } 103 104 | Popular Tags |