Java Code Examples for com.sun.xml.internal.bind.v2.runtime.JaxBeanInfo

The following examples show how to use com.sun.xml.internal.bind.v2.runtime.JaxBeanInfo. These examples are extracted from open source projects. 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
protected ArrayElementProperty(JAXBContextImpl grammar, RuntimeElementPropertyInfo prop) {
    super(grammar, prop, prop.getXmlName(), prop.isCollectionNillable());
    this.prop = prop;

    List<? extends RuntimeTypeRef> types = prop.getTypes();

    Name n = null;

    for (RuntimeTypeRef typeRef : types) {
        Class type = (Class)typeRef.getTarget().getType();
        if(type.isPrimitive())
            type = RuntimeUtil.primitiveToBox.get(type);

        JaxBeanInfo beanInfo = grammar.getOrCreate(typeRef.getTarget());
        TagAndType tt = new TagAndType(
                            grammar.nameBuilder.createElementName(typeRef.getTagName()),
                            beanInfo);
        typeMap.put(type,tt);
        refs.put(typeRef,beanInfo);
        if(typeRef.isNillable() && n==null)
            n = tt.tagName;
    }

    nillableTagName = n;
}
 
Example 2
protected final void serializeListBody(BeanT o, XMLSerializer w, ListT list) throws IOException, XMLStreamException, SAXException {
    ListIterator<ItemT> itr = lister.iterator(list, w);

    while(itr.hasNext()) {
        try {
            ItemT item = itr.next();
            if (item != null) {
                if(isMixed && item.getClass()==String.class) {
                    w.text((String)item,null);
                } else {
                    JaxBeanInfo bi = w.grammar.getBeanInfo(item,true);
                    if(bi.jaxbType==Object.class && domHandler!=null)
                        // even if 'v' is a DOM node, it always derive from Object,
                        // so the getBeanInfo returns BeanInfo for Object
                        w.writeDom(item,domHandler,o,fieldName);
                    else
                        bi.serializeRoot(item,w);
                }
            }
        } catch (JAXBException e) {
            w.reportError(fieldName,e);
            // recover by ignoring this item
        }
    }
}
 
Example 3
public void createBodyUnmarshaller(UnmarshallerChain chain, QNameMap<ChildLoader> loaders) {
    final int offset = chain.allocateOffset();

    Receiver recv = new ReceiverImpl(offset);

    for( QNameMap.Entry<JaxBeanInfo> n : expectedElements.entrySet() ) {
        final JaxBeanInfo beanInfo = n.getValue();
        loaders.put(n.nsUri,n.localName,new ChildLoader(beanInfo.getLoader(chain.context,true),recv));
    }

    if(isMixed) {
        // handler for processing mixed contents.
        loaders.put(TEXT_HANDLER,
            new ChildLoader(new MixedTextLoader(recv),null));
    }

    if(domHandler!=null) {
        loaders.put(CATCH_ALL,
            new ChildLoader(new WildcardLoader(domHandler,wcMode),recv));
    }
}
 
Example 4
public Object unmarshal0( Source source, JaxBeanInfo expectedType ) throws JAXBException {
    if (source instanceof SAXSource) {
        SAXSource ss = (SAXSource) source;

        XMLReader locReader = ss.getXMLReader();
        if (locReader == null) {
            locReader = getXMLReader();
        }

        return unmarshal0(locReader, ss.getInputSource(), expectedType);
    }
    if (source instanceof StreamSource) {
        return unmarshal0(getXMLReader(), streamSourceToInputSource((StreamSource) source), expectedType);
    }
    if (source instanceof DOMSource) {
        return unmarshal0(((DOMSource) source).getNode(), expectedType);
    }

    // we don't handle other types of Source
    throw new IllegalArgumentException();
}
 
