Java Code Examples for org.apache.xmlbeans.XmlObject#getClass()

The following examples show how to use org.apache.xmlbeans.XmlObject#getClass() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: AbstractXmlDecoder.java    From arctic-sea with Apache License 2.0 6 votes vote down vote up
public DecoderKey getDecoderKey(XmlObject doc) {

        Node domNode = doc.getDomNode();
        String namespaceURI = domNode.getNamespaceURI();
        if (namespaceURI == null && domNode.getFirstChild() != null) {
            namespaceURI = domNode.getFirstChild().getNamespaceURI();
        }
        /*
         * if document starts with a comment, get next sibling (and ignore
         * initial comment)
         */
        if (namespaceURI == null &&
            domNode.getFirstChild() != null &&
            domNode.getFirstChild().getNextSibling() != null) {
            namespaceURI = domNode.getFirstChild().getNextSibling().getNamespaceURI();
        }

        return new XmlNamespaceDecoderKey(namespaceURI, doc.getClass());
    }
 
Example 2
Source File: AbstractXmlDecoder.java    From arctic-sea with Apache License 2.0 5 votes vote down vote up
public <T> T decodeXmlObject(XmlObject xbObject) throws DecodingException {
    DecoderKey key = getDecoderKey(xbObject);
    Decoder<T, XmlObject> decoder = getDecoderRepository().getDecoder(key);
    if (decoder == null) {
        DecoderKey schemaTypeKey = new XmlNamespaceDecoderKey(xbObject.schemaType().getName().getNamespaceURI(),
                                                              xbObject.getClass());
        decoder = getDecoderRepository().getDecoder(schemaTypeKey);
    }
    if (decoder == null) {
        throw new NoDecoderForKeyException(key);
    }
    return decoder.decode(xbObject);
}
 
Example 3
Source File: GetDataAvailabilityRequestDecoderTest.java    From arctic-sea with Apache License 2.0 5 votes vote down vote up
private Decoder<GetDataAvailabilityRequest, XmlObject> getDecoder(XmlObject document) {
    String namespace = XmlHelper.getNamespace(document);
    Class<? extends XmlObject> clazz = document.getClass();
    XmlNamespaceDecoderKey key = new XmlNamespaceDecoderKey(namespace, clazz);
    Decoder<GetDataAvailabilityRequest, XmlObject> decoder = decoderRepository.getDecoder(key);
    assertNotNull(decoder);
    return decoder;

}
 
Example 4
Source File: CodingHelper.java    From arctic-sea with Apache License 2.0 4 votes vote down vote up
public static DecoderKey getDecoderKey(final XmlObject doc) {
    return new XmlNamespaceDecoderKey(XmlHelper.getNamespace(doc), doc.getClass());
}