SOAPHeader.java revision 325
0N/A/*
2362N/A * Copyright (c) 1997, 2011, Oracle and/or its affiliates. All rights reserved.
0N/A * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
0N/A *
0N/A * This code is free software; you can redistribute it and/or modify it
0N/A * under the terms of the GNU General Public License version 2 only, as
0N/A * published by the Free Software Foundation. Oracle designates this
0N/A * particular file as subject to the "Classpath" exception as provided
0N/A * by Oracle in the LICENSE file that accompanied this code.
0N/A *
0N/A * This code is distributed in the hope that it will be useful, but WITHOUT
0N/A * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
0N/A * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
0N/A * version 2 for more details (a copy is included in the LICENSE file that
0N/A * accompanied this code).
0N/A *
0N/A * You should have received a copy of the GNU General Public License version
0N/A * 2 along with this work; if not, write to the Free Software Foundation,
2362N/A * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
2362N/A *
2362N/A * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
0N/A * or visit www.oracle.com if you need additional information or have any
0N/A * questions.
0N/A */
0N/A
0N/Apackage com.sun.tools.internal.ws.wsdl.document.soap;
0N/A
0N/Aimport com.sun.tools.internal.ws.wsdl.framework.*;
0N/Aimport org.xml.sax.Locator;
0N/A
0N/Aimport javax.xml.namespace.QName;
0N/Aimport java.util.ArrayList;
0N/Aimport java.util.Iterator;
0N/Aimport java.util.List;
0N/A
0N/A/**
0N/A * A SOAP header extension.
0N/A *
0N/A * @author WS Development Team
0N/A */
0N/Apublic class SOAPHeader extends ExtensionImpl {
0N/A
0N/A public SOAPHeader(Locator locator) {
0N/A super(locator);
0N/A _faults = new ArrayList();
0N/A }
0N/A
public void add(SOAPHeaderFault fault) {
_faults.add(fault);
}
public Iterator faults() {
return _faults.iterator();
}
public QName getElementName() {
return SOAPConstants.QNAME_HEADER;
}
public String getNamespace() {
return _namespace;
}
public void setNamespace(String s) {
_namespace = s;
}
public SOAPUse getUse() {
return _use;
}
public void setUse(SOAPUse u) {
_use = u;
}
public boolean isEncoded() {
return _use == SOAPUse.ENCODED;
}
public boolean isLiteral() {
return _use == SOAPUse.LITERAL;
}
public String getEncodingStyle() {
return _encodingStyle;
}
public void setEncodingStyle(String s) {
_encodingStyle = s;
}
public String getPart() {
return _part;
}
public void setMessage(QName message) {
_message = message;
}
public QName getMessage() {
return _message;
}
public void setPart(String s) {
_part = s;
}
public void withAllSubEntitiesDo(EntityAction action) {
super.withAllSubEntitiesDo(action);
for (Iterator iter = _faults.iterator(); iter.hasNext();) {
action.perform((Entity) iter.next());
}
}
public void withAllQNamesDo(QNameAction action) {
super.withAllQNamesDo(action);
if (_message != null) {
action.perform(_message);
}
}
public void accept(ExtensionVisitor visitor) throws Exception {
visitor.preVisit(this);
for (Iterator iter = _faults.iterator(); iter.hasNext();) {
((SOAPHeaderFault) iter.next()).accept(visitor);
}
visitor.postVisit(this);
}
public void validateThis() {
if (_message == null) {
failValidation("validation.missingRequiredAttribute", "message");
}
if (_part == null) {
failValidation("validation.missingRequiredAttribute", "part");
}
// Fix for bug 4851427
// if (_use == null) {
// failValidation("validation.missingRequiredAttribute", "use");
// }
if(_use == SOAPUse.ENCODED) {
throw new ValidationException("validation.unsupportedUse.encoded", getLocator().getLineNumber(),getLocator().getSystemId());
}
}
private String _encodingStyle;
private String _namespace;
private String _part;
private QName _message;
private SOAPUse _use=SOAPUse.LITERAL;
private List _faults;
}