Example 5
public void serializeBody(BeanT o, XMLSerializer w, Object outerPeer) throws SAXException, AccessorException, IOException, XMLStreamException {
    ValueT v = acc.get(o);
    if(v!=null) {
        try {
            JaxBeanInfo bi = w.grammar.getBeanInfo(v,true);
            if(bi.jaxbType==Object.class && domHandler!=null)
                // even if 'v' is a DOM node, it always derive from Object,
                // so the getBeanInfo returns BeanInfo for Object
                w.writeDom(v,domHandler,o,fieldName);
            else
                bi.serializeRoot(v,w);
        } catch (JAXBException e) {
            w.reportError(fieldName,e);
            // recover by ignoring this property
        }
    }
}
 
Example 6
/**
 * Receives the root element and determines how to start
 * unmarshalling.
 */
@Override
public void childElement(UnmarshallingContext.State state, TagName ea) throws SAXException {
    Loader loader = state.getContext().selectRootLoader(state,ea);
    if(loader!=null) {
        state.loader = loader;
        state.receiver = this;
        return;
    }

    // the registry doesn't know about this element.
    // try its xsi:type
    JaxBeanInfo beanInfo = XsiTypeLoader.parseXsiType(state, ea, null);
    if(beanInfo==null) {
        // we don't even know its xsi:type
        reportUnexpectedChildElement(ea,false);
        return;
    }

    state.loader = beanInfo.getLoader(null,false);
    state.prev.backup = new JAXBElement<Object>(ea.createQName(),Object.class,null);
    state.receiver = this;
}
 
Example 7
public ArrayReferenceNodeProperty(JAXBContextImpl p, RuntimeReferencePropertyInfo prop) {
    super(p, prop, prop.getXmlName(), prop.isCollectionNillable());

    for (RuntimeElement e : prop.getElements()) {
        JaxBeanInfo bi = p.getOrCreate(e);
        expectedElements.put( e.getElementName().getNamespaceURI(),e.getElementName().getLocalPart(), bi );
    }

    isMixed = prop.isMixed();

    if(prop.getWildcard()!=null) {
        domHandler = (DomHandler) ClassFactory.create(prop.getDOMHandler());
        wcMode = prop.getWildcard();
    } else {
        domHandler = null;
        wcMode = null;
    }
}
 
Example 8
Source Project: hottub   Source File: UnmarshallerImpl.java    License: GNU General Public License v2.0 6 votes vote down vote up
public final Object unmarshal0( Node node, JaxBeanInfo expectedType ) throws JAXBException {
    try {
        final DOMScanner scanner = new DOMScanner();

        InterningXmlVisitor handler = new InterningXmlVisitor(createUnmarshallerHandler(null,false,expectedType));
        scanner.setContentHandler(new SAXConnector(handler,scanner));

        if(node.getNodeType() == Node.ELEMENT_NODE) {
            scanner.scan((Element)node);
        } else if(node.getNodeType() == Node.DOCUMENT_NODE) {
            scanner.scan((Document)node);
        } else {
            throw new IllegalArgumentException("Unexpected node type: "+node);
        }

        Object retVal = handler.getContext().getResult();
        handler.getContext().clearResult();
        return retVal;
    } catch( SAXException e ) {
        throw createUnmarshalException(e);
    }
}
 
Example 9
Source Project: openjdk-8   Source File: UnmarshallerImpl.java    License: GNU General Public License v2.0 6 votes vote down vote up
public Object unmarshal0( Source source, JaxBeanInfo expectedType ) throws JAXBException {
    if (source instanceof SAXSource) {
        SAXSource ss = (SAXSource) source;

        XMLReader locReader = ss.getXMLReader();
        if (locReader == null) {
            locReader = getXMLReader();
        }

        return unmarshal0(locReader, ss.getInputSource(), expectedType);
    }
    if (source instanceof StreamSource) {
        return unmarshal0(getXMLReader(), streamSourceToInputSource((StreamSource) source), expectedType);
    }
    if (source instanceof DOMSource) {
        return unmarshal0(((DOMSource) source).getNode(), expectedType);
    }

    // we don't handle other types of Source
    throw new IllegalArgumentException();
}
 
