KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > catcode > odf > ElementPostProcess


1 /*
2     ElementPostProcess lets you specify post-processing characters for
3     OpenDocument elements.
4     Copyright (C) 2005 J. David Eisenberg
5
6     This library is free software; you can redistribute it and/or
7     modify it under the terms of the GNU Lesser General Public
8     License as published by the Free Software Foundation; either
9     version 2.1 of the License, or (at your option) any later version.
10
11     This library is distributed in the hope that it will be useful,
12     but WITHOUT ANY WARRANTY; without even the implied warranty of
13     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14     Lesser General Public License for more details.
15
16     You should have received a copy of the GNU Lesser General Public
17     License along with this library; if not, write to the Free Software
18     Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
19     
20     Author: J. David Eisenberg
21     Contact: catcode@catcode.com
22
23 */

24 package com.catcode.odf;
25
26 /**
27  * Describes what character the <code>OpenDocumentTextInputStream</code>
28  * class should emit when an element closes.
29  * For example, after closing a <code>&lt;text:p&gt;</code> or
30  * <code>&lt;text:h&gt;</code> element, emit a <code>'\n'</code>.
31  * If you want to specify an element with no post-processing,
32  * set its <code>postProcess</code> field to <code>'\0'</code>
33  */

34 public class ElementPostProcess implements Comparable JavaDoc
35 {
36     protected String JavaDoc name;
37     protected char postProcess;
38     
39     /**
40      * Constructs a placeholder element descriptor.
41      *
42      */

43     public ElementPostProcess( )
44     {
45         this( "", '\0' );
46     }
47     
48     /**
49      * Constructs an element descriptor with the given name and
50      * <code>'\0'</code> post-processing character.
51      *
52      * @param name the element name, without a namespace prefix.
53      */

54     public ElementPostProcess( String JavaDoc name )
55     {
56         this( name, '\0');
57     }
58     
59     /**
60      * Constructs an element descriptor with the given name and
61      * post-processing character.
62      *
63      * @param name the element name, without a namespace prefix.
64      * @param postProcess the character to emit after the element closes.
65      */

66     public ElementPostProcess( String JavaDoc name, char postProcess )
67     {
68         this.name = name;
69         this.postProcess = postProcess;
70     }
71     
72     /**
73      * Returns the element's post-processing character.
74      * @return the post-processing character.
75      */

76     public char getPostProcess( )
77     {
78         return postProcess;
79     }
80     
81     /**
82      * Sets element post-processing character to the given value.
83      * @param postProcess the post-processing character for this element.
84      */

85     public void setPostProcess( char postProcess )
86     {
87         this.postProcess = postProcess;
88     }
89
90     /**
91      * Returns the element name.
92      * @return The element name.
93      */

94     public String JavaDoc getName( )
95     {
96         return name;
97     }
98     
99     /**
100      * Sets the element name to the given value.
101      * @param name the desired name.
102      */

103     public void setName( String JavaDoc name )
104     {
105         this.name = name;
106     }
107     
108     /**
109      * See <code>Comparator</code> interface for details.
110      */

111     public int compareTo(Object JavaDoc o)
112     {
113         return this.name.compareTo( ((ElementPostProcess) o).name );
114     }
115 }
116
117
Popular Tags