1 34 35 package net.percederberg.grammatica.code.visualbasic; 36 37 import java.io.PrintWriter ; 38 39 import net.percederberg.grammatica.code.CodeElement; 40 import net.percederberg.grammatica.code.CodeElementContainer; 41 import net.percederberg.grammatica.code.CodeStyle; 42 43 52 public abstract class VisualBasicType extends CodeElementContainer { 53 54 57 protected int modifiers; 58 59 62 protected String name; 63 64 67 protected String [] extendTypes; 68 69 72 protected VisualBasicComment comment = null; 73 74 84 protected VisualBasicType(int modifiers, String name, String extendType) { 85 this.modifiers = modifiers; 86 this.name = name; 87 if (extendType == null || extendType.equals("")) { 88 this.extendTypes = new String [0]; 89 } else { 90 this.extendTypes = new String [1]; 91 this.extendTypes[0] = extendType; 92 } 93 } 94 95 103 protected VisualBasicType(int modifiers, 104 String name, 105 String [] extendTypes) { 106 107 this.modifiers = modifiers; 108 this.name = name; 109 this.extendTypes = extendTypes; 110 } 111 112 117 public String toString() { 118 return name; 119 } 120 121 127 public void addComment(VisualBasicComment comment) { 128 this.comment = comment; 129 } 130 131 139 protected void print(PrintWriter out, 140 CodeStyle style, 141 int indent, 142 String type) { 143 144 StringBuffer buf = new StringBuffer (); 145 String indentStr = style.getIndent(indent); 146 147 if (comment != null) { 149 comment.print(out, style, indent); 150 } 151 152 buf.append(indentStr); 154 buf.append(VisualBasicModifier.createModifierDecl(modifiers)); 155 buf.append(type); 156 buf.append(" "); 157 buf.append(name); 158 buf.append("\n"); 159 for (int i = 0; i < extendTypes.length; i++) { 160 buf.append(style.getIndent(indent+1)); 161 buf.append("Inherits "); 162 buf.append(extendTypes[i]); 163 buf.append("\n"); 164 } 165 out.print(buf.toString()); 166 167 printContents(out, style, indent + 1); 169 170 out.println(indentStr + "End " + type); 172 } 173 174 182 protected void printSeparator(PrintWriter out, 183 CodeStyle style, 184 CodeElement prev, 185 CodeElement next) { 186 187 if (prev == null || next == null) { 188 } else { 190 out.println(); 191 } 192 } 193 } 194 | Popular Tags |