void marshal(InMemory o, XMLSerializer out) throws IOException, SAXException, XMLStreamException { try { core.marshal(_adaptM( XMLSerializer.getInstance(), o ), out ); } catch (MarshalException e) { // recover from error by not marshalling this element. } } }
@Override public CharSequence print(V o) throws AccessorException { XMLSerializer w = XMLSerializer.getInstance(); MimeType old = w.setExpectedMimeType(expectedMimeType); try { return core.print(o); } finally { w.setExpectedMimeType(old); } }
public final void serializeURIs(BeanT bean, XMLSerializer target) throws SAXException { // TODO: maybe we should create another LeafBeanInfoImpl class for // context-dependent xducers? if(xducer.useNamespace()) { try { xducer.declareNamespace(bean,target); } catch (AccessorException e) { target.reportError(null,e); } } }
public String next() throws SAXException, JAXBException { last = i.next(); String id = context.grammar.getBeanInfo(last,true).getId(last,context); if(id==null) { context.errorMissingId(last); } return id; } }
@Override public CharSequence print(V o) throws AccessorException { XMLSerializer w = XMLSerializer.getInstance(); QName old = w.setSchemaType(schemaType); try { return core.print(o); } finally { w.setSchemaType(old); } }
public void serializeItem(JaxBeanInfo bi, ItemT item, XMLSerializer w) throws SAXException, AccessorException, IOException, XMLStreamException { xducer.declareNamespace(item,w); w.endNamespaceDecls(item); w.endAttributes(); // this is leaf, so by definition there's no type substitution // if there's, we'll be using ArrayElementNodeProperty xducer.writeText(w,item,fieldName); } }
public void marshal(Marshaller _m, T t, OutputStream output, NamespaceContext nsContext) throws JAXBException { MarshallerImpl m = (MarshallerImpl)_m; Runnable pia = null; if(nsContext!=null) pia = new StAXPostInitAction(nsContext,m.serializer); m.write(tagName,bi,t,m.createWriter(output),pia); }
private OnWire adaptM(Marshaller m,InMemory v) throws JAXBException { XMLSerializer serializer = ((MarshallerImpl)m).serializer; serializer.pushCoordinator(); try { return _adaptM(serializer, v); } finally { serializer.popCoordinator(); } }
/** * Gets the ID value from an identifiable object. */ private String getIdFromObject(Object identifiableObject) throws SAXException, JAXBException { return grammar.getBeanInfo(identifiableObject,true).getId(identifiableObject,this); }
@Override public void writeText(XMLSerializer w, V o, String fieldName) throws IOException, SAXException, XMLStreamException, AccessorException { QName old = w.setSchemaType(schemaType); try { core.writeText(w,o,fieldName); } finally { w.setSchemaType(old); } }
@Override public QName getTypeName(BeanT instance) { QName tn = xducer.getTypeName(instance); if(tn!=null) return tn; // rely on default return super.getTypeName(instance); }
@Override public void writeLeafElement(XMLSerializer w, Name tagName, V o, String fieldName) throws IOException, SAXException, XMLStreamException, AccessorException { MimeType old = w.setExpectedMimeType(expectedMimeType); try { core.writeLeafElement(w, tagName, o, fieldName); } finally { w.setExpectedMimeType(old); } } }
@Override public void writeLeafElement(XMLSerializer w, Name tagName, V o, String fieldName) throws IOException, SAXException, XMLStreamException, AccessorException { QName old = w.setSchemaType(schemaType); try { core.writeLeafElement(w, tagName, o, fieldName); } finally { w.setSchemaType(old); } } }
@Override public void writeText(XMLSerializer w, V o, String fieldName) throws IOException, SAXException, XMLStreamException, AccessorException { MimeType old = w.setExpectedMimeType(expectedMimeType); try { core.writeText(w, o, fieldName); } finally { w.setExpectedMimeType(old); } }
@Override public void writeText(XMLSerializer w, V o, String fieldName) throws IOException, SAXException, XMLStreamException, AccessorException { boolean old = w.setInlineBinaryFlag(true); try { core.writeText(w,o,fieldName); } finally { w.setInlineBinaryFlag(old); } }
@Override public void writeLeafElement(XMLSerializer w, Name tagName, V o, String fieldName) throws IOException, SAXException, XMLStreamException, AccessorException { boolean old = w.setInlineBinaryFlag(true); try { core.writeLeafElement(w, tagName, o, fieldName); } finally { w.setInlineBinaryFlag(old); } } }
public final void serializeBody(BeanT bean, XMLSerializer w) throws SAXException, IOException, XMLStreamException { // most of the times leaves are printed as leaf element/attribute property, // so this code is only used for example when you have multiple XmlElement on a property // and some of them are leaves. Hence this doesn't need to be super-fast. try { xducer.writeText(w,bean,null); } catch (AccessorException e) { w.reportError(null,e); } }
/** * Marshals to {@link OutputStream} with the given in-scope namespaces * taken into account. * * @since 2.1.5 */ public void marshal(Object obj, OutputStream out, NamespaceContext inscopeNamespace) throws JAXBException { write(obj, createWriter(out), new StAXPostInitAction(inscopeNamespace,serializer)); }