public void marshal(Object jaxbObject, XmlNode xmlNode) throws JAXBException { if ((xmlNode == null) || (jaxbObject == null)) throw new IllegalArgumentException(); getMarshaller().marshal(jaxbObject,createOutput(xmlNode)); }
Document doc = JAXBContextImpl.createDom(getContext().disableSecurityProcessing); ((DOMResult) result).setNode(doc); return new SAXOutput(new SAX2DOMEx(doc)); return createWriter(sr.getWriter()); else if (sr.getOutputStream() != null) return createWriter(sr.getOutputStream()); else if (sr.getSystemId() != null) { String fileURL = sr.getSystemId(); assert toBeClosed==null; toBeClosed = fos; return createWriter(fos); } catch (IOException e) { throw new MarshalException(e);
public void setProperty(String name, Object value) throws PropertyException { if (name == null) throw new IllegalArgumentException(Messages.NULL_PROPERTY_NAME.format()); // exclude RI properties that don't make sense for Binder if (excludeProperty(name)) { throw new PropertyException(name, value); } PropertyException pe = null; try { getMarshaller().setProperty(name, value); return; } catch (PropertyException p) { pe = p; } try { getUnmarshaller().setProperty(name, value); return; } catch (PropertyException p) { pe = p; } // replace the stacktrace - we don't want to see a trace // originating from Un|Marshaller.setProperty pe.setStackTrace(Thread.currentThread().getStackTrace()); throw pe; }
public void marshal(Marshaller _m, T t, Result result) throws JAXBException { MarshallerImpl m = (MarshallerImpl)_m; m.write(tagName,bi,t, m.createXmlOutput(result),m.createPostInitAction(result)); }
public XmlOutput createWriter(Writer w) { return createWriter(w, getEncoding()); }
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); }
public XmlOutput createWriter( OutputStream os, String encoding ) throws JAXBException { // UTF8XmlOutput does buffering on its own, and // otherwise createWriter(Writer) inserts a buffering, // so no point in doing a buffering here. if(encoding.equals("UTF-8")) { Encoded[] table = context.getUTF8NameTable(); final UTF8XmlOutput out; CharacterEscapeHandler ceh = createEscapeHandler(encoding); if(isFormattedOutput()) out = new IndentingUTF8XmlOutput(os, indent, table, ceh); else { if(c14nSupport) out = new C14nXmlOutput(os, table, context.c14nSupport, ceh); else out = new UTF8XmlOutput(os, table, ceh); } if(header!=null) out.setHeader(header); return out; } try { return createWriter( new OutputStreamWriter(os,getJavaEncoding(encoding)), encoding ); } catch( UnsupportedEncodingException e ) { throw new MarshalException( Messages.UNSUPPORTED_ENCODING.format(encoding), e ); } }
prewrite(out,isFragment(),postInitAction); serializer.childAsRoot(obj); postwrite(); } catch( SAXException e ) { throw new MarshalException(e); cleanUp();
public XmlOutput createWriter( Writer w, String encoding ) { // XMLWriter doesn't do buffering, so do it here if it looks like a good idea if(!(w instanceof BufferedWriter)) w = new BufferedWriter(w); assert toBeFlushed==null; toBeFlushed = w; CharacterEscapeHandler ceh = createEscapeHandler(encoding); XMLWriter xw; if(isFormattedOutput()) { DataWriter d = new DataWriter(w,encoding,ceh); d.setIndentStep(indent); xw=d; } else xw = new XMLWriter(w,encoding,ceh); xw.setXmlDecl(!isFragment()); xw.setHeader(header); return new SAXOutput(xw); // TODO: don't we need a better writer? }
@Override public void setProperty(String name, Object value) throws PropertyException { if( INDENT_STRING.equals(name) ) { checkString(name, value); indent = (String)value; return; checkBoolean(name, value); checkString(name, value); header = (String)value; return; checkBoolean(name,value); c14nSupport = (Boolean)value; return; checkBoolean(name,value); serializer.setObjectIdentityCycleDetection((Boolean)value); return;
private MarshallerImpl getMarshaller() { if(marshaller==null) marshaller = new MarshallerImpl(context,assoc); return marshaller; }
@Override protected BindingContext getContext(Marshaller m) { return newContext(((MarshallerImpl) m).getContext()); }
public XmlOutput createWriter( OutputStream os, String encoding ) throws JAXBException { // UTF8XmlOutput does buffering on its own, and // otherwise createWriter(Writer) inserts a buffering, // so no point in doing a buffering here. if(encoding.equals("UTF-8")) { Encoded[] table = context.getUTF8NameTable(); final UTF8XmlOutput out; CharacterEscapeHandler ceh = createEscapeHandler(encoding); if(isFormattedOutput()) out = new IndentingUTF8XmlOutput(os, indent, table, ceh); else { if(c14nSupport) out = new C14nXmlOutput(os, table, context.c14nSupport, ceh); else out = new UTF8XmlOutput(os, table, ceh); } if(header!=null) out.setHeader(header); return out; } try { return createWriter( new OutputStreamWriter(os,getJavaEncoding(encoding)), encoding ); } catch( UnsupportedEncodingException e ) { throw new MarshalException( Messages.UNSUPPORTED_ENCODING.format(encoding), e ); } }
public void marshal(Object target,Result result) throws JAXBException { write(target, createXmlOutput(result), createPostInitAction(result)); }
prewrite(out,isFragment(),postInitAction); serializer.childAsRoot(obj); postwrite(); } catch( SAXException e ) { throw new MarshalException(e); cleanUp();
public XmlOutput createWriter( Writer w, String encoding ) { // XMLWriter doesn't do buffering, so do it here if it looks like a good idea if(!(w instanceof BufferedWriter)) w = new BufferedWriter(w); assert toBeFlushed==null; toBeFlushed = w; CharacterEscapeHandler ceh = createEscapeHandler(encoding); XMLWriter xw; if(isFormattedOutput()) { DataWriter d = new DataWriter(w,encoding,ceh); d.setIndentStep(indent); xw=d; } else xw = new XMLWriter(w,encoding,ceh); xw.setXmlDecl(!isFragment()); xw.setHeader(header); return new SAXOutput(xw); // TODO: don't we need a better writer? }
/** * 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)); }
public XmlOutput createWriter(Writer w) { return createWriter(w, getEncoding()); }