This one works for both leaves and nodes, scalars and arrays.
Implements {@link Comparable} so that it can be sorted lexicographically. @author Kohsuke Kawaguchi (kk@kohsuke.org)
8889909192939495969798
protected AccessorFactory createAccessorFactory(Class clazz) { XmlAccessorFactory factoryAnn; AccessorFactory accFactory = null; // user providing class to be used. JAXBContextImpl context = ((RuntimeModelBuilder) builder).context; if (context!=null && context.xmlAccessorFactorySupport){ factoryAnn = findXmlAccessorFactoryAnnotation(clazz); if (factoryAnn != null) { try {
1030103110321033103410351036103710381039104010411042104310441045
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; }
51525354555657585960616263
super(true); this.defaultBeanInfo = defaultBeanInfo; } 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.loader = loader; loader.startElement(state,ea); }
6263646566676869707172
loader.startElement(state,ea); } /*pacakge*/ static JaxBeanInfo parseXsiType(UnmarshallingContext.State state, TagName ea, @Nullable JaxBeanInfo defaultBeanInfo) throws SAXException { UnmarshallingContext context = state.getContext(); JaxBeanInfo beanInfo = null; // look for @xsi:type Attributes atts = ea.atts; int idx = atts.getIndex(WellKnownNamespace.XML_SCHEMA_INSTANCE,"type");
142143144145146147148149150151152
if(id==ID.ID) t = new IDTransducerImpl(t); MimeType emt = src.getExpectedMimeType(); if(emt!=null) t = new MimeTypedTransducer(t,emt); if(src.inlineBinaryData()) t = new InlineBinaryTransducer(t); if(src.getSchemaType()!=null) {
102103104105106107108
getMarshaller().marshal(jaxbObject,createOutput(xmlNode)); } // TODO move this to a sub class once we support something other than W3C DOM private DOMOutput createOutput(XmlNode xmlNode) { return new DOMOutput((Node)xmlNode,assoc); }
821822823824825826827828829830831
setThreadAffinity(); pushCoordinator(); nsContext.reset(); nse = nsContext.getCurrent(); if(attachmentMarshaller!=null && attachmentMarshaller.isXOPPackage()) out = new MTOMXmlOutput(out); this.out = out; objectsWithId.clear(); idReferencedObjects.clear(); textHasAlreadyPrinted = false; seenRoot = false;
186187188189190191192193194
public AttachmentMarshaller attachmentMarshaller; /*package*/ XMLSerializer( MarshallerImpl _owner ) { this.marshaller = _owner; this.grammar = marshaller.context; nsContext = new NamespaceContextImpl(this); nameList = marshaller.context.nameList; knownUri2prefixIndexMap = new int[nameList.namespaceURIs.length]; }
89909192939495
m.write(tagName,bi,t,m.createWriter(output),pia); } public void marshal(Marshaller _m, T t, Node output) throws JAXBException { MarshallerImpl m = (MarshallerImpl)_m; m.write(tagName,bi,t,new SAXOutput(new SAX2DOMEx(output)),new DomPostInitAction(output,m.serializer)); }
949596979899100
m.write(tagName,bi,t,new SAXOutput(new SAX2DOMEx(output)),new DomPostInitAction(output,m.serializer)); } public void marshal(Marshaller _m, T t, ContentHandler contentHandler) throws JAXBException { MarshallerImpl m = (MarshallerImpl)_m; m.write(tagName,bi,t,new SAXOutput(contentHandler),null); }