001: /*
002: * Portions Copyright 2006 Sun Microsystems, Inc. All Rights Reserved.
003: * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
004: *
005: * This code is free software; you can redistribute it and/or modify it
006: * under the terms of the GNU General Public License version 2 only, as
007: * published by the Free Software Foundation. Sun designates this
008: * particular file as subject to the "Classpath" exception as provided
009: * by Sun in the LICENSE file that accompanied this code.
010: *
011: * This code is distributed in the hope that it will be useful, but WITHOUT
012: * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
013: * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
014: * version 2 for more details (a copy is included in the LICENSE file that
015: * accompanied this code).
016: *
017: * You should have received a copy of the GNU General Public License version
018: * 2 along with this work; if not, write to the Free Software Foundation,
019: * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
020: *
021: * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
022: * CA 95054 USA or visit www.sun.com if you need additional information or
023: * have any questions.
024: */
025:
026: package com.sun.tools.internal.ws.processor.model.java;
027:
028: import java.util.ArrayList;
029: import java.util.Iterator;
030: import java.util.List;
031:
032: import com.sun.tools.internal.ws.util.ClassNameInfo;
033:
034: import com.sun.tools.internal.ws.processor.model.ModelException;
035:
036: /**
037: *
038: * @author WS Development Team
039: */
040: public class JavaInterface {
041:
042: public JavaInterface() {
043: }
044:
045: public JavaInterface(String name) {
046: this (name, null);
047: }
048:
049: public JavaInterface(String name, String impl) {
050: this .realName = name;
051: this .name = name.replace('$', '.');
052: this .impl = impl;
053: }
054:
055: public String getName() {
056: return name;
057: }
058:
059: public String getFormalName() {
060: return name;
061: }
062:
063: public void setFormalName(String s) {
064: name = s;
065: }
066:
067: public String getRealName() {
068: return realName;
069: }
070:
071: public void setRealName(String s) {
072: realName = s;
073: }
074:
075: public String getImpl() {
076: return impl;
077: }
078:
079: public void setImpl(String s) {
080: impl = s;
081: }
082:
083: public Iterator getMethods() {
084: return methods.iterator();
085: }
086:
087: public boolean hasMethod(JavaMethod method) {
088: for (int i = 0; i < methods.size(); i++) {
089: if (method.equals(((JavaMethod) methods.get(i)))) {
090: return true;
091: }
092: }
093: return false;
094: }
095:
096: public void addMethod(JavaMethod method) {
097:
098: if (hasMethod(method)) {
099: throw new ModelException("model.uniqueness");
100: }
101: methods.add(method);
102: }
103:
104: /* serialization */
105: public List getMethodsList() {
106: return methods;
107: }
108:
109: /* serialization */
110: public void setMethodsList(List l) {
111: methods = l;
112: }
113:
114: public boolean hasInterface(String interfaceName) {
115: for (int i = 0; i < interfaces.size(); i++) {
116: if (interfaceName.equals((String) interfaces.get(i))) {
117: return true;
118: }
119: }
120: return false;
121: }
122:
123: public void addInterface(String interfaceName) {
124:
125: // verify that an exception with this name does not already exist
126: if (hasInterface(interfaceName)) {
127: return;
128: }
129: interfaces.add(interfaceName);
130: }
131:
132: public Iterator getInterfaces() {
133: return interfaces.iterator();
134: }
135:
136: /* serialization */
137: public List getInterfacesList() {
138: return interfaces;
139: }
140:
141: /* serialization */
142: public void setInterfacesList(List l) {
143: interfaces = l;
144: }
145:
146: public String getSimpleName() {
147: return ClassNameInfo.getName(name);
148: }
149:
150: /* NOTE - all these fields (except "interfaces") were final, but had to
151: * remove this modifier to enable serialization
152: */
153: private String javadoc;
154:
155: public String getJavaDoc() {
156: return javadoc;
157: }
158:
159: public void setJavaDoc(String javadoc) {
160: this .javadoc = javadoc;
161: }
162:
163: private String name;
164: private String realName;
165: private String impl;
166: private List methods = new ArrayList();
167: private List interfaces = new ArrayList();
168: }
|