KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > netbeans > modules > j2ee > sun > share > configbean > customizers > webservice > PortInfoMapping


1 /*
2  * The contents of this file are subject to the terms of the Common Development
3  * and Distribution License (the License). You may not use this file except in
4  * compliance with the License.
5  *
6  * You can obtain a copy of the License at http://www.netbeans.org/cddl.html
7  * or http://www.netbeans.org/cddl.txt.
8  *
9  * When distributing Covered Code, include this CDDL Header Notice in each file
10  * and include the License file at http://www.netbeans.org/cddl.txt.
11  * If applicable, add the following below the CDDL Header, with the fields
12  * enclosed by brackets [] replaced by your own identifying information:
13  * "Portions Copyrighted [year] [name of copyright owner]"
14  *
15  * The Original Software is NetBeans. The Initial Developer of the Original
16  * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun
17  * Microsystems, Inc. All Rights Reserved.
18  */

19 /*
20  * PortInfoMapping.java
21  *
22  * Created on October 27, 2003, 8:39 AM
23  */

24
25 package org.netbeans.modules.j2ee.sun.share.configbean.customizers.webservice;
26
27 import org.netbeans.modules.j2ee.sun.dd.api.common.PortInfo;
28 import org.netbeans.modules.j2ee.sun.dd.api.common.WsdlPort;
29
30
31 /** Class that associates a PortInfo with a string so we can do combobox
32  * selection easiser.
33  *
34  * @author Peter Williams
35  * @version %I%, %G%
36  */

37 public class PortInfoMapping {
38
39     private PortInfo portInfo;
40     private String JavaDoc displayText;
41     private boolean textOutOfDate;
42
43     public PortInfoMapping(final PortInfo pi) {
44         portInfo = pi;
45         displayText = buildDisplayText();
46     }
47
48     public PortInfoMapping(final PortInfo pi, final String JavaDoc display) {
49         portInfo = pi;
50         displayText = display;
51     }
52
53     public String JavaDoc toString() {
54         if(textOutOfDate) {
55             displayText = buildDisplayText();
56         }
57
58         return displayText;
59     }
60
61     public PortInfo getPortInfo() {
62         return portInfo;
63     }
64
65     public void updateDisplayText() {
66         textOutOfDate = true;
67     }
68
69     private String JavaDoc buildDisplayText() {
70         String JavaDoc sei = portInfo.getServiceEndpointInterface();
71         WsdlPort wsdl = portInfo.getWsdlPort();
72         String JavaDoc localPart = null;
73         String JavaDoc namespaceURI = null;
74
75         if(wsdl != null) {
76             localPart = wsdl.getLocalpart();
77             namespaceURI = wsdl.getNamespaceURI();
78         }
79
80         StringBuffer JavaDoc resultBuf = new StringBuffer JavaDoc(128);
81         boolean separator = false;
82
83         if(sei != null && sei.length() > 0) {
84             resultBuf.append(sei);
85             separator = true;
86         }
87
88         if(localPart != null && localPart.length() > 0) {
89             if(separator) {
90                 resultBuf.append(", ");
91             }
92
93             resultBuf.append(localPart);
94             separator = true;
95         }
96
97         if(namespaceURI != null && namespaceURI.length() > 0) {
98             if(separator) {
99                 resultBuf.append(", ");
100             }
101
102             resultBuf.append(namespaceURI);
103         }
104
105         if(resultBuf.length() == 0) {
106             resultBuf.append(ServiceRefCustomizer.bundle.getString("LBL_UntitledPortInfo"));
107         }
108
109         textOutOfDate = false;
110
111         return resultBuf.toString();
112     }
113 }
114
Popular Tags