001: /*
002: * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
003: *
004: * Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved.
005: *
006: * The contents of this file are subject to the terms of either the GNU
007: * General Public License Version 2 only ("GPL") or the Common
008: * Development and Distribution License("CDDL") (collectively, the
009: * "License"). You may not use this file except in compliance with the
010: * License. You can obtain a copy of the License at
011: * http://www.netbeans.org/cddl-gplv2.html
012: * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
013: * specific language governing permissions and limitations under the
014: * License. When distributing the software, include this License Header
015: * Notice in each file and include the License file at
016: * nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this
017: * particular file as subject to the "Classpath" exception as provided
018: * by Sun in the GPL Version 2 section of the License file that
019: * accompanied this code. If applicable, add the following below the
020: * License Header, with the fields enclosed by brackets [] replaced by
021: * your own identifying information:
022: * "Portions Copyrighted [year] [name of copyright owner]"
023: *
024: * Contributor(s):
025: *
026: * The Original Software is NetBeans. The Initial Developer of the Original
027: * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun
028: * Microsystems, Inc. All Rights Reserved.
029: *
030: * If you wish your version of this file to be governed by only the CDDL
031: * or only the GPL Version 2, indicate your decision by adding
032: * "[Contributor] elects to include this software in this distribution
033: * under the [CDDL or GPL Version 2] license." If you do not indicate a
034: * single choice of license, a recipient has the option to distribute
035: * your version of this file under either the CDDL, the GPL Version 2 or
036: * to extend the choice of license to its licensees as provided above.
037: * However, if you add GPL Version 2 code and therefore, elected the GPL
038: * Version 2 license, then the option applies only if the new code is
039: * made subject to such option by the copyright holder.
040: */
041:
042: package org.netbeans.modules.websvc.registry.jaxrpc;
043:
044: import com.sun.xml.rpc.processor.model.java.JavaException;
045: import com.sun.xml.rpc.processor.model.java.JavaMethod;
046: import com.sun.xml.rpc.processor.model.java.JavaParameter;
047: import java.io.OutputStreamWriter;
048: import java.io.PrintWriter;
049: import java.io.Writer;
050: import java.util.HashSet;
051: import java.util.Iterator;
052: import java.util.Set;
053:
054: /**
055: * A simple writer to write the Bean Info Class.
056: * @author Winston Prakash
057: */
058: public class WrapperClientBeanInfoWriter extends java.io.PrintWriter {
059:
060: private String className;
061: private String super ClassName;
062: private String packageName;
063:
064: private Set constructorStatements = new HashSet();
065:
066: public static String WEBSERVICE_ICON_FILENAME = "webservice.png";
067:
068: int indent = 0;
069:
070: /** Creates a new instance of JavaWriter */
071: public WrapperClientBeanInfoWriter(Writer writer) {
072: super (writer);
073: setSuperClass("SimpleBeanInfo");
074: }
075:
076: /** Set package name */
077: public void setPackage(String pkgName) {
078: packageName = pkgName;
079: }
080:
081: /** Set the name of the class */
082: public void setName(String name) {
083: className = name;
084: }
085:
086: /** Set the name of the super class this class would extends */
087: public void setSuperClass(String super Class) {
088: super ClassName = super Class;
089: }
090:
091: public void writeBeanInfo() {
092: // Write the Package name
093: println("package " + packageName + ";");
094: println();
095:
096: println("import java.awt.Image;");
097: println("import java.beans.BeanDescriptor;");
098: println("import java.beans.PropertyDescriptor;");
099: println("import java.beans.SimpleBeanInfo;");
100: println();
101:
102: // Write the class signature
103: print("public class " + className + "BeanInfo");
104: if (super ClassName != null)
105: print(" extends " + super ClassName + " ");
106: println(" {");
107: println();
108:
109: println(" private Class beanClass = " + className + ".class;");
110: println(" private String iconFileName = \""
111: + this .WEBSERVICE_ICON_FILENAME + "\";");
112: println(" private BeanDescriptor beanDescriptor = null;");
113: println(" private PropertyDescriptor[] propDescriptors = null;");
114:
115: println();
116:
117: println(" public BeanDescriptor getBeanDescriptor() {");
118: println(" if (beanDescriptor == null) {");
119: println(" beanDescriptor = new BeanDescriptor(beanClass);");
120: println(" beanDescriptor.setValue(\"trayComponent\", Boolean.TRUE);");
121: println(" }");
122: println(" return beanDescriptor;");
123: println(" }");
124:
125: println();
126:
127: println(" public PropertyDescriptor[] getPropertyDescriptors() {");
128: println(" if (propDescriptors == null) {");
129: println(" propDescriptors = new PropertyDescriptor[] {");
130: println(" ");
131: println(" };");
132: println(" }");
133: println(" return propDescriptors;");
134: println(" }");
135:
136: println();
137:
138: println(" public Image getIcon(int iconKind) {");
139: println(" return loadImage(iconFileName);");
140: println(" }");
141:
142: println("}");
143: }
144:
145: /**
146: * @param args the command line arguments
147: */
148: public static void main(String[] args) {
149: try {
150: WrapperClientBeanInfoWriter beanWriter = new WrapperClientBeanInfoWriter(
151: new OutputStreamWriter(System.out));
152: beanWriter.setPackage("untitled");
153: beanWriter.setName("WebserviceProxyClient");
154: beanWriter.writeBeanInfo();
155: beanWriter.flush();
156: beanWriter.close();
157: } catch (Exception exc) {
158: exc.printStackTrace();
159: }
160: }
161:
162: }
|