Skip to content

Package: StaxLazySourceBridge$1

StaxLazySourceBridge$1

nameinstructionbranchcomplexitylinemethod
proceedAfterStartElement()
M: 17 C: 0
0%
M: 4 C: 0
0%
M: 3 C: 0
0%
M: 3 C: 0
0%
M: 1 C: 0
0%
{...}
M: 11 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 1 C: 0
0%
M: 1 C: 0
0%

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.XMLStreamException;
17: import javax.xml.stream.XMLStreamReader;
18: import javax.xml.stream.XMLStreamWriter;
19:
20: import com.sun.xml.messaging.saaj.LazyEnvelopeSource;
21: import org.jvnet.staxex.util.XMLStreamReaderToXMLStreamWriter;
22:
23:
24: /**
25: * StaxBridge builds Envelope from LazyEnvelopeSource
26: *
27: * @author shih-chang.chen@oracle.com
28: */
29: public class StaxLazySourceBridge extends StaxBridge {
30: private LazyEnvelopeSource lazySource;
31:
32: public StaxLazySourceBridge(LazyEnvelopeSource src, SOAPPartImpl soapPart) throws SOAPException {
33: super(soapPart);
34: lazySource = src;
35: final String soapEnvNS = soapPart.getSOAPNamespace();
36: try {
37: breakpoint = new XMLStreamReaderToXMLStreamWriter.Breakpoint(src.readToBodyStarTag(), saajWriter) {
38: @Override
39: public boolean proceedAfterStartElement() {
40:• if ("Body".equals(reader.getLocalName()) && soapEnvNS.equals(reader.getNamespaceURI()) ){
41: return false;
42: } else
43: return true;
44: }
45: };
46: } catch (XMLStreamException e) {
47: throw new SOAPException(e);
48: }
49: }
50:
51: @Override
52: public XMLStreamReader getPayloadReader() {
53: return lazySource.readPayload();
54: //                throw new UnsupportedOperationException();
55: }
56:
57: @Override
58: public QName getPayloadQName() {
59: return lazySource.getPayloadQName();
60: }
61:
62: @Override
63: public String getPayloadAttributeValue(String attName) {
64: if (lazySource.isPayloadStreamReader()) {
65: XMLStreamReader reader = lazySource.readPayload();
66: if (reader.getEventType() == XMLStreamConstants.START_ELEMENT) {
67: return reader.getAttributeValue(null, attName);
68: }
69: }
70: return null;
71: }
72:
73: @Override
74: public String getPayloadAttributeValue(QName attName) {
75: if (lazySource.isPayloadStreamReader()) {
76: XMLStreamReader reader = lazySource.readPayload();
77: if (reader.getEventType() == XMLStreamConstants.START_ELEMENT) {
78: return reader.getAttributeValue(attName.getNamespaceURI(), attName.getLocalPart());
79: }
80: }
81: return null;
82: }
83:
84: @Override
85: public void bridgePayload() throws XMLStreamException {
86: //Assuming out is at Body
87: writePayloadTo(saajWriter);
88: }
89:
90: public void writePayloadTo(XMLStreamWriter writer) throws XMLStreamException {
91: lazySource.writePayloadTo(writer);
92: }
93: }