1 /* -------------------------------------------------------------------
2 * Java source file for the class IndentedStream
3 *
4 * Copyright (c), 2003, Masahiro Takatsuka.
5 * All Rights Researved.
6 *
7 * Original Author: Masahiro Takatsuka (masa@jbeans.net)
8 * $Author: takatsukam $
9 *
10 * $Date: 2003/07/25 04:51:45 $
11 *
12 * $Id: IndentedStream.java,v 1.1.1.1 2003/07/25 04:51:45 takatsukam Exp $
13 *
14 * Reference: Document no:
15 * ___ ___
16 *
17 * To Do:
18 * ___
19 *
20 ------------------------------------------------------------------- */
21
22 /* --------------------------- Package ---------------------------- */
23 package net.jbeans.io;
24
25 /* ------------------ Import classes (packages) ------------------- *//package-summary/html">color="#329900"> ------------------ Import classes (packages) ------------------- *//package-summary.html">color="#329900">/* ------------------ Import classes (packages) ------------------- *//package-summary.html">color="#329900"> ------------------ Import classes (packages) ------------------- */
26 import java.io.*;
27
28 /*====================================================================
29 Implementation of class IndentedStream
30 ====================================================================*/
31 /***
32 * This is a utility class for the generation of Source Files.
33 *
34 * @version $Revision: 1.1.1.1 $
35 * @author Masahiro Takatsuka (masa@jbeans.net)
36 */
37
38 public final class IndentedStream {
39 // Private fields for indented streams...
40 private int indentLevel; // indentation level
41 private String indentSpace; // space
42 private PrintWriter currentStream; // for generating code
43
44 public IndentedStream(PrintWriter s, String space) {
45 this.currentStream = s;
46 this.indentSpace = space;
47 }
48
49 public IndentedStream(PrintWriter s) {
50 this(s, " ");
51 }
52
53 public final void close() {
54 this.currentStream.close();
55 }
56
57 public final void out() { // o()
58 this.indentLevel--;
59 }
60
61 public final void in() { // i()
62 this.indentLevel++;
63 }
64
65 public final void in_println(String s) { // ip(s)
66 in();
67 indent_println(s);
68 }
69
70 public final void in_println() { // ip()
71 in();
72 println();
73 }
74
75 public final void out_println(String s) { // op(s)
76 out();
77 indent_println(s);
78 }
79
80 public final void out_println() { // op()
81 out();
82 println();
83 }
84
85 public final void println() { // pp()
86 // _currentStream.println();
87 this.currentStream.print("\n");
88 }
89
90 public final void indent_println(String s) { // pp(s)
91 for (int i = 0; i < this.indentLevel; i++) {
92 this.currentStream.print(this.indentSpace);
93 }
94 // _currentStream.println(s);
95 this.currentStream.print(s);
96 println();
97 }
98
99 public final void indent_print(String s) { // pp0(s)
100 for (int i = 0; i < this.indentLevel; i++) {
101 this.currentStream.print(this.indentSpace);
102 }
103 this.currentStream.print(s);
104 }
105
106 public final void println(String s) { // pn(s)
107 // _currentStream.println(s);
108 this.currentStream.print(s);
109 println();
110 }
111
112 public final void print(String s) { // pn0(s)
113 this.currentStream.print(s);
114 }
115 }
This page was automatically generated by Maven