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 Development
008: * and Distribution License("CDDL") (collectively, the "License"). You
009: * may not use this file except in compliance with the License. You can obtain
010: * a copy of the License at https://glassfish.dev.java.net/public/CDDL+GPL.html
011: * or glassfish/bootstrap/legal/LICENSE.txt. See the License for the specific
012: * language governing permissions and limitations under the License.
013: *
014: * When distributing the software, include this License Header Notice in each
015: * file and include the License file at glassfish/bootstrap/legal/LICENSE.txt.
016: * Sun designates this particular file as subject to the "Classpath" exception
017: * as provided by Sun in the GPL Version 2 section of the License file that
018: * accompanied this code. If applicable, add the following below the License
019: * Header, with the fields enclosed by brackets [] replaced by your own
020: * identifying information: "Portions Copyrighted [year]
021: * [name of copyright owner]"
022: *
023: * Contributor(s):
024: *
025: * If you wish your version of this file to be governed by only the CDDL or
026: * only the GPL Version 2, indicate your decision by adding "[Contributor]
027: * elects to include this software in this distribution under the [CDDL or GPL
028: * Version 2] license." If you don't indicate a single choice of license, a
029: * recipient has the option to distribute your version of this file under
030: * either the CDDL, the GPL Version 2 or to extend the choice of license to
031: * its licensees as provided above. However, if you add GPL Version 2 code
032: * and therefore, elected the GPL Version 2 license, then the option applies
033: * only if the new code is made subject to such option by the copyright
034: * holder.
035: */
036:
037: package com.sun.tools.ws.processor.model.java;
038:
039: import com.sun.tools.ws.processor.model.ModelException;
040: import com.sun.tools.ws.util.ClassNameInfo;
041:
042: import java.util.ArrayList;
043: import java.util.Iterator;
044: import java.util.List;
045:
046: /**
047: *
048: * @author WS Development Team
049: */
050: public class JavaInterface {
051:
052: public JavaInterface() {
053: }
054:
055: public JavaInterface(String name) {
056: this (name, null);
057: }
058:
059: public JavaInterface(String name, String impl) {
060: this .realName = name;
061: this .name = name.replace('$', '.');
062: this .impl = impl;
063: }
064:
065: public String getName() {
066: return name;
067: }
068:
069: public String getFormalName() {
070: return name;
071: }
072:
073: public void setFormalName(String s) {
074: name = s;
075: }
076:
077: public String getRealName() {
078: return realName;
079: }
080:
081: public void setRealName(String s) {
082: realName = s;
083: }
084:
085: public String getImpl() {
086: return impl;
087: }
088:
089: public void setImpl(String s) {
090: impl = s;
091: }
092:
093: public Iterator getMethods() {
094: return methods.iterator();
095: }
096:
097: public boolean hasMethod(JavaMethod method) {
098: for (int i = 0; i < methods.size(); i++) {
099: if (method.equals(((JavaMethod) methods.get(i)))) {
100: return true;
101: }
102: }
103: return false;
104: }
105:
106: public void addMethod(JavaMethod method) {
107:
108: if (hasMethod(method)) {
109: throw new ModelException("model.uniqueness");
110: }
111: methods.add(method);
112: }
113:
114: /* serialization */
115: public List getMethodsList() {
116: return methods;
117: }
118:
119: /* serialization */
120: public void setMethodsList(List l) {
121: methods = l;
122: }
123:
124: public boolean hasInterface(String interfaceName) {
125: for (int i = 0; i < interfaces.size(); i++) {
126: if (interfaceName.equals((String) interfaces.get(i))) {
127: return true;
128: }
129: }
130: return false;
131: }
132:
133: public void addInterface(String interfaceName) {
134:
135: // verify that an exception with this name does not already exist
136: if (hasInterface(interfaceName)) {
137: return;
138: }
139: interfaces.add(interfaceName);
140: }
141:
142: public Iterator getInterfaces() {
143: return interfaces.iterator();
144: }
145:
146: /* serialization */
147: public List getInterfacesList() {
148: return interfaces;
149: }
150:
151: /* serialization */
152: public void setInterfacesList(List l) {
153: interfaces = l;
154: }
155:
156: public String getSimpleName() {
157: return ClassNameInfo.getName(name);
158: }
159:
160: /* NOTE - all these fields (except "interfaces") were final, but had to
161: * remove this modifier to enable serialization
162: */
163: private String javadoc;
164:
165: public String getJavaDoc() {
166: return javadoc;
167: }
168:
169: public void setJavaDoc(String javadoc) {
170: this .javadoc = javadoc;
171: }
172:
173: private String name;
174: private String realName;
175: private String impl;
176: private List methods = new ArrayList();
177: private List interfaces = new ArrayList();
178: }
|