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: * Portions Copyrighted 2007 Sun Microsystems, Inc.
027: */
028: package org.netbeans.modules.visualweb.websvcmgr.codegen;
029:
030: import com.sun.tools.ws.processor.model.java.JavaMethod;
031: import com.sun.tools.ws.processor.model.java.JavaParameter;
032: import com.sun.tools.ws.processor.model.java.JavaType;
033: import java.util.ArrayList;
034: import java.util.Iterator;
035: import java.util.List;
036:
037: /**
038: *
039: * @author quynguyen
040: */
041: public class DataProviderModelMethod implements DataProviderMethod {
042: private String methodName;
043: private String returnType;
044: private List<DataProviderParameter> parameters;
045: private List<String> exceptions;
046: private JavaMethod javaMethod;
047:
048: public DataProviderModelMethod(JavaMethod method) {
049: this .methodName = method.getName();
050: this .returnType = toString(method.getReturnType());
051: this .javaMethod = method;
052:
053: List<JavaParameter> params = method.getParametersList();
054: parameters = new ArrayList<DataProviderParameter>();
055: for (JavaParameter param : params) {
056: String paramType = toString(param.getType());
057: if (param.isHolder()) {
058: paramType = param.getHolderName() + "<" + paramType
059: + ">"; // NOI18N
060: }
061: parameters.add(new DataProviderParameter(paramType, param
062: .getName()));
063: }
064:
065: exceptions = new ArrayList<String>();
066: Iterator<String> exceptionIter = method.getExceptions();
067:
068: while (exceptionIter.hasNext()) {
069: exceptions.add(exceptionIter.next());
070: }
071: }
072:
073: public JavaMethod getJavaMethod() {
074: return javaMethod;
075: }
076:
077: public String getMethodName() {
078: return methodName;
079: }
080:
081: public String getMethodReturnType() {
082: return returnType;
083: }
084:
085: public List<DataProviderParameter> getParameters() {
086: return parameters;
087: }
088:
089: public List<String> getExceptions() {
090: return exceptions;
091: }
092:
093: private String toString(JavaType type) {
094: if (type.isHolder()) {
095: return "javax.xml.ws.Holder<" + type.getHolderName() + ">"; // NOI18N
096: } else {
097: return type.getRealName();
098: }
099: }
100: }
|