public ArrayLoader(JAXBContextImpl owner) { super(false); itemLoader = itemBeanInfo.getLoader(owner,true); }
/** * Based on the tag name, determine what object to unmarshal, * and then set a new object and its loader to the current unmarshaller state. * * @return * null if the given name pair is not recognized. */ public final Loader selectRootLoader( UnmarshallingContext.State state, TagName tag ) { JaxBeanInfo beanInfo = rootMap.get(tag.uri,tag.local); if(beanInfo==null) return null; return beanInfo.getLoader(this,true); }
/** * Receives the root element and determines how to start * unmarshalling. */ @Override public void childElement(UnmarshallingContext.State state, TagName ea) { UnmarshallingContext context = state.getContext(); // unmarshals the specified type QName qn = new QName(ea.uri,ea.local); state.prev.target = new JAXBElement(qn,context.expectedType.jaxbType,null,null); state.receiver = this; // this is bit wasteful, as in theory we should have each expectedType keep // nillable version --- but that increases the combination from two to four, // which adds the resident memory footprint. Since XsiNilLoader is small, // I intentionally allocate a new instance freshly. state.loader = new XsiNilLoader(context.expectedType.getLoader(null,true)); }
public void startElement(UnmarshallingContext.State state, TagName ea) throws SAXException { JaxBeanInfo beanInfo = parseXsiType(state,ea,defaultBeanInfo); if(beanInfo==null) beanInfo = defaultBeanInfo; Loader loader = beanInfo.getLoader(null,false); state.setLoader(loader); loader.startElement(state,ea); }
/** * Creates a loader handler that unmarshals the body of the item. * * <p> * This will be sandwiched into <item> ... </item>. * * <p> * When unmarshalling the body of item, the Pack of {@link Lister} is available * as the handler state. * * @param chain * @param typeRef */ private Loader createItemUnmarshaller(UnmarshallerChain chain, RuntimeTypeRef typeRef) { if(PropertyFactory.isLeaf(typeRef.getSource())) { final Transducer xducer = typeRef.getTransducer(); return new TextLoader(xducer); } else { return refs.get(typeRef).getLoader(chain.context,true); } }
/** * 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; }
public void buildChildElementUnmarshallers(UnmarshallerChain chain, QNameMap<ChildLoader> handlers) { JAXBContextImpl context = chain.context; for (TypeRef<Type,Class> e : prop.getTypes()) { JaxBeanInfo bi = context.getOrCreate((RuntimeTypeInfo) e.getTarget()); // if the expected Java type is already final, type substitution won't really work anyway. // this also traps cases like trying to substitute xsd:long element with xsi:type='xsd:int' Loader l = bi.getLoader(context,!Modifier.isFinal(bi.jaxbType.getModifiers())); if(e.getDefaultValue()!=null) l = new DefaultValueLoaderDecorator(l,e.getDefaultValue()); if(nillable || chain.context.allNillable) l = new XsiNilLoader.Single(l,acc); handlers.put( e.getTagName(), new ChildLoader(l,acc)); } }
public void buildChildElementUnmarshallers(UnmarshallerChain chain, QNameMap<ChildLoader> handlers) { for (QNameMap.Entry<JaxBeanInfo> n : expectedElements.entrySet()) handlers.put(n.nsUri,n.localName, new ChildLoader(n.getValue().getLoader(chain.context,true),acc)); if(domHandler!=null) handlers.put(CATCH_ALL,new ChildLoader(new WildcardLoader(domHandler,wcMode),acc)); }
/** * On top of {@link JAXBContextImpl#selectRootLoader(State, TagName)}, * this method also consults {@link ClassResolver}. * * @throws SAXException * if {@link ValidationEventHandler} reported a failure. */ public Loader selectRootLoader(State state, TagName tag) throws SAXException { try { Loader l = getJAXBContext().selectRootLoader(state, tag); if(l!=null) return l; if(classResolver!=null) { Class<?> clazz = classResolver.resolveElementName(tag.uri, tag.local); if(clazz!=null) { JAXBContextImpl enhanced = getJAXBContext().createAugmented(clazz); JaxBeanInfo<?> bi = enhanced.getBeanInfo(clazz); return bi.getLoader(enhanced,true); } } } catch (RuntimeException e) { throw e; } catch (Exception e) { handleError(e); } return null; }
public ArrayLoader(JAXBContextImpl owner) { super(false); itemLoader = itemBeanInfo.getLoader(owner,true); }
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)); } }
/** * Based on the tag name, determine what object to unmarshal, * and then set a new object and its loader to the current unmarshaller state. * * @return * null if the given name pair is not recognized. */ public final Loader selectRootLoader( UnmarshallingContext.State state, TagName tag ) { JaxBeanInfo beanInfo = rootMap.get(tag.uri,tag.local); if(beanInfo==null) return null; return beanInfo.getLoader(this,true); }
/** * Receives the root element and determines how to start * unmarshalling. */ @Override public void childElement(UnmarshallingContext.State state, TagName ea) { UnmarshallingContext context = state.getContext(); // unmarshals the specified type QName qn = new QName(ea.uri,ea.local); state.prev.target = new JAXBElement(qn,context.expectedType.jaxbType,null,null); state.receiver = this; // this is bit wasteful, as in theory we should have each expectedType keep // nillable version --- but that increases the combination from two to four, // which adds the resident memory footprint. Since XsiNilLoader is small, // I intentionally allocate a new instance freshly. state.loader = new XsiNilLoader(context.expectedType.getLoader(null,true)); }
public void startElement(UnmarshallingContext.State state, TagName ea) throws SAXException { JaxBeanInfo beanInfo = parseXsiType(state,ea,defaultBeanInfo); if(beanInfo==null) beanInfo = defaultBeanInfo; Loader loader = beanInfo.getLoader(null,false); state.setLoader(loader); loader.startElement(state,ea); }
/** * Creates a loader handler that unmarshals the body of the item. * * <p> * This will be sandwiched into <item> ... </item>. * * <p> * When unmarshalling the body of item, the Pack of {@link Lister} is available * as the handler state. * * @param chain * @param typeRef */ private Loader createItemUnmarshaller(UnmarshallerChain chain, RuntimeTypeRef typeRef) { if(PropertyFactory.isLeaf(typeRef.getSource())) { final Transducer xducer = typeRef.getTransducer(); return new TextLoader(xducer); } else { return refs.get(typeRef).getLoader(chain.context,true); } }
public void buildChildElementUnmarshallers(UnmarshallerChain chain, QNameMap<ChildLoader> handlers) { JAXBContextImpl context = chain.context; for (TypeRef<Type,Class> e : prop.getTypes()) { JaxBeanInfo bi = context.getOrCreate((RuntimeTypeInfo) e.getTarget()); // if the expected Java type is already final, type substitution won't really work anyway. // this also traps cases like trying to substitute xsd:long element with xsi:type='xsd:int' Loader l = bi.getLoader(context,!Modifier.isFinal(bi.jaxbType.getModifiers())); if(e.getDefaultValue()!=null) l = new DefaultValueLoaderDecorator(l,e.getDefaultValue()); if(nillable || chain.context.allNillable) l = new XsiNilLoader.Single(l,acc); handlers.put( e.getTagName(), new ChildLoader(l,acc)); } }
public void buildChildElementUnmarshallers(UnmarshallerChain chain, QNameMap<ChildLoader> handlers) { for (QNameMap.Entry<JaxBeanInfo> n : expectedElements.entrySet()) handlers.put(n.nsUri,n.localName, new ChildLoader(n.getValue().getLoader(chain.context,true),acc)); if(domHandler!=null) handlers.put(CATCH_ALL,new ChildLoader(new WildcardLoader(domHandler,wcMode),acc)); }
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)); } }