Example 10
protected final void serializeListBody(BeanT o, XMLSerializer w, ListT list) throws IOException, XMLStreamException, SAXException {
    ListIterator<ItemT> itr = lister.iterator(list, w);

    while(itr.hasNext()) {
        try {
            ItemT item = itr.next();
            if (item != null) {
                if(isMixed && item.getClass()==String.class) {
                    w.text((String)item,null);
                } else {
                    JaxBeanInfo bi = w.grammar.getBeanInfo(item,true);
                    if(bi.jaxbType==Object.class && domHandler!=null)
                        // even if 'v' is a DOM node, it always derive from Object,
                        // so the getBeanInfo returns BeanInfo for Object
                        w.writeDom(item,domHandler,o,fieldName);
                    else
                        bi.serializeRoot(item,w);
                }
            }
        } catch (JAXBException e) {
            w.reportError(fieldName,e);
            // recover by ignoring this item
        }
    }
}
 
Example 11
/**
 * Receives the root element and determines how to start
 * unmarshalling.
 */
@Override
public void childElement(UnmarshallingContext.State state, TagName ea) throws SAXException {
    Loader loader = state.getContext().selectRootLoader(state,ea);
    if(loader!=null) {
        state.loader = loader;
        state.receiver = this;
        return;
    }

    // the registry doesn't know about this element.
    // try its xsi:type
    JaxBeanInfo beanInfo = XsiTypeLoader.parseXsiType(state, ea, null);
    if(beanInfo==null) {
        // we don't even know its xsi:type
        reportUnexpectedChildElement(ea,false);
        return;
    }

    state.loader = beanInfo.getLoader(null,false);
    state.prev.backup = new JAXBElement<Object>(ea.createQName(),Object.class,null);
    state.receiver = this;
}
 
Example 12
/**
 * Creates and configures a new unmarshalling pipe line.
 * Depending on the setting, we put a validator as a filter.
 *
 * @return
 *      A component that implements both {@link UnmarshallerHandler}
 *      and {@link ValidationEventHandler}. All the parsing errors
 *      should be reported to this error handler for the unmarshalling
 *      process to work correctly.
 *
 *      Also, returned handler expects all the XML names to be interned.
 *
 */
public final XmlVisitor createUnmarshallerHandler(InfosetScanner scanner, boolean inplace, JaxBeanInfo expectedType ) {

    coordinator.reset(scanner,inplace,expectedType,idResolver);
    XmlVisitor unmarshaller = coordinator;

    // delegate to JAXP 1.3 for validation if the client provided a schema
    if (schema != null) {
        unmarshaller = new ValidatingUnmarshaller(schema,unmarshaller);
    }

    if(attachmentUnmarshaller!=null && attachmentUnmarshaller.isXOPPackage()) {
        unmarshaller = new MTOMDecorator(this,unmarshaller,attachmentUnmarshaller);
    }

    return unmarshaller;
}
 
Example 13
Source Project: openjdk-8   Source File: UnmarshallerImpl.java    License: GNU General Public License v2.0 6 votes vote down vote up
public final Object unmarshal0( Node node, JaxBeanInfo expectedType ) throws JAXBException {
    try {
        final DOMScanner scanner = new DOMScanner();

        InterningXmlVisitor handler = new InterningXmlVisitor(createUnmarshallerHandler(null,false,expectedType));
        scanner.setContentHandler(new SAXConnector(handler,scanner));

        if(node.getNodeType() == Node.ELEMENT_NODE) {
            scanner.scan((Element)node);
        } else if(node.getNodeType() == Node.DOCUMENT_NODE) {
            scanner.scan((Document)node);
        } else {
            throw new IllegalArgumentException("Unexpected node type: "+node);
        }

        Object retVal = handler.getContext().getResult();
        handler.getContext().clearResult();
        return retVal;
    } catch( SAXException e ) {
        throw createUnmarshalException(e);
    }
}
 
