1 17 package org.apache.ws.jaxme.js; 18 19 import java.io.IOException ; 20 21 22 26 public class JavaMethod extends AbstractJavaMethod { 27 private boolean isSynchronized; 28 29 32 JavaMethod(String pName, JavaQName pType, JavaSource.Protection pProtection) { 33 super(pName, pType, pProtection); 34 } 35 36 38 public void setSynchronized(boolean pSynchronized) { 39 isSynchronized = pSynchronized; 40 } 41 42 44 public boolean isSynchronized() { 45 return isSynchronized; 46 } 47 48 50 protected void writeHeader(IndentationTarget pTarget) throws IOException { 51 pTarget.indent(0); 52 JavaSource.Protection protection = getProtection(); 53 if (protection != null && !protection.equals(JavaSource.DEFAULT_PROTECTION)) { 54 pTarget.write(getProtection().toString()); 55 pTarget.write(" "); 56 } 57 if (isStatic()) { 58 pTarget.write("static "); 59 } 60 if (isFinal()) { 61 pTarget.write("final "); 62 } 63 if (isAbstract()) { 64 pTarget.write("abstract "); 65 } 66 if (isSynchronized() && !pTarget.isInterface()) { 67 pTarget.write("synchronized "); 68 } 69 pTarget.write(pTarget.asString(getType())); 70 pTarget.write(" "); 71 pTarget.write(getName()); 72 pTarget.write("("); 73 Parameter[] params = getParams(); 74 for (int i = 0; i < params.length; i++) { 75 if (i > 0) { 76 pTarget.write(", "); 77 } 78 Parameter p = params[i]; 79 pTarget.write(pTarget.asString(p.getType()) ); 80 pTarget.write(" "); 81 pTarget.write(p.getName()); 82 } 83 pTarget.write(")"); 84 JavaQName[] exceptions = getExceptions(); 85 for (int i = 0; i < exceptions.length; i++) { 86 if (i > 0) { 87 pTarget.write(", "); 88 } else { 89 pTarget.write(" throws "); 90 } 91 pTarget.write(pTarget.asString(exceptions[i])); 92 } 93 if (pTarget.isInterface() || isAbstract()) { 94 pTarget.write(";"); 95 } else { 96 pTarget.write(" {"); 97 } 98 pTarget.write(); 99 } 100 101 104 public String getLoggingSignature() { 105 StringBuffer result = new StringBuffer (getName()); 106 Parameter[] params = getParams(); 107 if (params.length > 0) { 108 result.append('('); 109 for (int i = 0; i < params.length; i++) { 110 if (i > 0) { result.append(','); } 111 result.append(params[i].getType().getClassName()); 112 } 113 result.append(')'); 114 } 115 return result.toString(); 116 } 117 118 120 public boolean isVoid() { 121 return getType().equals(JavaQNameImpl.VOID); 122 } 123 } 124 | Popular Tags |