1 package org.freehep.graphicsio.pdf;
2
3 import java.io.IOException;
4 import java.io.OutputStream;
5
6 import org.freehep.util.io.CountedByteOutputStream;
7
8
9
10
11
12
13
14
15
16
17 public class PDFByteWriter extends CountedByteOutputStream implements
18 PDFConstants {
19
20 private int indent;
21
22 private String indentString = " ";
23
24 PDFByteWriter(OutputStream out) {
25 super(out);
26 indent = 0;
27 }
28
29 public void write(String s) throws IOException {
30 write(s.getBytes("ISO-8859-1"));
31 }
32
33 public void close() throws IOException {
34 out.close();
35 super.close();
36 }
37
38 public void print(String string) throws IOException {
39 for (int i = 0; i < indent; i++) {
40 write(indentString);
41 }
42 printPlain(string);
43 }
44
45 public void printPlain(String string) throws IOException {
46 write(string);
47 }
48
49 public void println() throws IOException {
50 write(EOL);
51 }
52
53 public void indent() {
54 indent++;
55 }
56
57 public void outdent() {
58 if (indent > 0) {
59 indent--;
60 }
61 }
62
63
64 public void println(String string) throws IOException {
65 print(string);
66 println();
67 }
68
69 public void print(int number) throws IOException {
70 print(Integer.toString(number));
71 }
72
73 public void println(int number) throws IOException {
74 print(number);
75 println();
76 }
77
78 public void printPlain(int number) throws IOException {
79 printPlain(Integer.toString(number));
80 }
81
82 public void print(double number) throws IOException {
83 print(Double.toString(number));
84 }
85
86 public void println(double number) throws IOException {
87 print(number);
88 println();
89 }
90
91 public void printPlain(double number) throws IOException {
92 printPlain(Double.toString(number));
93 }
94
95 public void print(Object object) throws IOException {
96 print(object.toString());
97 }
98
99 public void println(Object object) throws IOException {
100 print(object);
101 println();
102 }
103
104 public void printPlain(Object object) throws IOException {
105 printPlain(object.toString());
106 }
107
108 }