< prev index next >

jaxws/src/java.xml.ws/share/classes/com/sun/xml/internal/messaging/saaj/soap/impl/HeaderImpl.java

Print this page

        

@@ -23,23 +23,29 @@
  * questions.
  */
 
 package com.sun.xml.internal.messaging.saaj.soap.impl;
 
-import java.util.*;
 import java.util.logging.Level;
 
 import javax.xml.namespace.QName;
-import javax.xml.soap.*;
 
-import com.sun.xml.internal.messaging.saaj.util.SAAJUtil;
 import org.w3c.dom.Element;
 
 import com.sun.xml.internal.messaging.saaj.SOAPExceptionImpl;
 import com.sun.xml.internal.messaging.saaj.soap.SOAPDocument;
 import com.sun.xml.internal.messaging.saaj.soap.SOAPDocumentImpl;
 import com.sun.xml.internal.messaging.saaj.soap.name.NameImpl;
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+import javax.xml.soap.Name;
+import javax.xml.soap.SOAPElement;
+import javax.xml.soap.SOAPEnvelope;
+import javax.xml.soap.SOAPException;
+import javax.xml.soap.SOAPHeader;
+import javax.xml.soap.SOAPHeaderElement;
 
 public abstract class HeaderImpl extends ElementImpl implements SOAPHeader {
     protected static final boolean MUST_UNDERSTAND_ONLY = false;
 
     protected HeaderImpl(SOAPDocumentImpl ownerDoc, NameImpl name) {

@@ -56,10 +62,11 @@
         throws SOAPException;
     protected abstract NameImpl getNotUnderstoodName();
     protected abstract NameImpl getUpgradeName();
     protected abstract NameImpl getSupportedEnvelopeName();
 
+    @Override
     public SOAPHeaderElement addHeaderElement(Name name) throws SOAPException {
         SOAPElement newHeaderElement =
             ElementFactory.createNamedElement(
                 ((SOAPDocument) getOwnerDocument()).getDocument(),
                 name.getLocalName(),

@@ -79,10 +86,11 @@
         }
         addNode(newHeaderElement);
         return (SOAPHeaderElement) newHeaderElement;
     }
 
+    @Override
     public SOAPHeaderElement addHeaderElement(QName name) throws SOAPException {
         SOAPElement newHeaderElement =
             ElementFactory.createNamedElement(
                 ((SOAPDocument) getOwnerDocument()).getDocument(),
                 name.getLocalPart(),

@@ -102,23 +110,27 @@
         }
         addNode(newHeaderElement);
         return (SOAPHeaderElement) newHeaderElement;
     }
 
+    @Override
     protected SOAPElement addElement(Name name) throws SOAPException {
         return addHeaderElement(name);
     }
 
+    @Override
     protected SOAPElement addElement(QName name) throws SOAPException {
         return addHeaderElement(name);
     }
 
-    public Iterator examineHeaderElements(String actor) {
+    @Override
+    public Iterator<SOAPHeaderElement> examineHeaderElements(String actor) {
         return getHeaderElementsForActor(actor, false, false);
     }
 
-    public Iterator extractHeaderElements(String actor) {
+    @Override
+    public Iterator<SOAPHeaderElement> extractHeaderElements(String actor) {
         return getHeaderElementsForActor(actor, true, false);
     }
 
     protected Iterator<SOAPHeaderElement> getHeaderElementsForActor(
         String actor,

@@ -133,13 +145,13 @@
 
     protected Iterator<SOAPHeaderElement> getHeaderElements(
         String actor,
         boolean detach,
         boolean mustUnderstand) {
-        List<SOAPHeaderElement> elementList = new ArrayList<SOAPHeaderElement>();
+        List<SOAPHeaderElement> elementList = new ArrayList<>();
 
-        Iterator<org.w3c.dom.Node> eachChild = getChildElements();
+        Iterator<javax.xml.soap.Node> eachChild = getChildElements();
 
         org.w3c.dom.Node currentChild = iterate(eachChild);
         while (currentChild != null) {
             if (!(currentChild instanceof SOAPHeaderElement)) {
                 currentChild = iterate(eachChild);

@@ -179,10 +191,11 @@
 
     private <T> T iterate(Iterator<T> each) {
         return each.hasNext() ? each.next() : null;
     }
 
+    @Override
     public void setParentElement(SOAPElement element) throws SOAPException {
         if (!(element instanceof SOAPEnvelope)) {
             log.severe("SAAJ0133.impl.header.parent.mustbe.envelope");
             throw new SOAPException("Parent of SOAPHeader has to be a SOAPEnvelope");
         }

@@ -191,10 +204,11 @@
 
     // overriding ElementImpl's method to ensure that HeaderElements are
     // namespace qualified. Holds for both SOAP versions.
     // TODO - This check needs to be made for other addChildElement() methods
     // as well.
+    @Override
     public SOAPElement addChildElement(String localName) throws SOAPException {
 
         SOAPElement element = super.addChildElement(localName);
         // check that URI is  not empty, ensuring that the element is NS qualified.
         String uri = element.getElementName().getURI();

@@ -203,23 +217,27 @@
             throw new SOAPExceptionImpl("HeaderElements must be namespace qualified");
         }
         return element;
     }
 
-    public Iterator examineAllHeaderElements() {
+    @Override
+    public Iterator<SOAPHeaderElement> examineAllHeaderElements() {
         return getHeaderElements(null, false, MUST_UNDERSTAND_ONLY);
     }
 
-    public Iterator examineMustUnderstandHeaderElements(String actor) {
+    @Override
+    public Iterator<SOAPHeaderElement> examineMustUnderstandHeaderElements(String actor) {
         return getHeaderElements(actor, false, true);
 
     }
 
-    public Iterator extractAllHeaderElements() {
+    @Override
+    public Iterator<SOAPHeaderElement> extractAllHeaderElements() {
         return getHeaderElements(null, true, false);
     }
 
+    @Override
     public SOAPHeaderElement addUpgradeHeaderElement(Iterator supportedSoapUris)
         throws SOAPException {
         if (supportedSoapUris == null) {
             log.severe("SAAJ0411.ver1_2.no.null.supportedURIs");
             throw new SOAPException("Argument cannot be null; iterator of supportedURIs cannot be null");

@@ -239,22 +257,23 @@
             String ns = "ns" + Integer.toString(i);
             subElement.addAttribute(
                 NameImpl.createFromUnqualifiedName("qname"),
                 ns + ":Envelope");
             subElement.addNamespaceDeclaration(
-                ns,
-                (String) supportedSoapUris.next());
+                ns, (String) supportedSoapUris.next());
             i ++;
         }
         return upgradeHeaderElement;
     }
 
+    @Override
     public SOAPHeaderElement addUpgradeHeaderElement(String supportedSoapUri)
         throws SOAPException {
         return addUpgradeHeaderElement(new String[] {supportedSoapUri});
     }
 
+    @Override
     public SOAPHeaderElement addUpgradeHeaderElement(String[] supportedSoapUris)
         throws SOAPException {
 
         if (supportedSoapUris == null) {
             log.severe("SAAJ0411.ver1_2.no.null.supportedURIs");

@@ -278,10 +297,11 @@
             subElement.addNamespaceDeclaration(ns, supportedSoapUris[i]);
         }
         return upgradeHeaderElement;
     }
 
+    @Override
     protected SOAPElement convertToSoapElement(Element element) {
         final org.w3c.dom.Node soapNode = getSoapDocument().findIfPresent(element);
         if (soapNode instanceof SOAPHeaderElement) {
             return (SOAPElement) soapNode;
         } else {

@@ -296,10 +316,11 @@
                 element,
                 (ElementImpl) headerElement);
         }
     }
 
+    @Override
     public SOAPElement setElementQName(QName newName) throws SOAPException {
        log.log(Level.SEVERE,
                 "SAAJ0146.impl.invalid.name.change.requested",
                 new Object[] {elementQName.getLocalPart(),
                               newName.getLocalPart()});
< prev index next >