Search in sources :

Example 1 with RepeatedElementBridge

use of com.sun.xml.ws.spi.db.RepeatedElementBridge in project metro-jax-ws by eclipse-ee4j.

the class WrapperBond method marshal.

@Override
public final void marshal(T object, XMLStreamWriter output, AttachmentMarshaller am) throws JAXBException {
    WrapperComposite w = (WrapperComposite) object;
    try {
        // output.writeStartElement(typeInfo.tagName.getNamespaceURI(), typeInfo.tagName.getLocalPart());
        // System.out.println(typeInfo.tagName.getNamespaceURI());
        // The prefix is to workaround an eclipselink bug
        output.writeStartElement(WrapperPrefix, typeInfo.tagName.getLocalPart(), typeInfo.tagName.getNamespaceURI());
        output.writeNamespace(WrapperPrefix, typeInfo.tagName.getNamespaceURI());
    // output.writeStartElement("", typeInfo.tagName.getLocalPart(), typeInfo.tagName.getNamespaceURI());
    // output.writeDefaultNamespace(typeInfo.tagName.getNamespaceURI());
    // System.out.println("======== " + output.getPrefix(typeInfo.tagName.getNamespaceURI()));
    // System.out.println("======== " + output.getNamespaceContext().getPrefix(typeInfo.tagName.getNamespaceURI()));
    // System.out.println("======== " + output.getNamespaceContext().getNamespaceURI(""));
    } catch (XMLStreamException e) {
        e.printStackTrace();
        throw new DatabindingException(e);
    }
    if (w.bridges != null)
        for (int i = 0; i < w.bridges.length; i++) {
            if (w.bridges[i] instanceof RepeatedElementBridge) {
                RepeatedElementBridge rbridge = (RepeatedElementBridge) w.bridges[i];
                for (Iterator itr = rbridge.collectionHandler().iterator(w.values[i]); itr.hasNext(); ) {
                    rbridge.marshal(itr.next(), output, am);
                }
            } else {
                w.bridges[i].marshal(w.values[i], output, am);
            }
        }
    try {
        output.writeEndElement();
    } catch (XMLStreamException e) {
        throw new DatabindingException(e);
    }
}
Also used : DatabindingException(com.sun.xml.ws.spi.db.DatabindingException) RepeatedElementBridge(com.sun.xml.ws.spi.db.RepeatedElementBridge) XMLStreamException(javax.xml.stream.XMLStreamException) Iterator(java.util.Iterator) WrapperComposite(com.sun.xml.ws.spi.db.WrapperComposite)

Example 2 with RepeatedElementBridge

use of com.sun.xml.ws.spi.db.RepeatedElementBridge in project metro-jax-ws by eclipse-ee4j.

the class WrapperBond method marshal.

@Override
public final void marshal(T object, ContentHandler contentHandler, AttachmentMarshaller am) throws JAXBException {
    WrapperComposite w = (WrapperComposite) object;
    Attributes att = new Attributes() {

        @Override
        public int getLength() {
            return 0;
        }

        @Override
        public String getURI(int index) {
            return null;
        }

        @Override
        public String getLocalName(int index) {
            return null;
        }

        @Override
        public String getQName(int index) {
            return null;
        }

        @Override
        public String getType(int index) {
            return null;
        }

        @Override
        public String getValue(int index) {
            return null;
        }

        @Override
        public int getIndex(String uri, String localName) {
            return 0;
        }

        @Override
        public int getIndex(String qName) {
            return 0;
        }

        @Override
        public String getType(String uri, String localName) {
            return null;
        }

        @Override
        public String getType(String qName) {
            return null;
        }

        @Override
        public String getValue(String uri, String localName) {
            return null;
        }

        @Override
        public String getValue(String qName) {
            return null;
        }
    };
    try {
        contentHandler.startElement(typeInfo.tagName.getNamespaceURI(), typeInfo.tagName.getLocalPart(), WrapperPrefix_ + typeInfo.tagName.getLocalPart(), att);
    } catch (SAXException e) {
        throw new JAXBException(e);
    }
    if (w.bridges != null)
        for (int i = 0; i < w.bridges.length; i++) {
            if (w.bridges[i] instanceof RepeatedElementBridge) {
                RepeatedElementBridge rbridge = (RepeatedElementBridge) w.bridges[i];
                for (Iterator itr = rbridge.collectionHandler().iterator(w.values[i]); itr.hasNext(); ) {
                    rbridge.marshal(itr.next(), contentHandler, am);
                }
            } else {
                w.bridges[i].marshal(w.values[i], contentHandler, am);
            }
        }
    try {
        contentHandler.endElement(typeInfo.tagName.getNamespaceURI(), typeInfo.tagName.getLocalPart(), null);
    } catch (SAXException e) {
        throw new JAXBException(e);
    }
// bridge.marshal(object, contentHandler, am);
}
Also used : RepeatedElementBridge(com.sun.xml.ws.spi.db.RepeatedElementBridge) JAXBException(jakarta.xml.bind.JAXBException) Attributes(org.xml.sax.Attributes) Iterator(java.util.Iterator) WrapperComposite(com.sun.xml.ws.spi.db.WrapperComposite) SAXException(org.xml.sax.SAXException)

Aggregations

RepeatedElementBridge (com.sun.xml.ws.spi.db.RepeatedElementBridge)2 WrapperComposite (com.sun.xml.ws.spi.db.WrapperComposite)2 Iterator (java.util.Iterator)2 DatabindingException (com.sun.xml.ws.spi.db.DatabindingException)1 JAXBException (jakarta.xml.bind.JAXBException)1 XMLStreamException (javax.xml.stream.XMLStreamException)1 Attributes (org.xml.sax.Attributes)1 SAXException (org.xml.sax.SAXException)1