KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > fop > render > ps > extensions > PSSetupCode


1 /*
2  * Licensed to the Apache Software Foundation (ASF) under one or more
3  * contributor license agreements. See the NOTICE file distributed with
4  * this work for additional information regarding copyright ownership.
5  * The ASF licenses this file to You under the Apache License, Version 2.0
6  * (the "License"); you may not use this file except in compliance with
7  * the License. You may obtain a copy of the License at
8  *
9  * http://www.apache.org/licenses/LICENSE-2.0
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  */

17
18 /* $Id: PSSetupCode.java 426576 2006-07-28 15:44:37Z jeremias $ */
19
20 package org.apache.fop.render.ps.extensions;
21
22 import java.io.Serializable JavaDoc;
23
24 import org.apache.fop.fo.extensions.ExtensionAttachment;
25 import org.apache.fop.util.XMLizable;
26 import org.xml.sax.ContentHandler JavaDoc;
27 import org.xml.sax.SAXException JavaDoc;
28 import org.xml.sax.helpers.AttributesImpl JavaDoc;
29
30 /**
31  * This is the pass-through value object for the PostScript extension.
32  */

33 public class PSSetupCode implements ExtensionAttachment, Serializable JavaDoc, XMLizable {
34
35     /** The category URI for this extension attachment. */
36     public static final String JavaDoc CATEGORY = "apache:fop:extensions:postscript";
37     
38     private String JavaDoc name;
39     private String JavaDoc content;
40
41     /**
42      * No-argument contructor.
43      */

44     public PSSetupCode() {
45         //nop
46
}
47     
48     /**
49      * Default constructor.
50      * @param name the name of the setup code object, may be null
51      * @param content the content of the setup code object
52      */

53     public PSSetupCode(String JavaDoc name, String JavaDoc content) {
54         this.name = name;
55         this.content = content;
56     }
57     
58     /** @return the content */
59     public String JavaDoc getContent() {
60         return content;
61     }
62     
63     /**
64      * Sets the content for the setup code object.
65      * @param content The content to set.
66      */

67     public void setContent(String JavaDoc content) {
68         this.content = content;
69     }
70     
71     /** @return the name */
72     public String JavaDoc getName() {
73         return name;
74     }
75     
76     /**
77      * Sets the name of the setup code object.
78      * @param name The name to set.
79      */

80     public void setName(String JavaDoc name) {
81         this.name = name;
82     }
83
84     /** @see org.apache.fop.fo.extensions.ExtensionAttachment#getCategory() */
85     public String JavaDoc getCategory() {
86         return CATEGORY;
87     }
88     
89     /** @see java.lang.Object#toString() */
90     public String JavaDoc toString() {
91         return "PSSetupCode(name=" + getName() + ")";
92     }
93
94     private static final String JavaDoc ATT_NAME = "name";
95     private static final String JavaDoc ELEMENT = "ps-setup-code";
96     
97     /** @see org.apache.fop.util.XMLizable#toSAX(org.xml.sax.ContentHandler) */
98     public void toSAX(ContentHandler JavaDoc handler) throws SAXException JavaDoc {
99         AttributesImpl JavaDoc atts = new AttributesImpl JavaDoc();
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