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.wsdl.document;
027:
028: import java.util.Iterator;
029:
030: import javax.xml.namespace.QName;
031:
032: import com.sun.tools.internal.ws.wsdl.framework.AbstractDocument;
033: import com.sun.tools.internal.ws.wsdl.framework.Defining;
034: import com.sun.tools.internal.ws.wsdl.framework.EntityAction;
035: import com.sun.tools.internal.ws.wsdl.framework.EntityReferenceAction;
036: import com.sun.tools.internal.ws.wsdl.framework.ExtensibilityHelper;
037: import com.sun.tools.internal.ws.wsdl.framework.Extensible;
038: import com.sun.tools.internal.ws.wsdl.framework.Extension;
039: import com.sun.tools.internal.ws.wsdl.framework.GlobalEntity;
040: import com.sun.tools.internal.ws.wsdl.framework.Kind;
041: import com.sun.tools.internal.ws.wsdl.framework.QNameAction;
042:
043: /**
044: * Entity corresponding to the "port" WSDL element.
045: *
046: * @author WS Development Team
047: */
048: public class Port extends GlobalEntity implements Extensible {
049:
050: public Port(Defining defining) {
051: super (defining);
052: _helper = new ExtensibilityHelper();
053: }
054:
055: public Service getService() {
056: return _service;
057: }
058:
059: public void setService(Service s) {
060: _service = s;
061: }
062:
063: public QName getBinding() {
064: return _binding;
065: }
066:
067: public void setBinding(QName n) {
068: _binding = n;
069: }
070:
071: public Binding resolveBinding(AbstractDocument document) {
072: return (Binding) document.find(Kinds.BINDING, _binding);
073: }
074:
075: public Kind getKind() {
076: return Kinds.PORT;
077: }
078:
079: public QName getElementName() {
080: return WSDLConstants.QNAME_PORT;
081: }
082:
083: public Documentation getDocumentation() {
084: return _documentation;
085: }
086:
087: public void setDocumentation(Documentation d) {
088: _documentation = d;
089: }
090:
091: public void withAllQNamesDo(QNameAction action) {
092: super .withAllQNamesDo(action);
093:
094: if (_binding != null) {
095: action.perform(_binding);
096: }
097: }
098:
099: public void withAllEntityReferencesDo(EntityReferenceAction action) {
100: super .withAllEntityReferencesDo(action);
101: if (_binding != null) {
102: action.perform(Kinds.BINDING, _binding);
103: }
104: }
105:
106: public void accept(WSDLDocumentVisitor visitor) throws Exception {
107: visitor.preVisit(this );
108: _helper.accept(visitor);
109: visitor.postVisit(this );
110: }
111:
112: public void validateThis() {
113: if (getName() == null) {
114: failValidation("validation.missingRequiredAttribute",
115: "name");
116: }
117: if (_binding == null) {
118: failValidation("validation.missingRequiredAttribute",
119: "binding");
120: }
121: }
122:
123: public void addExtension(Extension e) {
124: _helper.addExtension(e);
125: }
126:
127: public Iterator extensions() {
128: return _helper.extensions();
129: }
130:
131: public void withAllSubEntitiesDo(EntityAction action) {
132: _helper.withAllSubEntitiesDo(action);
133: }
134:
135: private ExtensibilityHelper _helper;
136: private Documentation _documentation;
137: private Service _service;
138: private QName _binding;
139: }
|