1 19 20 package org.netbeans.modules.websvc.registry.jaxrpc; 21 22 import com.sun.xml.rpc.processor.model.java.JavaException; 23 import com.sun.xml.rpc.processor.model.java.JavaMethod; 24 import com.sun.xml.rpc.processor.model.java.JavaParameter; 25 import java.io.OutputStreamWriter ; 26 import java.io.PrintWriter ; 27 import java.io.Writer ; 28 import java.util.HashSet ; 29 import java.util.Iterator ; 30 import java.util.Set ; 31 32 36 public class WrapperClientBeanInfoWriter extends java.io.PrintWriter { 37 38 private String className; 39 private String superClassName; 40 private String packageName; 41 42 private Set constructorStatements = new HashSet (); 43 44 public static String WEBSERVICE_ICON_FILENAME = "webservice.png"; 45 46 int indent = 0; 47 48 49 public WrapperClientBeanInfoWriter(Writer writer){ 50 super(writer); 51 setSuperClass("SimpleBeanInfo"); 52 } 53 54 55 public void setPackage(String pkgName){ 56 packageName = pkgName; 57 } 58 59 60 public void setName(String name){ 61 className = name; 62 } 63 64 65 public void setSuperClass(String superClass){ 66 superClassName = superClass; 67 } 68 69 public void writeBeanInfo(){ 70 println("package " + packageName + ";"); 72 println(); 73 74 println("import java.awt.Image;"); 75 println("import java.beans.BeanDescriptor;"); 76 println("import java.beans.PropertyDescriptor;"); 77 println("import java.beans.SimpleBeanInfo;"); 78 println(); 79 80 print("public class " + className + "BeanInfo"); 82 if(superClassName != null) print(" extends " + superClassName + " "); 83 println(" {"); 84 println(); 85 86 87 println(" private Class beanClass = " + className + ".class;"); 88 println(" private String iconFileName = \"" + this.WEBSERVICE_ICON_FILENAME + "\";"); 89 println(" private BeanDescriptor beanDescriptor = null;"); 90 println(" private PropertyDescriptor[] propDescriptors = null;"); 91 92 println(); 93 94 println(" public BeanDescriptor getBeanDescriptor() {"); 95 println(" if (beanDescriptor == null) {"); 96 println(" beanDescriptor = new BeanDescriptor(beanClass);"); 97 println(" beanDescriptor.setValue(\"trayComponent\", Boolean.TRUE);"); 98 println(" }"); 99 println(" return beanDescriptor;"); 100 println(" }"); 101 102 println(); 103 104 println(" public PropertyDescriptor[] getPropertyDescriptors() {"); 105 println(" if (propDescriptors == null) {"); 106 println(" propDescriptors = new PropertyDescriptor[] {"); 107 println(" "); 108 println(" };"); 109 println(" }"); 110 println(" return propDescriptors;"); 111 println(" }"); 112 113 println(); 114 115 println(" public Image getIcon(int iconKind) {"); 116 println(" return loadImage(iconFileName);"); 117 println(" }"); 118 119 println("}"); 120 } 121 122 125 public static void main(String [] args) { 126 try{ 127 WrapperClientBeanInfoWriter beanWriter = new WrapperClientBeanInfoWriter(new OutputStreamWriter (System.out)); 128 beanWriter.setPackage("untitled"); 129 beanWriter.setName("WebserviceProxyClient"); 130 beanWriter.writeBeanInfo(); 131 beanWriter.flush(); 132 beanWriter.close(); 133 }catch(Exception exc){ 134 exc.printStackTrace(); 135 } 136 } 137 138 } 139 | Popular Tags |