1
/*___INFO__MARK_BEGIN__*/
2
/*************************************************************************
4
* The Contents of this file are made available subject to the terms of
5
* the Sun Industry Standards Source License Version 1.2
7
* Sun Microsystems Inc., March, 2001
10
* Sun Industry Standards Source License Version 1.2
11
* =================================================
12
* The contents of this file are subject to the Sun Industry Standards
13
* Source License Version 1.2 (the "License"); You may not use this file
14
* except in compliance with the License. You may obtain a copy of the
15
* License at http://gridengine.sunsource.net/Gridengine_SISSL_license.html
17
* Software provided under this License is provided on an "AS IS" basis,
18
* WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
19
* WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
20
* MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
21
* See the License for the specific provisions governing your rights and
22
* obligations concerning the Software.
24
* The Initial Developer of the Original Code is: Sun Microsystems, Inc.
26
* Copyright: 2001 by Sun Microsystems, Inc.
28
* All Rights Reserved.
30
************************************************************************/
31
/*___INFO__MARK_END__*/
32
package com.sun.grid.jgdi.configuration.xml;
35
import java.io.FileNotFoundException;
36
import java.io.FileWriter;
37
import java.io.IOException;
38
import java.io.OutputStream;
39
import java.io.PrintWriter;
40
import java.io.Writer;
43
* This class implements a PrintWriter with
46
public class IndentedPrintWriter extends PrintWriter {
48
private StringBuilder indent = new StringBuilder();
50
/** this flag indicates that a indent should
54
private boolean addIndent = false;
56
/** size of an indent step: */
57
private int indentSize = 3;
60
* Create a new IndentedPrintWriter on an OutputStream
61
* @param out the output stream
63
public IndentedPrintWriter(OutputStream out) {
67
/** Creates a new IndentedPrintWriter on a Writer
68
* @param writer the writer
70
public IndentedPrintWriter(Writer writer) {
74
/** Creates a new IndentedPrintWriter on a File
75
* @param file the file
77
public IndentedPrintWriter(File file) throws IOException {
78
super(new FileWriter(file));
84
public void indent() {
85
for(int i = 0; i < indentSize; i++) {
93
public void deindent() {
94
int newLen = Math.max(0,indent.length() - indentSize);
95
indent.setLength(newLen);
99
public void println(String x) {
105
public void print(String s) {
113
public void println(Object x) {
119
public void print(Object obj) {
127
public void println(int x) {
133
public void print(int i) {
141
public void print(boolean b) {
149
public void println(boolean x) {
155
public void println(long x) {
161
public void print(long l) {
169
public void println(double x) {
175
public void println(char[] x) {
181
public void print(char[] s) {
189
public void print(double d) {
197
public void println(char x) {
203
public void print(char c) {
212
public void println(float x) {
218
public void print(float f) {
227
public void println() {
232
public int getIndentSize() {
236
public void setIndentSize(int indentSize) {
237
this.indentSize = indentSize;