KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > enhydra > xml > Indent


1 /*
2  * @(#)HashMapNode.java 1.36 02/03/21
3  *
4  * Copyright 2002 Sun Microsystems, Inc. All rights reserved.
5  * SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
6  */

7 package org.enhydra.xml;
8
9
10 /**
11  * @author Tweety
12  *
13  * A class that describes format of the output xml file.
14  *
15  * @version 1.0
16  */

17 public class Indent {
18
19     /**
20      * Default tab value.
21      */

22     public static String JavaDoc DEFAULT_TAB = " ";
23         
24     /**
25      * Indent size.
26      */

27     private int indent;
28     
29     /**
30      * Tab string, the value that is going to be treated as tab.
31      */

32     private String JavaDoc tab;
33     
34     
35     
36     /**
37      * Constructs new <code>Indent</code> with the given size of indentation and the tab string.
38      *
39      * @param ind size of indentation.
40      * @param tab tab string.
41      */

42     public Indent(int ind, String JavaDoc tab) {
43         this.indent = ind;
44         this.tab = tab;
45     }
46     
47     
48     /**
49      * toString method
50      */

51     public String JavaDoc toString() {
52         StringBuffer JavaDoc buff = new StringBuffer JavaDoc();
53         for (int i = 0; i < indent; i++)
54             buff.append(tab);
55         return buff.toString();
56     }
57
58
59     /**
60      * Increments the indentation size.
61      */

62     public void increment() {
63         indent++;
64     }
65
66
67     /**
68      * Decrements the indentation size.
69      */

70     public void decrement() {
71         indent--;
72     }
73
74
75     /**
76      * Returns the tab string.
77      */

78     public String JavaDoc getTab() {
79         return tab;
80     }
81
82     /**
83      * Sets the tab string.
84      */

85     public void setTab(String JavaDoc tab) {
86         this.tab = tab;
87     }
88     
89 }
90
Popular Tags