1 18 19 package org.objectweb.jac.ide; 20 21 import java.io.IOException ; 22 import java.io.Writer ; 23 24 28 public class AccGenState { 29 30 boolean classOpened = false; 31 32 boolean fieldOpened = false; 33 Writer output; 34 35 public AccGenState(Writer output) { 36 this.output = output; 37 } 38 39 42 void openClass(Class cl) 43 throws IOException 44 { 45 if (!classOpened) { 46 output.write("class "+cl.getGenerationFullName()+" {\n"); 47 classOpened = true; 48 } 49 } 50 53 void closeClass() 54 throws IOException 55 { 56 if (classOpened) { 57 classOpened = false; 58 write("}\n"); 59 } 60 } 61 62 65 void openField(Class cl, Field field) 66 throws IOException 67 { 68 openClass(cl); 69 if (!fieldOpened) { 70 write("attribute "+field.getGenerationName()+" {\n"); 71 fieldOpened = true; 72 } 73 } 74 75 78 void openRole(Class cl, RelationRole role) 79 throws IOException 80 { 81 openClass(cl); 82 if (!fieldOpened) { 83 write("attribute "+role.getGenerationName()+" {\n"); 84 fieldOpened = true; 85 } 86 } 87 88 91 void openMethod(Class cl, Method method) 92 throws IOException 93 { 94 openClass(cl); 95 if (!fieldOpened) { 96 write("method \""+method.getUniqueName()+"\" {\n"); 97 fieldOpened = true; 98 } 99 } 100 103 void closeMember() 104 throws IOException 105 { 106 if (fieldOpened) { 107 fieldOpened = false; 108 write("}\n"); 109 } 110 } 111 112 116 void write(String text) throws IOException { 117 if (classOpened) 118 output.write(" "); 119 if (fieldOpened) 120 output.write(" "); 121 output.write(text); 122 } 123 } 124 | Popular Tags |