/** * Create a <CODE>Marshaller</CODE> object that can be used to convert a * java content-tree into XML data. * * @return a <CODE>Marshaller</CODE> object * @throws JAXBException if an error was encountered while creating the * <code>Marshaller</code> object */ public Marshaller createMarshaller() throws JAXBException { return new MarshallerImpl(); }
public XMLWriter createWriter( OutputStream os ) throws JAXBException { return createWriter(os, getEncoding()); }
public XMLWriter createWriter( OutputStream os, String encoding ) throws JAXBException { try { return createWriter( new OutputStreamWriter(os,getJavaEncoding(encoding)), encoding ); } catch( UnsupportedEncodingException e ) { throw new MarshalException( Messages.format( Messages.UNSUPPORTED_ENCODING, encoding ), e ); } }
public XMLWriter createWriter( Writer w, String encoding ) throws JAXBException { CharacterEscapeHandler ceh = createEscapeHandler(encoding); if(isFormattedOutput()) { DataWriter d = new DataWriter(w,encoding,ceh); d.setIndentStep(indent); return d; } else return new XMLWriter(w,encoding,ceh); }
private void write( XMLSerializable obj, ContentHandler writer ) throws JAXBException { try { if( getSchemaLocation()!=null || getNoNSSchemaLocation()!=null ) { // if we need to add xsi:schemaLocation or its brother, // throw in the component to do that. writer = new SchemaLocationFilter( getSchemaLocation(), getNoNSSchemaLocation(), writer ); } SAXMarshaller serializer = new SAXMarshaller(writer,this); // set a DocumentLocator that doesn't provide any information writer.setDocumentLocator( new LocatorImpl() ); writer.startDocument(); obj.serializeElements(serializer); writer.endDocument(); } catch( SAXException e ) { throw new MarshalException(e); } }
write(so, ((SAXResult) result).getHandler()); return; Document doc = db.newDocument(); ((DOMResult) result).setNode(doc); write(so, new SAX2DOMEx(doc)); } catch (ParserConfigurationException pce) { throw new InternalError(); write(so, new SAX2DOMEx(node)); w = createWriter(sr.getWriter()); else if (sr.getOutputStream() != null) w = createWriter(sr.getOutputStream()); else if (sr.getSystemId() != null) { String fileURL = sr.getSystemId(); w = createWriter(new FileOutputStream(fileURL)); } catch (IOException e) { throw new MarshalException(e); throw new IllegalArgumentException(); write(so, w); return;
protected CharacterEscapeHandler createEscapeHandler( String encoding ) { if( escapeHandler!=null ) // user-specified one takes precedence. return escapeHandler; // otherwise try to find one from the encoding try { // try new JDK1.4 NIO return new NioEscapeHandler( getJavaEncoding(encoding) ); } catch( Throwable e ) { // if that fails, fall back to the dumb mode return DumbEscapeHandler.theInstance; } }
public void reportError( ValidationEvent ve ) throws AbortSerializationException { ValidationEventHandler handler; try { handler = owner.getEventHandler(); } catch( JAXBException e ) { throw new AbortSerializationException(e); } if(!handler.handleEvent(ve)) throw new AbortSerializationException(ve.getMessage()); }
public XMLWriter createWriter(Writer w) throws JAXBException{ return createWriter(w, getEncoding()); }