01: /*
02: Copyright (C) 2003 Together
03:
04: This library is free software; you can redistribute it and/or
05: modify it under the terms of the GNU Lesser General Public
06: License as published by the Free Software Foundation; either
07: version 2.1 of the License, or (at your option) any later version.
08:
09: This library is distributed in the hope that it will be useful,
10: but WITHOUT ANY WARRANTY; without even the implied warranty of
11: MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12: Lesser General Public License for more details.
13:
14: You should have received a copy of the GNU Lesser General Public
15: License along with this library; if not, write to the Free Software
16: Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17: */
18:
19: package org.enhydra.xml;
20:
21: /**
22: * @author Tweety
23: *
24: * A class that describes format of the output xml file.
25: *
26: * @version 1.0
27: */
28: public class Indent {
29:
30: /**
31: * Default tab value.
32: */
33: public static String DEFAULT_TAB = " ";
34:
35: /**
36: * Indent size.
37: */
38: private int indent;
39:
40: /**
41: * Tab string, the value that is going to be treated as tab.
42: */
43: private String tab;
44:
45: /**
46: * Constructs new <code>Indent</code> with the given size of indentation and the tab string.
47: *
48: * @param ind size of indentation.
49: * @param tab tab string.
50: */
51: public Indent(int ind, String tab) {
52: this .indent = ind;
53: this .tab = tab;
54: }
55:
56: /**
57: * toString method
58: * @return string
59: */
60: public String toString() {
61: StringBuffer buff = new StringBuffer();
62: for (int i = 0; i < indent; i++)
63: buff.append(tab);
64: return buff.toString();
65: }
66:
67: /**
68: * Increments the indentation size.
69: */
70: public void increment() {
71: indent++;
72: }
73:
74: /**
75: * Decrements the indentation size.
76: */
77: public void decrement() {
78: indent--;
79: }
80:
81: /**
82: * Returns the tab string.
83: * @return tab
84: */
85: public String getTab() {
86: return tab;
87: }
88:
89: /**
90: * Sets the tab string.
91: * @param tab is tab
92: */
93: public void setTab(String tab) {
94: this.tab = tab;
95: }
96:
97: }
|