1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/src/share/jaxws_classes/com/sun/xml/internal/messaging/saaj/soap/impl/DetailImpl.java Wed Apr 27 01:27:09 2016 +0800 1.3 @@ -0,0 +1,146 @@ 1.4 +/* 1.5 + * Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved. 1.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 1.7 + * 1.8 + * This code is free software; you can redistribute it and/or modify it 1.9 + * under the terms of the GNU General Public License version 2 only, as 1.10 + * published by the Free Software Foundation. Oracle designates this 1.11 + * particular file as subject to the "Classpath" exception as provided 1.12 + * by Oracle in the LICENSE file that accompanied this code. 1.13 + * 1.14 + * This code is distributed in the hope that it will be useful, but WITHOUT 1.15 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 1.16 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 1.17 + * version 2 for more details (a copy is included in the LICENSE file that 1.18 + * accompanied this code). 1.19 + * 1.20 + * You should have received a copy of the GNU General Public License version 1.21 + * 2 along with this work; if not, write to the Free Software Foundation, 1.22 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 1.23 + * 1.24 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 1.25 + * or visit www.oracle.com if you need additional information or have any 1.26 + * questions. 1.27 + */ 1.28 + 1.29 +package com.sun.xml.internal.messaging.saaj.soap.impl; 1.30 + 1.31 +import java.util.Iterator; 1.32 +import java.util.NoSuchElementException; 1.33 + 1.34 +import javax.xml.namespace.QName; 1.35 +import javax.xml.soap.*; 1.36 + 1.37 +import org.w3c.dom.Element; 1.38 + 1.39 +import com.sun.xml.internal.messaging.saaj.soap.SOAPDocumentImpl; 1.40 +import com.sun.xml.internal.messaging.saaj.soap.name.NameImpl; 1.41 + 1.42 +public abstract class DetailImpl extends FaultElementImpl implements Detail { 1.43 + public DetailImpl(SOAPDocumentImpl ownerDoc, NameImpl detailName) { 1.44 + super(ownerDoc, detailName); 1.45 + } 1.46 + 1.47 + protected abstract DetailEntry createDetailEntry(Name name); 1.48 + protected abstract DetailEntry createDetailEntry(QName name); 1.49 + 1.50 + public DetailEntry addDetailEntry(Name name) throws SOAPException { 1.51 + DetailEntry entry = createDetailEntry(name); 1.52 + addNode(entry); 1.53 + return (DetailEntry) circumventBug5034339(entry); 1.54 + } 1.55 + 1.56 + public DetailEntry addDetailEntry(QName qname) throws SOAPException { 1.57 + DetailEntry entry = createDetailEntry(qname); 1.58 + addNode(entry); 1.59 + return (DetailEntry) circumventBug5034339(entry); 1.60 + } 1.61 + 1.62 + protected SOAPElement addElement(Name name) throws SOAPException { 1.63 + return addDetailEntry(name); 1.64 + } 1.65 + 1.66 + protected SOAPElement addElement(QName name) throws SOAPException { 1.67 + return addDetailEntry(name); 1.68 + } 1.69 + 1.70 + protected SOAPElement convertToSoapElement(Element element) { 1.71 + if (element instanceof DetailEntry) { 1.72 + return (SOAPElement) element; 1.73 + } else { 1.74 + DetailEntry detailEntry = 1.75 + createDetailEntry(NameImpl.copyElementName(element)); 1.76 + return replaceElementWithSOAPElement( 1.77 + element, 1.78 + (ElementImpl) detailEntry); 1.79 + } 1.80 + } 1.81 + 1.82 + public Iterator getDetailEntries() { 1.83 + return new Iterator() { 1.84 + Iterator eachNode = getChildElementNodes(); 1.85 + SOAPElement next = null; 1.86 + SOAPElement last = null; 1.87 + 1.88 + public boolean hasNext() { 1.89 + if (next == null) { 1.90 + while (eachNode.hasNext()) { 1.91 + next = (SOAPElement) eachNode.next(); 1.92 + if (next instanceof DetailEntry) { 1.93 + break; 1.94 + } 1.95 + next = null; 1.96 + } 1.97 + } 1.98 + return next != null; 1.99 + } 1.100 + 1.101 + public Object next() { 1.102 + if (!hasNext()) { 1.103 + throw new NoSuchElementException(); 1.104 + } 1.105 + last = next; 1.106 + next = null; 1.107 + return last; 1.108 + } 1.109 + 1.110 + public void remove() { 1.111 + if (last == null) { 1.112 + throw new IllegalStateException(); 1.113 + } 1.114 + SOAPElement target = last; 1.115 + removeChild(target); 1.116 + last = null; 1.117 + } 1.118 + }; 1.119 + } 1.120 + 1.121 + protected boolean isStandardFaultElement() { 1.122 + return true; 1.123 + } 1.124 + 1.125 + //overriding this method since the only two uses of this method 1.126 + // are in ElementImpl and DetailImpl 1.127 + //whereas the original base impl does the correct job for calls to it inside ElementImpl 1.128 + // But it would not work for DetailImpl. 1.129 + protected SOAPElement circumventBug5034339(SOAPElement element) { 1.130 + 1.131 + Name elementName = element.getElementName(); 1.132 + if (!isNamespaceQualified(elementName)) { 1.133 + String prefix = elementName.getPrefix(); 1.134 + String defaultNamespace = getNamespaceURI(prefix); 1.135 + if (defaultNamespace != null) { 1.136 + Name newElementName = 1.137 + NameImpl.create( 1.138 + elementName.getLocalName(), 1.139 + elementName.getPrefix(), 1.140 + defaultNamespace); 1.141 + SOAPElement newElement = createDetailEntry(newElementName); 1.142 + replaceChild(newElement, element); 1.143 + return newElement; 1.144 + } 1.145 + } 1.146 + return element; 1.147 + } 1.148 + 1.149 +}