Example 14
public SingleElementNodeProperty(JAXBContextImpl context, RuntimeElementPropertyInfo prop) {
    super(context,prop);
    acc = prop.getAccessor().optimize(context);
    this.prop = prop;

    QName nt = null;
    boolean nil = false;

    acceptedElements = new QName[prop.getTypes().size()];
    for( int i=0; i<acceptedElements.length; i++ )
        acceptedElements[i] = prop.getTypes().get(i).getTagName();

    for (RuntimeTypeRef e : prop.getTypes()) {
        JaxBeanInfo beanInfo = context.getOrCreate(e.getTarget());
        if(nt==null)    nt = e.getTagName();
        typeNames.put( beanInfo.jaxbType, new TagAndType(
            context.nameBuilder.createElementName(e.getTagName()),beanInfo) );
        nil |= e.isNillable();
    }

    nullTagName = context.nameBuilder.createElementName(nt);

    nillable = nil;
}
 
Example 15
protected final void serializeListBody(BeanT o, XMLSerializer w, ListT list) throws IOException, XMLStreamException, SAXException {
    ListIterator<ItemT> itr = lister.iterator(list, w);

    while(itr.hasNext()) {
        try {
            ItemT item = itr.next();
            if (item != null) {
                if(isMixed && item.getClass()==String.class) {
                    w.text((String)item,null);
                } else {
                    JaxBeanInfo bi = w.grammar.getBeanInfo(item,true);
                    if(bi.jaxbType==Object.class && domHandler!=null)
                        // even if 'v' is a DOM node, it always derive from Object,
                        // so the getBeanInfo returns BeanInfo for Object
                        w.writeDom(item,domHandler,o,fieldName);
                    else
                        bi.serializeRoot(item,w);
                }
            }
        } catch (JAXBException e) {
            w.reportError(fieldName,e);
            // recover by ignoring this item
        }
    }
}
 
Example 16
public ArrayReferenceNodeProperty(JAXBContextImpl p, RuntimeReferencePropertyInfo prop) {
    super(p, prop, prop.getXmlName(), prop.isCollectionNillable());

    for (RuntimeElement e : prop.getElements()) {
        JaxBeanInfo bi = p.getOrCreate(e);
        expectedElements.put( e.getElementName().getNamespaceURI(),e.getElementName().getLocalPart(), bi );
    }

    isMixed = prop.isMixed();

    if(prop.getWildcard()!=null) {
        domHandler = (DomHandler) ClassFactory.create(prop.getDOMHandler());
        wcMode = prop.getWildcard();
    } else {
        domHandler = null;
        wcMode = null;
    }
}
 
Example 17
protected final void serializeListBody(BeanT o, XMLSerializer w, ListT list) throws IOException, XMLStreamException, SAXException {
    ListIterator<ItemT> itr = lister.iterator(list, w);

    while(itr.hasNext()) {
        try {
            ItemT item = itr.next();
            if (item != null) {
                if(isMixed && item.getClass()==String.class) {
                    w.text((String)item,null);
                } else {
                    JaxBeanInfo bi = w.grammar.getBeanInfo(item,true);
                    if(bi.jaxbType==Object.class && domHandler!=null)
                        // even if 'v' is a DOM node, it always derive from Object,
                        // so the getBeanInfo returns BeanInfo for Object
                        w.writeDom(item,domHandler,o,fieldName);
                    else
                        bi.serializeRoot(item,w);
                }
            }
        } catch (JAXBException e) {
            w.reportError(fieldName,e);
            // recover by ignoring this item
        }
    }
}
 
Example 18
public void createBodyUnmarshaller(UnmarshallerChain chain, QNameMap<ChildLoader> loaders) {
    final int offset = chain.allocateOffset();

    Receiver recv = new ReceiverImpl(offset);

    for( QNameMap.Entry<JaxBeanInfo> n : expectedElements.entrySet() ) {
        final JaxBeanInfo beanInfo = n.getValue();
        loaders.put(n.nsUri,n.localName,new ChildLoader(beanInfo.getLoader(chain.context,true),recv));
    }

    if(isMixed) {
        // handler for processing mixed contents.
        loaders.put(TEXT_HANDLER,
            new ChildLoader(new MixedTextLoader(recv),null));
    }

    if(domHandler!=null) {
        loaders.put(CATCH_ALL,
            new ChildLoader(new WildcardLoader(domHandler,wcMode),recv));
    }
}
 
