1 28 29 package com.caucho.java.gen; 30 31 import com.caucho.bytecode.JClass; 32 import com.caucho.bytecode.JMethod; 33 import com.caucho.java.JavaWriter; 34 import com.caucho.util.L10N; 35 36 import java.io.IOException ; 37 38 41 public class MethodCallChain extends CallChain { 42 private static L10N L = new L10N(MethodCallChain.class); 43 44 private String _methodName; 45 private JClass []_parameterTypes; 46 private JClass _returnType; 47 48 51 public MethodCallChain() 52 { 53 } 54 55 58 public MethodCallChain(JMethod method) 59 { 60 _methodName = method.getName(); 61 _parameterTypes = method.getParameterTypes(); 62 _returnType = method.getReturnType(); 63 } 64 65 68 public MethodCallChain(String methodName, JClass []params, JClass returnType) 69 { 70 _methodName = methodName; 71 _parameterTypes = params; 72 _returnType = returnType; 73 } 74 75 78 public JClass []getParameterTypes() 79 { 80 return _parameterTypes; 81 } 82 83 86 public JClass getReturnType() 87 { 88 return _returnType; 89 } 90 91 99 public void generateCall(JavaWriter out, String retVar, 100 String var, String []args) 101 throws IOException 102 { 103 if (getReturnType().getName().equals("void")) { 104 } 105 else if (retVar != null) 106 out.print(retVar + " = "); 107 else 108 out.print("return "); 109 110 if (var != null) 111 out.print(var + "."); 112 else 113 out.print("super."); 114 115 out.print(_methodName + "("); 116 117 for (int i = 0; i < args.length; i++) { 118 if (i != 0) 119 out.print(", "); 120 121 out.print(args[i]); 122 } 123 124 out.println(");"); 125 } 126 } 127 | Popular Tags |