source: trunk/src/org/expeditee/io/JAVAWriter.java@ 376

Last change on this file since 376 was 306, checked in by ra33, 16 years ago

Added some HELP actions
More mail stuff... and networking stuff
Can now save frames and send messages to peers
Also version control prevent versions from being lost

File size: 1.5 KB
Line 
1package org.expeditee.io;
2
3import java.io.IOException;
4import java.io.Writer;
5import java.util.List;
6
7import org.expeditee.gui.Frame;
8import org.expeditee.items.Item;
9import org.expeditee.items.Picture;
10import org.expeditee.items.Text;
11
12public class JAVAWriter extends DefaultTreeWriter {
13
14 private int _indent = 0;
15
16 private static final String INDENT = " ";
17
18 @Override
19 protected void initialise(Frame start, Writer writer) throws IOException {
20 _format = ".java";
21 super.initialise(start, writer);
22
23 // write the package and import statements here!!
24 }
25
26 @Override
27 protected String finaliseTree() throws IOException {
28 _writer.write("}" + ItemWriter.NEW_LINE);
29 return super.finaliseTree();
30 }
31
32 @Override
33 protected void writeStartLink(Item linker) throws IOException {
34 indent();
35 _writer.write("{" + ItemWriter.NEW_LINE);
36 _indent++;
37 }
38
39 @Override
40 protected void writeEndLink(Item linker) throws IOException {
41 _indent--;
42 indent();
43 _writer.write("}" + ItemWriter.NEW_LINE);
44 }
45
46 @Override
47 protected void writeTitle(Text toWrite, List<Item> items)
48 throws IOException {
49 String heading = toWrite.getText();
50
51 _writer.write("public class " + heading + "{" + ItemWriter.NEW_LINE);
52 }
53
54 @Override
55 protected void writeText(Text text) throws IOException {
56 indent();
57 _writer.write(text.getText().replace('\n', ' '));
58 _writer.write(";" + ItemWriter.NEW_LINE);
59 }
60
61 private void indent() throws IOException {
62 for (int i = 0; i < _indent; i++)
63 _writer.write(INDENT);
64 }
65
66 @Override
67 protected void writePicture(Picture pic) throws IOException {
68 }
69}
Note: See TracBrowser for help on using the repository browser.