KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > lowagie > text > rtf > GenericRtfField


1 /**
2  * $Id: GenericRtfField.java 2655 2007-03-15 19:26:36Z xlv $
3  *
4  * Copyright 2002 by
5  * <a HREF="http://www.smb-tec.com">SMB</a>
6  * Dirk Weigenand (Dirk.Weigenand@smb-tec.com)
7  *
8  * The contents of this file are subject to the Mozilla Public License Version 1.1
9  * (the "License"); you may not use this file except in compliance with the License.
10  * You may obtain a copy of the License at http://www.mozilla.org/MPL/
11  *
12  * Software distributed under the License is distributed on an "AS IS" basis,
13  * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
14  * for the specific language governing rights and limitations under the License.
15  *
16  * The Original Code is 'iText, a free JAVA-PDF library'.
17  *
18  * The Initial Developer of the Original Code is Bruno Lowagie. Portions created by
19  * the Initial Developer are Copyright (C) 1999, 2000, 2001, 2002 by Bruno Lowagie.
20  * All Rights Reserved.
21  * Co-Developer of the code is Paulo Soares. Portions created by the Co-Developer
22  * are Copyright (C) 2000, 2001, 2002 by Paulo Soares. All Rights Reserved.
23  *
24  * Contributor(s): all the names of the contributors are added in the source code
25  * where applicable.
26  *
27  * Alternatively, the contents of this file may be used under the terms of the
28  * LGPL license (the "GNU LIBRARY GENERAL PUBLIC LICENSE"), in which case the
29  * provisions of LGPL are applicable instead of those above. If you wish to
30  * allow use of your version of this file only under the terms of the LGPL
31  * License and not to allow others to use your version of this file under
32  * the MPL, indicate your decision by deleting the provisions above and
33  * replace them with the notice and other provisions required by the LGPL.
34  * If you do not delete the provisions above, a recipient may use your version
35  * of this file under either the MPL or the GNU LIBRARY GENERAL PUBLIC LICENSE.
36
37  *
38  * This library is free software; you can redistribute it and/or modify it
39  * under the terms of the MPL as stated above or under the terms of the GNU
40  * Library General Public License as published by the Free Software Foundation;
41  * either version 2 of the License, or any later version.
42  *
43  * This library is distributed in the hope that it will be useful, but WITHOUT
44  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
45  * FOR A PARTICULAR PURPOSE. See the GNU Library general Public License for more
46  * details.
47  *
48  * If you didn't download this code from the following link, you should check if
49  * you aren't using an obsolete version:
50  * http://www.lowagie.com/iText/
51  */

52
53 package com.lowagie.text.rtf;
54
55 import java.io.IOException JavaDoc;
56 import java.io.OutputStream JavaDoc;
57
58 import com.lowagie.text.Font;
59
60
61 /**
62  * This class implements a generic RtfField.
63  *
64  * This class is based on the RtfWriter-package from Mark Hall.
65  *
66  * ONLY FOR USE WITH THE RtfWriter NOT with the RtfWriter2.
67  *
68  * @author Dirk Weigenand (Dirk.Weigenand@smb-tec.com)
69  * @version $Id: GenericRtfField.java 2655 2007-03-15 19:26:36Z xlv $
70  * @since Mon Aug 19 14:50:39 2002
71  * @deprecated Please move to the RtfWriter2 and associated classes.
72  */

73 public class GenericRtfField extends AbstractRtfField {
74     /**
75      * Field Initialization Stuff.
76      */

77     protected String JavaDoc fieldInst;
78
79     /**
80      * Field Result Stuff.
81      */

82     protected String JavaDoc fieldResult;
83
84     /**
85      * public constructor, set the data that is to be written into the
86      * Field Initialization Stuff and Field Result parts of the
87      * RtfField.
88      *
89      * @param fieldInst data to be written into the Field
90      * Initialization Stuff part of the RtfField.
91      * @param fieldResult data to be written into the Field Result
92      * part of the RtfField.
93      */

94     public GenericRtfField(final String JavaDoc fieldInst, final String JavaDoc fieldResult) {
95         super("x", new Font());
96         this.fieldInst = fieldInst;
97         this.fieldResult = fieldResult;
98     }
99
100     /**
101      * public constructor, set the data that is to be written into the
102      * Field Initialization Stuff and Field Result parts of the
103      * RtfField.
104      *
105      * @param fieldInst data to be written into the Field
106      * Initialization Stuff part of the RtfField.
107      * @param fieldResult data to be written into the Field Result
108      * part of the RtfField.
109      * @param font
110      */

111     public GenericRtfField(final String JavaDoc fieldInst, final String JavaDoc fieldResult, Font font) {
112         super("x", font);
113         this.fieldInst = fieldInst;
114         this.fieldResult = fieldResult;
115     }
116
117     /**
118      * method for writing custom stuff to the Field Initialization
119      * Stuff part of an RtfField.
120      * @param out
121      * @throws IOException
122      */

123     public void writeRtfFieldInitializationStuff(OutputStream JavaDoc out) throws IOException JavaDoc {
124         out.write(fieldInst.trim().getBytes());
125         out.write(RtfWriter.delimiter);
126     }
127
128     /**
129      * method for writing custom stuff to the Field Result part of an
130      * RtfField.
131      * @param out
132      * @throws IOException
133      */

134     public void writeRtfFieldResultStuff(OutputStream JavaDoc out) throws IOException JavaDoc {
135         if (null != fieldResult) {
136             out.write(fieldResult.trim().getBytes());
137         }
138     }
139 }
140
Popular Tags