1 55 package org.jboss.axis.wsdl.toJava; 56 57 import org.jboss.axis.utils.Messages; 58 59 import java.io.File ; 60 import java.io.IOException ; 61 import java.io.PrintWriter ; 62 63 146 public abstract class JavaClassWriter extends JavaWriter 147 { 148 protected Namespaces namespaces; 149 protected String className; 150 protected String packageName; 151 152 160 protected JavaClassWriter(Emitter emitter, 161 String fullClassName, 162 String type) 163 { 164 super(emitter, type); 165 this.namespaces = emitter.getNamespaces(); 166 this.packageName = Utils.getJavaPackageName(fullClassName); 167 this.className = Utils.getJavaLocalName(fullClassName); 168 } 170 174 protected String getFileName() 175 { 176 return namespaces.toDir(packageName) + className + ".java"; 177 } 179 186 protected void registerFile(String file) 187 { 188 String fqClass = getPackage() + '.' + getClassName(); 189 emitter.getGeneratedFileInfo().add(file, fqClass, type); 190 } 192 196 protected void writeFileHeader(PrintWriter pw) throws IOException 197 { 198 writeHeaderComments(pw); 199 writePackage(pw); 200 201 pw.println(getClassModifiers() + getClassText() + getClassName() + ' ' + getExtendsText() + getImplementsText() + "{"); 203 } 205 208 protected void writeHeaderComments(PrintWriter pw) throws IOException 209 { 210 String localFile = getFileName(); 211 int lastSepChar = localFile.lastIndexOf(File.separatorChar); 212 if (lastSepChar >= 0) 213 { 214 localFile = localFile.substring(lastSepChar + 1); 215 } 216 pw.println("/**"); 217 pw.println(" * " + localFile); 218 pw.println(" *"); 219 pw.println(" * " + Messages.getMessage("wsdlGenLine00")); 220 pw.println(" * " + Messages.getMessage("wsdlGenLine01")); 221 pw.println(" */"); 222 pw.println(); 223 } 225 228 protected void writePackage(PrintWriter pw) throws IOException 229 { 230 if (getPackage() != null) 231 { 232 pw.println("package " + getPackage() + ";"); 233 pw.println(); 234 } 235 236 } 238 242 protected String getClassModifiers() 243 { 244 return "public "; 245 } 247 251 protected String getClassText() 252 { 253 return "class "; 254 } 256 263 protected String getExtendsText() 264 { 265 return ""; 266 } 268 275 protected String getImplementsText() 276 { 277 return ""; 278 } 280 283 protected String getPackage() 284 { 285 return packageName; 286 } 288 291 protected String getClassName() 292 { 293 return className; 294 } 296 299 protected void writeFileFooter(PrintWriter pw) throws IOException 300 { 301 super.writeFileFooter(pw); 302 pw.println('}'); 303 } 305 } | Popular Tags |