use of com.sun.xml.ws.util.xml.XMLReaderComposite.ElemInfo in project metro-jax-ws by eclipse-ee4j.
the class XMLReaderCompositeTest method testComposite.
// @Test
public void testComposite() throws Exception {
XMLStreamReader r = r("<root xmlns='ns0' xmlns:p1='ns1' att1='11' xmlns:p2='ns2' xmlns:p3='ns3'/>");
XMLStreamReader x = r("<p1:x xmlns:p2='ns2' xmlns:p1='ns1' att2='22' p2:att2='11'/>");
XMLStreamReader a = r("<a xmlns='ns0' att1='11'/>");
XMLStreamReader b = r("<p1:b xmlns='ns0' att1='11' xmlns:p3='ns3' xmlns:p1='ns1'/>");
TagInfoset rTag = new TagInfoset(r);
ElemInfo rElem = new ElemInfo(rTag, null);
TagInfoset xTag = new TagInfoset(x);
ElemInfo xElem = new ElemInfo(xTag, rElem);
XMLStreamReader[] kids = { a, b };
XMLReaderComposite xrc = new XMLReaderComposite(xElem, kids);
assertTrue(xrc.isStartElement());
assertEquals(new QName("ns1", "x"), xrc.getName());
assertEquals(2, xrc.getAttributeCount());
assertEquals(2, xrc.getNamespaceCount());
assertEquals("ns0", xrc.getNamespaceURI(""));
assertEquals("ns3", xrc.getNamespaceURI("p3"));
xrc.next();
assertTrue(xrc.isStartElement());
assertEquals(new QName("ns0", "a"), xrc.getName());
assertEquals(1, xrc.getAttributeCount());
xrc.next();
assertTrue(xrc.isEndElement());
xrc.next();
assertTrue(xrc.isStartElement());
assertEquals(new QName("ns1", "b"), xrc.getName());
assertEquals(1, xrc.getAttributeCount());
xrc.next();
assertTrue(xrc.isEndElement());
xrc.next();
assertTrue(xrc.isEndElement());
}
use of com.sun.xml.ws.util.xml.XMLReaderComposite.ElemInfo in project metro-jax-ws by eclipse-ee4j.
the class JAXBMessage method readToBodyStarTag.
public XMLStreamReader readToBodyStarTag() {
int base = soapVersion.ordinal() * 3;
this.envelopeTag = DEFAULT_TAGS.get(base);
this.bodyTag = DEFAULT_TAGS.get(base + 2);
List<XMLStreamReader> hReaders = new java.util.ArrayList<>();
ElemInfo envElem = new ElemInfo(envelopeTag, null);
ElemInfo bdyElem = new ElemInfo(bodyTag, envElem);
for (Header h : getHeaders().asList()) {
try {
hReaders.add(h.readHeader());
} catch (XMLStreamException e) {
throw new RuntimeException(e);
}
}
XMLStreamReader soapHeader = null;
if (hReaders.size() > 0) {
headerTag = DEFAULT_TAGS.get(base + 1);
ElemInfo hdrElem = new ElemInfo(headerTag, envElem);
soapHeader = new XMLReaderComposite(hdrElem, hReaders.toArray(new XMLStreamReader[0]));
}
XMLStreamReader soapBody = new XMLReaderComposite(bdyElem, new XMLStreamReader[] {});
XMLStreamReader[] soapContent = (soapHeader != null) ? new XMLStreamReader[] { soapHeader, soapBody } : new XMLStreamReader[] { soapBody };
return new XMLReaderComposite(envElem, soapContent);
}
use of com.sun.xml.ws.util.xml.XMLReaderComposite.ElemInfo in project metro-jax-ws by eclipse-ee4j.
the class JAXBMessage method readEnvelope.
public XMLStreamReader readEnvelope() {
int base = soapVersion.ordinal() * 3;
this.envelopeTag = DEFAULT_TAGS.get(base);
this.bodyTag = DEFAULT_TAGS.get(base + 2);
List<XMLStreamReader> hReaders = new java.util.ArrayList<>();
ElemInfo envElem = new ElemInfo(envelopeTag, null);
ElemInfo bdyElem = new ElemInfo(bodyTag, envElem);
for (Header h : getHeaders().asList()) {
try {
hReaders.add(h.readHeader());
} catch (XMLStreamException e) {
throw new RuntimeException(e);
}
}
XMLStreamReader soapHeader = null;
if (hReaders.size() > 0) {
headerTag = DEFAULT_TAGS.get(base + 1);
ElemInfo hdrElem = new ElemInfo(headerTag, envElem);
soapHeader = new XMLReaderComposite(hdrElem, hReaders.toArray(new XMLStreamReader[0]));
}
try {
XMLStreamReader payload = readPayload();
XMLStreamReader soapBody = new XMLReaderComposite(bdyElem, new XMLStreamReader[] { payload });
XMLStreamReader[] soapContent = (soapHeader != null) ? new XMLStreamReader[] { soapHeader, soapBody } : new XMLStreamReader[] { soapBody };
return new XMLReaderComposite(envElem, soapContent);
} catch (XMLStreamException e) {
throw new RuntimeException(e);
}
}
use of com.sun.xml.ws.util.xml.XMLReaderComposite.ElemInfo in project metro-jax-ws by eclipse-ee4j.
the class StreamMessage method readToBodyStarTag.
public XMLStreamReader readToBodyStarTag() {
if (envelopeReader != null)
readEnvelope(this);
List<XMLStreamReader> hReaders = new java.util.ArrayList<>();
ElemInfo envElem = new ElemInfo(envelopeTag, null);
ElemInfo hdrElem = (headerTag != null) ? new ElemInfo(headerTag, envElem) : null;
ElemInfo bdyElem = new ElemInfo(bodyTag, envElem);
for (Header h : getHeaders().asList()) {
try {
hReaders.add(h.readHeader());
} catch (XMLStreamException e) {
throw new RuntimeException(e);
}
}
XMLStreamReader soapHeader = (hdrElem != null) ? new XMLReaderComposite(hdrElem, hReaders.toArray(new XMLStreamReader[0])) : null;
XMLStreamReader[] payload = {};
XMLStreamReader soapBody = new XMLReaderComposite(bdyElem, payload);
XMLStreamReader[] soapContent = (soapHeader != null) ? new XMLStreamReader[] { soapHeader, soapBody } : new XMLStreamReader[] { soapBody };
return new XMLReaderComposite(envElem, soapContent);
}
use of com.sun.xml.ws.util.xml.XMLReaderComposite.ElemInfo in project metro-jax-ws by eclipse-ee4j.
the class StreamMessage method readEnvelope.
public XMLStreamReader readEnvelope() {
if (envelopeReader == null) {
List<XMLStreamReader> hReaders = new java.util.ArrayList<>();
ElemInfo envElem = new ElemInfo(envelopeTag, null);
ElemInfo hdrElem = (headerTag != null) ? new ElemInfo(headerTag, envElem) : null;
ElemInfo bdyElem = new ElemInfo(bodyTag, envElem);
for (Header h : getHeaders().asList()) {
try {
hReaders.add(h.readHeader());
} catch (XMLStreamException e) {
throw new RuntimeException(e);
}
}
XMLStreamReader soapHeader = (hdrElem != null) ? new XMLReaderComposite(hdrElem, hReaders.toArray(new XMLStreamReader[0])) : null;
XMLStreamReader[] payload = { readPayload() };
XMLStreamReader soapBody = new XMLReaderComposite(bdyElem, payload);
XMLStreamReader[] soapContent = (soapHeader != null) ? new XMLStreamReader[] { soapHeader, soapBody } : new XMLStreamReader[] { soapBody };
return new XMLReaderComposite(envElem, soapContent);
}
return envelopeReader;
}
Aggregations