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-2007 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: /*
043: * Endpoint.java
044: *
045: * Created on October 4, 2006, 2:26 PM
046: *
047: * To change this template, choose Tools | Template Manager
048: * and open the template in the editor.
049: */
050:
051: package org.netbeans.modules.compapp.javaee.codegen.model;
052:
053: import javax.xml.namespace.QName;
054: import org.openide.util.NbBundle;
055:
056: /**
057: *
058: * @author gpatil
059: */
060: public class Endpoint {
061: public static enum EndPointType {
062: Provider, Consumer
063: }
064:
065: private EndPointType ept;
066: private String endPointName; // PortName
067: private QName interfaceName; // PortType
068: private QName serviceName; // ServiceName
069:
070: private String wsdlLocation = ""; //NOI18N
071:
072: private int hash = -1;
073:
074: /**
075: * Creates a new instance of Endpoint
076: */
077: public Endpoint() {
078: }
079:
080: public Endpoint(EndPointType type, String portName, QName portType,
081: QName nServiceName) {
082: this .ept = type;
083: this .endPointName = portName;
084: this .interfaceName = portType;
085: this .serviceName = nServiceName;
086: }
087:
088: public Endpoint(Endpoint orig) {
089: this .ept = orig.ept;
090: this .endPointName = orig.endPointName;
091: this .interfaceName = orig.interfaceName;
092: this .serviceName = orig.serviceName;
093: }
094:
095: public void setEndPointType(EndPointType nEpt) {
096: this .ept = nEpt;
097: this .hash = -1;
098: }
099:
100: public EndPointType getEndPointType() {
101: return this .ept;
102: }
103:
104: public void setEndPointName(String nName) {
105: this .endPointName = nName;
106: this .hash = -1;
107: }
108:
109: public String getEndPointName() {
110: return this .endPointName;
111: }
112:
113: public void setInterfaceName(QName nName) {
114: this .interfaceName = nName;
115: this .hash = -1;
116: }
117:
118: public QName getInterfaceName() {
119: return this .interfaceName;
120: }
121:
122: public void setServiceName(QName nName) {
123: this .serviceName = nName;
124: this .hash = -1;
125: }
126:
127: public QName getServiceName() {
128: return this .serviceName;
129: }
130:
131: public String getWSDLLocation() {
132: return this .wsdlLocation;
133: }
134:
135: public void setWSDLLocation(String nWsdlLoc) {
136: this .wsdlLocation = nWsdlLoc;
137: }
138:
139: // Used only by getLocalizedString
140: private static String LOCALIZED_STR_PROVIDES = null;
141: private static String LOCALIZED_STR_CONSUMES = null;
142: private static String LOCALIZED_STR_SERVICE = null;
143: private static String LOCALIZED_STR_INTERFACE = null;
144: private static String LOCALIZED_STR_ENDPOINT = null;
145:
146: static {
147: LOCALIZED_STR_PROVIDES = NbBundle.getMessage(Endpoint.class,
148: "LBL_Provides"); //NOI18N
149: LOCALIZED_STR_CONSUMES = NbBundle.getMessage(Endpoint.class,
150: "LBL_Consumes"); //NOI18N
151: LOCALIZED_STR_SERVICE = NbBundle.getMessage(Endpoint.class,
152: "LBL_Service"); //NOI18N
153: LOCALIZED_STR_INTERFACE = NbBundle.getMessage(Endpoint.class,
154: "LBL_Ineterface"); //NOI18N
155: LOCALIZED_STR_ENDPOINT = NbBundle.getMessage(Endpoint.class,
156: "LBL_Endpoint"); //NOI18N
157: }
158:
159: public String getEPToolTip() {
160: StringBuffer sb = new StringBuffer();
161: sb.append("<html>");//NOI18N
162:
163: if (EndPointType.Provider.equals(this .ept)) {
164: sb.append(LOCALIZED_STR_PROVIDES);
165: } else {
166: sb.append(LOCALIZED_STR_CONSUMES);
167: }
168: sb.append("<br>"); //NOI18N
169: sb.append(LOCALIZED_STR_SERVICE);
170: sb.append(":"); //NOI18N
171: sb.append(this .serviceName);
172: sb.append("<br>"); //NOI18N
173: sb.append(LOCALIZED_STR_ENDPOINT);
174: sb.append(":"); //NOI18N
175: sb.append(this .endPointName);
176: sb.append("<br>"); //NOI18N
177: sb.append(LOCALIZED_STR_INTERFACE);
178: sb.append(":"); //NOI18N
179: sb.append(this .interfaceName);
180: sb.append("</html>");//NOI18N
181: return sb.toString();
182: }
183:
184: public String toString() {
185: StringBuffer sb = new StringBuffer();
186: sb.append("EndPoint("); //NOI18N
187: sb.append(this .ept);
188: sb.append("):service:");//NOI18N
189: sb.append(this .serviceName);
190: sb.append(":port:");//NOI18N
191: sb.append(this .endPointName);
192: sb.append(":portType:");//NOI18N
193: sb.append(this .interfaceName);
194: return sb.toString();
195: }
196:
197: public String toEndpointConfigXML(String indent) {
198: if (indent == null) {
199: indent = "";
200: }
201:
202: String newlineIndent = "\n" + indent;
203:
204: StringBuffer sb = new StringBuffer();
205: sb.append(indent);
206: sb.append("<endpoint ");//NOI18N
207: sb.append(newlineIndent);
208: sb.append(" endpointType=\"");//NOI18N
209: sb.append(this .ept);
210: sb.append("\""); //NOI18N
211: sb.append(newlineIndent);
212: sb.append(" portName=\""); //NOI18N
213: sb.append(this .endPointName);
214: sb.append("\""); //NOI18N
215: sb.append(newlineIndent);
216: sb.append(" portTypeLocalName=\"");//NOI18N
217: sb.append(this .interfaceName.getLocalPart());
218: sb.append("\""); //NOI18N
219: sb.append(newlineIndent);
220: sb.append(" portTypeNamespace=\"");//NOI18N
221: sb.append(this .interfaceName.getNamespaceURI());
222: sb.append("\""); //NOI18N
223: sb.append(newlineIndent);
224: sb.append(" serviceLocalName=\"");//NOI18N
225: sb.append(this .serviceName.getLocalPart());
226: sb.append("\""); //NOI18N
227: sb.append(newlineIndent);
228: sb.append(" serviceNamespace=\"");//NOI18N
229: sb.append(this .serviceName.getNamespaceURI());
230: sb.append("\"/>\n");//NOI18N
231: return sb.toString();
232: }
233:
234: /**
235: *
236: */
237: public boolean equals(Object obj) {
238: boolean ret = true;
239: Endpoint oObj = null;
240:
241: if (this == obj) {
242: return true;
243: }
244:
245: if ((obj == null) || (!(obj instanceof Endpoint))) {
246: return false;
247: }
248:
249: oObj = (Endpoint) obj;
250:
251: if (this .ept != oObj.ept) {
252: return false;
253: }
254:
255: if ((this .interfaceName == null)
256: && (oObj.getInterfaceName() != null)) {
257: return false;
258: }
259:
260: if ((this .interfaceName != null)
261: && (!this .interfaceName.equals(oObj.getInterfaceName()))) {
262: return false;
263: }
264:
265: if ((this .serviceName == null)
266: && (oObj.getServiceName() != null)) {
267: return false;
268: }
269:
270: if ((this .serviceName != null)
271: && (!this .serviceName.equals(oObj.getServiceName()))) {
272: return false;
273: }
274:
275: if ((this .endPointName == null)
276: && (oObj.getEndPointName() != null)) {
277: return false;
278: }
279:
280: if ((this .endPointName != null)
281: && (!this .endPointName.equals(oObj.getEndPointName()))) {
282: return false;
283: }
284:
285: return ret;
286: }
287:
288: public int hashCode() {
289: if (this .hash == -1) {
290: // Do not include "UseBridge", "usingDefaultNames"
291: StringBuffer sb = new StringBuffer();
292: sb.append(this.endPointName);
293: sb.append(this.ept);
294: sb.append(this.interfaceName);
295: sb.append(this.serviceName);
296: this.hash = sb.toString().hashCode();
297: }
298: return this.hash;
299: }
300: }
|