Example 19
Source Project: jdk8u60   Source File: UnmarshallingContext.java    License: GNU General Public License v2.0 6 votes vote down vote up
/**
 * Receives the root element and determines how to start
 * unmarshalling.
 */
@Override
public void childElement(UnmarshallingContext.State state, TagName ea) throws SAXException {
    Loader loader = state.getContext().selectRootLoader(state,ea);
    if(loader!=null) {
        state.loader = loader;
        state.receiver = this;
        return;
    }

    // the registry doesn't know about this element.
    // try its xsi:type
    JaxBeanInfo beanInfo = XsiTypeLoader.parseXsiType(state, ea, null);
    if(beanInfo==null) {
        // we don't even know its xsi:type
        reportUnexpectedChildElement(ea,false);
        return;
    }

    state.loader = beanInfo.getLoader(null,false);
    state.prev.backup = new JAXBElement<Object>(ea.createQName(),Object.class,null);
    state.receiver = this;
}
 
Example 20
/**
 * Receives the root element and determines how to start
 * unmarshalling.
 */
@Override
public void childElement(UnmarshallingContext.State state, TagName ea) throws SAXException {
    Loader loader = state.getContext().selectRootLoader(state,ea);
    if(loader!=null) {
        state.loader = loader;
        state.receiver = this;
        return;
    }

    // the registry doesn't know about this element.
    // try its xsi:type
    JaxBeanInfo beanInfo = XsiTypeLoader.parseXsiType(state, ea, null);
    if(beanInfo==null) {
        // we don't even know its xsi:type
        reportUnexpectedChildElement(ea,false);
        return;
    }

    state.loader = beanInfo.getLoader(null,false);
    state.prev.backup = new JAXBElement<Object>(ea.createQName(),Object.class,null);
    state.receiver = this;
}
 
Example 21
Source Project: jdk8u60   Source File: UnmarshallerImpl.java    License: GNU General Public License v2.0 6 votes vote down vote up
/**
 * Creates and configures a new unmarshalling pipe line.
 * Depending on the setting, we put a validator as a filter.
 *
 * @return
 *      A component that implements both {@link UnmarshallerHandler}
 *      and {@link ValidationEventHandler}. All the parsing errors
 *      should be reported to this error handler for the unmarshalling
 *      process to work correctly.
 *
 *      Also, returned handler expects all the XML names to be interned.
 *
 */
public final XmlVisitor createUnmarshallerHandler(InfosetScanner scanner, boolean inplace, JaxBeanInfo expectedType ) {

    coordinator.reset(scanner,inplace,expectedType,idResolver);
    XmlVisitor unmarshaller = coordinator;

    // delegate to JAXP 1.3 for validation if the client provided a schema
    if (schema != null) {
        unmarshaller = new ValidatingUnmarshaller(schema,unmarshaller);
    }

    if(attachmentUnmarshaller!=null && attachmentUnmarshaller.isXOPPackage()) {
        unmarshaller = new MTOMDecorator(this,unmarshaller,attachmentUnmarshaller);
    }

    return unmarshaller;
}
 
