1 17 18 19 20 package org.apache.fop.render.ps.extensions; 21 22 import java.io.Serializable ; 23 24 import org.apache.fop.fo.extensions.ExtensionAttachment; 25 import org.apache.fop.util.XMLizable; 26 import org.xml.sax.ContentHandler ; 27 import org.xml.sax.SAXException ; 28 import org.xml.sax.helpers.AttributesImpl ; 29 30 33 public class PSSetupCode implements ExtensionAttachment, Serializable , XMLizable { 34 35 36 public static final String CATEGORY = "apache:fop:extensions:postscript"; 37 38 private String name; 39 private String content; 40 41 44 public PSSetupCode() { 45 } 47 48 53 public PSSetupCode(String name, String content) { 54 this.name = name; 55 this.content = content; 56 } 57 58 59 public String getContent() { 60 return content; 61 } 62 63 67 public void setContent(String content) { 68 this.content = content; 69 } 70 71 72 public String getName() { 73 return name; 74 } 75 76 80 public void setName(String name) { 81 this.name = name; 82 } 83 84 85 public String getCategory() { 86 return CATEGORY; 87 } 88 89 90 public String toString() { 91 return "PSSetupCode(name=" + getName() + ")"; 92 } 93 94 private static final String ATT_NAME = "name"; 95 private static final String ELEMENT = "ps-setup-code"; 96 97 98 public void toSAX(ContentHandler handler) throws SAXException { 99 AttributesImpl atts = new AttributesImpl (); 100 if (name != null && name.length() > 0) { 101 atts.addAttribute(null, ATT_NAME, ATT_NAME, "CDATA", name); 102 } 103 handler.startElement(CATEGORY, ELEMENT, ELEMENT, atts); 104 if (content != null && content.length() > 0) { 105 char[] chars = content.toCharArray(); 106 handler.characters(chars, 0, chars.length); 107 } 108 handler.endElement(CATEGORY, ELEMENT, ELEMENT); 109 } 110 111 } 112 | Popular Tags |