1 33 34 package net.percederberg.grammatica.code.csharp; 35 36 import java.io.File ; 37 import java.io.FileWriter ; 38 import java.io.IOException ; 39 import java.io.PrintWriter ; 40 41 import net.percederberg.grammatica.code.CodeElementContainer; 42 import net.percederberg.grammatica.code.CodeStyle; 43 44 50 public class CSharpFile extends CodeElementContainer { 51 52 55 private File file; 56 57 63 public CSharpFile(File basedir, String basename) { 64 this.file = new File (basedir, basename + ".cs"); 65 } 66 67 72 public String toString() { 73 return file.getName(); 74 } 75 76 84 public int category() { 85 return 0; 86 } 87 88 93 public void addComment(CSharpComment comment) { 94 addElement(comment); 95 } 96 97 102 public void addUsing(CSharpUsing u) { 103 addElement(u); 104 } 105 106 111 public void addNamespace(CSharpNamespace n) { 112 addElement(n); 113 } 114 115 120 public void addClass(CSharpClass c) { 121 addElement(c); 122 } 123 124 129 public void addEnumeration(CSharpEnumeration e) { 130 addElement(e); 131 } 132 133 141 public void writeCode(CodeStyle style) throws IOException { 142 PrintWriter out; 143 144 createFile(file); 145 out = new PrintWriter (new FileWriter (file)); 146 print(out, style, 0); 147 out.close(); 148 } 149 150 157 public void print(PrintWriter out, CodeStyle style, int indent) { 158 printContents(out, style, indent); 159 } 160 } 161 | Popular Tags |