KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > ecs > rtf > RTFDocument


1 /*
2  * ====================================================================
3  *
4  * The Apache Software License, Version 1.1
5  *
6  * Copyright (c) 1999-2003 The Apache Software Foundation. All rights
7  * reserved.
8  *
9  * Redistribution and use in source and binary forms, with or without
10  * modification, are permitted provided that the following conditions
11  * are met:
12  *
13  * 1. Redistributions of source code must retain the above copyright
14  * notice, this list of conditions and the following disclaimer.
15  *
16  * 2. Redistributions in binary form must reproduce the above copyright
17  * notice, this list of conditions and the following disclaimer in
18  * the documentation and/or other materials provided with the
19  * distribution.
20  *
21  * 3. The end-user documentation included with the redistribution, if
22  * any, must include the following acknowlegement:
23  * "This product includes software developed by the
24  * Apache Software Foundation (http://www.apache.org/)."
25  * Alternately, this acknowlegement may appear in the software itself,
26  * if and wherever such third-party acknowlegements normally appear.
27  *
28  * 4. The names "The Jakarta Project", "Jakarta Element Construction Set",
29  * "Jakarta ECS" , and "Apache Software Foundation" must not be used
30  * to endorse or promote products derived
31  * from this software without prior written permission. For written
32  * permission, please contact apache@apache.org.
33  *
34  * 5. Products derived from this software may not be called "Apache",
35  * "Jakarta Element Construction Set" nor "Jakarta ECS" nor may "Apache"
36  * appear in their names without prior written permission of the Apache Group.
37  *
38  * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
39  * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
40  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
41  * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
42  * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
43  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
44  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
45  * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
46  * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
47  * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
48  * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
49  * SUCH DAMAGE.
50  * ====================================================================
51  *
52  * This software consists of voluntary contributions made by many
53  * individuals on behalf of the Apache Software Foundation. For more
54  * information on the Apache Software Foundation, please see
55  * <http://www.apache.org/>.
56  *
57  */

58 package org.apache.ecs.rtf;
59
60 import org.apache.ecs.ConcreteElement;
61
62 public class RTFDocument
63 {
64     // static declerations.
65

66     /** Ansi character set. ( the default ) */
67     public static String JavaDoc ANSI = "\\ansi";
68     /** Apple Macintosh character set. */
69     public static String JavaDoc MAC = "\\mac";
70     /** IBM PC code page 437 character set. */
71     public static String JavaDoc PC = "\\pc";
72     /** IBM PC code page 850 character set. */
73     public static String JavaDoc PCA = "\\pca";
74
75     private Info info = new Info();
76     private Title title = new Title();
77     private Subject subject = new Subject();
78     private Comment comment = new Comment();
79     private Version version = new Version();
80
81     RTF rtf = new RTF();
82     /* Default Initializer */
83     {
84         rtf.addElement("charSet",ANSI);
85         info.addElement(title);
86         info.addElement(subject);
87         info.addElement(version);
88         info.addElement(comment);
89         rtf.addElement(info);
90     }
91
92     public RTFDocument()
93     {
94     }
95
96     public Info getInfo()
97     {
98         return info;
99     }
100
101     public RTFDocument setTitle(String JavaDoc title)
102     {
103         this.title.addElement(title);
104         return this;
105     }
106
107     public RTFDocument setVersion(int version)
108     {
109         this.version.setVersion(version);
110         return this;
111     }
112
113     public RTFDocument setComment(String JavaDoc comment)
114     {
115         this.comment.addElement("comment",comment);
116         return this;
117     }
118
119     public RTFDocument setSubject(String JavaDoc subject)
120     {
121         this.subject.addElement(subject);
122         return this;
123     }
124
125     public RTFDocument setColorTable(ColorTbl tbl)
126     {
127         rtf.addElement(tbl);
128         return this;
129     }
130
131     public RTFDocument setCharacterSet(String JavaDoc charSet)
132     {
133         rtf.addElement("charSet",charSet);
134         return this;
135     }
136
137     public RTFDocument setCodeSet(String JavaDoc codePage)
138     {
139         rtf.addElement("\\ansicpg"+codePage);
140         return this;
141     }
142
143     public org.apache.ecs.ConcreteElement getElement(String JavaDoc element)
144     {
145         return rtf.getElement(element);
146     }
147
148     public RTFDocument addElement(String JavaDoc element)
149     {
150         rtf.addElement(element);
151         return this;
152     }
153
154     public RTFDocument addElement(String JavaDoc key,String JavaDoc element)
155     {
156         rtf.addElement(key,element);
157         return this;
158     }
159
160     public RTFDocument addElement(RTFElement element)
161     {
162         rtf.addElement(element);
163         return this;
164     }
165
166     public RTFDocument addElement(String JavaDoc key, RTFElement element)
167     {
168         rtf.addElement(key,element);
169         return this;
170     }
171
172     public void output(java.io.OutputStream JavaDoc out)
173     {
174         rtf.output(out);
175     }
176
177     public void output(java.io.PrintWriter JavaDoc out)
178     {
179         rtf.output(out);
180     }
181 }
182
Popular Tags