1 17 18 19 20 package org.apache.fop.render.afp.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 AbstractAFPExtensionObject extends FONode { 35 36 private AFPPageSetup setupCode = null; 37 38 private String _name = null; 39 40 45 public AbstractAFPExtensionObject(FONode parent, String name) { 46 super(parent); 47 _name = name; 48 setupCode = new AFPPageSetup(name); 49 } 50 51 55 protected void validateChildNode(Locator loc, String nsURI, String localName) 56 throws ValidationException { 57 if (FO_URI.equals(nsURI)) { 58 invalidChildError(loc, nsURI, localName); 59 } 60 } 61 62 63 protected void addCharacters(char[] data, int start, int length, 64 PropertyList pList, Locator locator) { 65 } 66 67 68 public String getNamespaceURI() { 69 return AFPElementMapping.NAMESPACE; 70 } 71 72 73 public String getNormalNamespacePrefix() { 74 return AFPElementMapping.NAMESPACE_PREFIX; 75 } 76 77 78 public void processNode(String elementName, Locator locator, 79 Attributes attlist, PropertyList propertyList) 80 throws FOPException { 81 String name = attlist.getValue("name"); 82 if (name != null && name.length() > 0) { 83 setupCode.setName(name); 84 } else { 85 throw new FOPException(elementName + " must have a name attribute."); 86 } 87 if (AFPElementMapping.INCLUDE_PAGE_SEGMENT.equals(elementName)) { 88 name = attlist.getValue("src"); 89 if (name != null && name.length() > 0) { 90 setupCode.setValue(name); 91 } else { 92 throw new FOPException(elementName + " must have a src attribute."); 93 } 94 } 95 if (AFPElementMapping.TAG_LOGICAL_ELEMENT.equals(elementName)) { 96 name = attlist.getValue("value"); 97 if (name != null && name.length() > 0) { 98 setupCode.setValue(name); 99 } else { 100 throw new FOPException(elementName + " must have a value attribute."); 101 } 102 } 103 } 104 105 106 protected void endOfNode() throws FOPException { 107 super.endOfNode(); 108 } 109 110 111 public ExtensionAttachment getExtensionAttachment() { 112 return this.setupCode; 113 } 114 115 116 public String getLocalName() { 117 return _name; 118 } 119 120 } 121 122 | Popular Tags |