1 34 35 package net.percederberg.grammatica.code.visualbasic; 36 37 import java.io.File ; 38 import java.io.FileWriter ; 39 import java.io.IOException ; 40 import java.io.PrintWriter ; 41 42 import net.percederberg.grammatica.code.CodeElementContainer; 43 import net.percederberg.grammatica.code.CodeStyle; 44 45 53 public class VisualBasicFile extends CodeElementContainer { 54 55 58 private File file; 59 60 66 public VisualBasicFile(File basedir, String basename) { 67 this.file = new File (basedir, basename + ".vb"); 68 } 69 70 75 public String toString() { 76 return file.getName(); 77 } 78 79 87 public int category() { 88 return 0; 89 } 90 91 96 public void addComment(VisualBasicComment comment) { 97 addElement(comment); 98 } 99 100 105 public void addImports(VisualBasicImports imports) { 106 addElement(imports); 107 } 108 109 114 public void addNamespace(VisualBasicNamespace namespace) { 115 addElement(namespace); 116 } 117 118 123 public void addClass(VisualBasicClass c) { 124 addElement(c); 125 } 126 127 132 public void addEnumeration(VisualBasicEnumeration e) { 133 addElement(e); 134 } 135 136 144 public void writeCode(CodeStyle style) throws IOException { 145 PrintWriter out; 146 147 createFile(file); 148 out = new PrintWriter (new FileWriter (file)); 149 print(out, style, 0); 150 out.close(); 151 } 152 153 160 public void print(PrintWriter out, CodeStyle style, int indent) { 161 printContents(out, style, indent); 162 } 163 } 164 | Popular Tags |