Example 22
Source Project: jdk8u60   Source File: UnmarshallerImpl.java    License: GNU General Public License v2.0 6 votes vote down vote up
public final Object unmarshal0( Node node, JaxBeanInfo expectedType ) throws JAXBException {
    try {
        final DOMScanner scanner = new DOMScanner();

        InterningXmlVisitor handler = new InterningXmlVisitor(createUnmarshallerHandler(null,false,expectedType));
        scanner.setContentHandler(new SAXConnector(handler,scanner));

        if(node.getNodeType() == Node.ELEMENT_NODE) {
            scanner.scan((Element)node);
        } else if(node.getNodeType() == Node.DOCUMENT_NODE) {
            scanner.scan((Document)node);
        } else {
            throw new IllegalArgumentException("Unexpected node type: "+node);
        }

        Object retVal = handler.getContext().getResult();
        handler.getContext().clearResult();
        return retVal;
    } catch( SAXException e ) {
        throw createUnmarshalException(e);
    }
}
 
Example 23
/**
 * Creates and configures a new unmarshalling pipe line.
 * Depending on the setting, we put a validator as a filter.
 *
 * @return
 *      A component that implements both {@link UnmarshallerHandler}
 *      and {@link ValidationEventHandler}. All the parsing errors
 *      should be reported to this error handler for the unmarshalling
 *      process to work correctly.
 *
 *      Also, returned handler expects all the XML names to be interned.
 *
 */
public final XmlVisitor createUnmarshallerHandler(InfosetScanner scanner, boolean inplace, JaxBeanInfo expectedType ) {

    coordinator.reset(scanner,inplace,expectedType,idResolver);
    XmlVisitor unmarshaller = coordinator;

    // delegate to JAXP 1.3 for validation if the client provided a schema
    if (schema != null) {
        unmarshaller = new ValidatingUnmarshaller(schema,unmarshaller);
    }

    if(attachmentUnmarshaller!=null && attachmentUnmarshaller.isXOPPackage()) {
        unmarshaller = new MTOMDecorator(this,unmarshaller,attachmentUnmarshaller);
    }

    return unmarshaller;
}
 
Example 24
public SingleElementNodeProperty(JAXBContextImpl context, RuntimeElementPropertyInfo prop) {
    super(context,prop);
    acc = prop.getAccessor().optimize(context);
    this.prop = prop;

    QName nt = null;
    boolean nil = false;

    acceptedElements = new QName[prop.getTypes().size()];
    for( int i=0; i<acceptedElements.length; i++ )
        acceptedElements[i] = prop.getTypes().get(i).getTagName();

    for (RuntimeTypeRef e : prop.getTypes()) {
        JaxBeanInfo beanInfo = context.getOrCreate(e.getTarget());
        if(nt==null)    nt = e.getTagName();
        typeNames.put( beanInfo.jaxbType, new TagAndType(
            context.nameBuilder.createElementName(e.getTagName()),beanInfo) );
        nil |= e.isNillable();
    }

    nullTagName = context.nameBuilder.createElementName(nt);

    nillable = nil;
}
 
Example 25
public SingleElementNodeProperty(JAXBContextImpl context, RuntimeElementPropertyInfo prop) {
    super(context,prop);
    acc = prop.getAccessor().optimize(context);
    this.prop = prop;

    QName nt = null;
    boolean nil = false;

    acceptedElements = new QName[prop.getTypes().size()];
    for( int i=0; i<acceptedElements.length; i++ )
        acceptedElements[i] = prop.getTypes().get(i).getTagName();

    for (RuntimeTypeRef e : prop.getTypes()) {
        JaxBeanInfo beanInfo = context.getOrCreate(e.getTarget());
        if(nt==null)    nt = e.getTagName();
        typeNames.put( beanInfo.jaxbType, new TagAndType(
            context.nameBuilder.createElementName(e.getTagName()),beanInfo) );
        nil |= e.isNillable();
    }

    nullTagName = context.nameBuilder.createElementName(nt);

    nillable = nil;
}
 
Example 26
public ArrayReferenceNodeProperty(JAXBContextImpl p, RuntimeReferencePropertyInfo prop) {
    super(p, prop, prop.getXmlName(), prop.isCollectionNillable());

    for (RuntimeElement e : prop.getElements()) {
        JaxBeanInfo bi = p.getOrCreate(e);
        expectedElements.put( e.getElementName().getNamespaceURI(),e.getElementName().getLocalPart(), bi );
    }

    isMixed = prop.isMixed();

    if(prop.getWildcard()!=null) {
        domHandler = (DomHandler) ClassFactory.create(prop.getDOMHandler());
        wcMode = prop.getWildcard();
    } else {
        domHandler = null;
        wcMode = null;
    }
}
 
