Skip to content

Package: StaxReaderBridge

StaxReaderBridge

nameinstructionbranchcomplexitylinemethod
StaxReaderBridge(XMLStreamReader, SOAPPartImpl)
M: 0 C: 20
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 5
100%
M: 0 C: 1
100%
getPayloadAttributeValue(QName)
M: 15 C: 0
0%
M: 2 C: 0
0%
M: 2 C: 0
0%
M: 1 C: 0
0%
M: 1 C: 0
0%
getPayloadAttributeValue(String)
M: 13 C: 0
0%
M: 2 C: 0
0%
M: 2 C: 0
0%
M: 1 C: 0
0%
M: 1 C: 0
0%
getPayloadQName()
M: 1 C: 10
91%
M: 1 C: 1
50%
M: 1 C: 1
50%
M: 0 C: 1
100%
M: 0 C: 1
100%
getPayloadReader()
M: 0 C: 3
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
M: 0 C: 1
100%

Coverage

1: /*
2: * Copyright (c) 2013, 2021 Oracle and/or its affiliates. All rights reserved.
3: *
4: * This program and the accompanying materials are made available under the
5: * terms of the Eclipse Distribution License v. 1.0, which is available at
6: * http://www.eclipse.org/org/documents/edl-v10.php.
7: *
8: * SPDX-License-Identifier: BSD-3-Clause
9: */
10:
11: package com.sun.xml.messaging.saaj.soap;
12:
13: import javax.xml.namespace.QName;
14: import jakarta.xml.soap.SOAPException;
15: import javax.xml.stream.XMLStreamConstants;
16: import javax.xml.stream.XMLStreamReader;
17:
18: import org.jvnet.staxex.util.XMLStreamReaderToXMLStreamWriter;
19:
20: /**
21: * StaxBridge builds Envelope using a XMLStreamReaderToXMLStreamWriter
22: *
23: * @author shih-chang.chen@oracle.com
24: */
25: public class StaxReaderBridge extends StaxBridge {
26: private XMLStreamReader in;
27:
28: public StaxReaderBridge(XMLStreamReader reader, SOAPPartImpl soapPart) throws SOAPException {
29: super(soapPart);
30: in = reader;
31: final String soapEnvNS = soapPart.getSOAPNamespace();
32: breakpoint = new XMLStreamReaderToXMLStreamWriter.Breakpoint(reader, saajWriter) {
33: boolean seenBody = false;
34: boolean stopedAtBody = false;
35: @Override
36: public boolean proceedBeforeStartElement() {
37: if (stopedAtBody) return true;
38: if (seenBody) {
39: stopedAtBody = true;
40: return false;
41: }
42: if ("Body".equals(reader.getLocalName()) && soapEnvNS.equals(reader.getNamespaceURI()) ){
43: seenBody = true;
44: }
45: return true;
46: }
47: };
48: }
49:
50: @Override
51: public XMLStreamReader getPayloadReader() {
52: return in;
53: }
54:
55: @Override
56: public QName getPayloadQName() {
57:• return (in.getEventType() == XMLStreamConstants.START_ELEMENT) ? in.getName() : null;
58: }
59:
60: @Override
61: public String getPayloadAttributeValue(String attName) {
62:• return (in.getEventType() == XMLStreamConstants.START_ELEMENT) ? in.getAttributeValue(null, attName) : null;
63: }
64:
65: @Override
66: public String getPayloadAttributeValue(QName attName) {
67:• return (in.getEventType() == XMLStreamConstants.START_ELEMENT) ? in.getAttributeValue(attName.getNamespaceURI(), attName.getLocalPart()) : null;
68: }
69: }