1 17 package org.apache.ws.jaxme.js; 18 19 import java.io.IOException ; 20 21 22 26 public class JavaConstructor extends AbstractJavaMethod { 27 28 JavaConstructor(String pName, JavaSource.Protection pProtection) { 29 super(pName, null, pProtection); 30 } 31 32 public String getName() { 33 String name = super.getName(); 34 int offset = name.lastIndexOf('$'); 35 if (offset > -1) { 36 return name.substring(offset+1); 37 } else { 38 return name; 39 } 40 } 41 42 protected void writeHeader(IndentationTarget pTarget) throws IOException { 43 if (pTarget.isInterface()) { 44 return; 45 } 46 pTarget.indent(0); 47 JavaSource.Protection protection = getProtection(); 48 if (protection != null && !protection.equals(JavaSource.DEFAULT_PROTECTION)) { 49 pTarget.write(getProtection().toString()); 50 pTarget.write(" "); 51 } 52 pTarget.write(getName()); 53 pTarget.write("("); 54 Parameter[] params = getParams(); 55 for (int i = 0; i < params.length; i++) { 56 if (i > 0) { 57 pTarget.write(", "); 58 } 59 Parameter p = params[i]; 60 pTarget.write(pTarget.asString(p.getType())); 61 pTarget.write(" "); 62 pTarget.write(p.getName()); 63 } 64 pTarget.write(")"); 65 JavaQName[] exceptions = getExceptions(); 66 for (int i = 0; i < exceptions.length; i++) { 67 if (i > 0) { 68 pTarget.write(", "); 69 } else { 70 pTarget.write(" throws "); 71 } 72 pTarget.write(pTarget.asString(exceptions[i])); 73 } 74 pTarget.write(" {"); 75 pTarget.write(); 76 } 77 } 78 | Popular Tags |