Example 27
protected ArrayElementProperty(JAXBContextImpl grammar, RuntimeElementPropertyInfo prop) {
    super(grammar, prop, prop.getXmlName(), prop.isCollectionNillable());
    this.prop = prop;

    List<? extends RuntimeTypeRef> types = prop.getTypes();

    Name n = null;

    for (RuntimeTypeRef typeRef : types) {
        Class type = (Class)typeRef.getTarget().getType();
        if(type.isPrimitive())
            type = RuntimeUtil.primitiveToBox.get(type);

        JaxBeanInfo beanInfo = grammar.getOrCreate(typeRef.getTarget());
        TagAndType tt = new TagAndType(
                            grammar.nameBuilder.createElementName(typeRef.getTagName()),
                            beanInfo);
        typeMap.put(type,tt);
        refs.put(typeRef,beanInfo);
        if(typeRef.isNillable() && n==null)
            n = tt.tagName;
    }

    nillableTagName = n;
}
 
Example 28
public void createBodyUnmarshaller(UnmarshallerChain chain, QNameMap<ChildLoader> loaders) {
    final int offset = chain.allocateOffset();

    Receiver recv = new ReceiverImpl(offset);

    for( QNameMap.Entry<JaxBeanInfo> n : expectedElements.entrySet() ) {
        final JaxBeanInfo beanInfo = n.getValue();
        loaders.put(n.nsUri,n.localName,new ChildLoader(beanInfo.getLoader(chain.context,true),recv));
    }

    if(isMixed) {
        // handler for processing mixed contents.
        loaders.put(TEXT_HANDLER,
            new ChildLoader(new MixedTextLoader(recv),null));
    }

    if(domHandler!=null) {
        loaders.put(CATCH_ALL,
            new ChildLoader(new WildcardLoader(domHandler,wcMode),recv));
    }
}
 
Example 29
public void createBodyUnmarshaller(UnmarshallerChain chain, QNameMap<ChildLoader> loaders) {
    final int offset = chain.allocateOffset();

    Receiver recv = new ReceiverImpl(offset);

    for( QNameMap.Entry<JaxBeanInfo> n : expectedElements.entrySet() ) {
        final JaxBeanInfo beanInfo = n.getValue();
        loaders.put(n.nsUri,n.localName,new ChildLoader(beanInfo.getLoader(chain.context,true),recv));
    }

    if(isMixed) {
        // handler for processing mixed contents.
        loaders.put(TEXT_HANDLER,
            new ChildLoader(new MixedTextLoader(recv),null));
    }

    if(domHandler!=null) {
        loaders.put(CATCH_ALL,
            new ChildLoader(new WildcardLoader(domHandler,wcMode),recv));
    }
}
 
Example 30
Source Project: hottub   Source File: UnmarshallingContext.java    License: GNU General Public License v2.0 6 votes vote down vote up
/**
 * Receives the root element and determines how to start
 * unmarshalling.
 */
@Override
public void childElement(UnmarshallingContext.State state, TagName ea) throws SAXException {
    Loader loader = state.getContext().selectRootLoader(state,ea);
    if(loader!=null) {
        state.loader = loader;
        state.receiver = this;
        return;
    }

    // the registry doesn't know about this element.
    // try its xsi:type
    JaxBeanInfo beanInfo = XsiTypeLoader.parseXsiType(state, ea, null);
    if(beanInfo==null) {
        // we don't even know its xsi:type
        reportUnexpectedChildElement(ea,false);
        return;
    }

    state.loader = beanInfo.getLoader(null,false);
    state.prev.backup = new JAXBElement<Object>(ea.createQName(),Object.class,null);
    state.receiver = this;
}