writer = new IndentingXMLStreamWriter(factory.createXMLStreamWriter(out, charSet)); } else { writer = factory.createXMLStreamWriter(out, charSet);
/** * Method write * * @param writer * @param redbackRoleModel */ public void write(Writer writer, RedbackRoleModel redbackRoleModel) throws java.io.IOException, XMLStreamException { XMLOutputFactory factory = XMLOutputFactory.newInstance(); boolean supportWindowsLineEndings = false; if ( factory.isPropertySupported( "com.ctc.wstx.outputEscapeCr" ) ) { factory.setProperty( "com.ctc.wstx.outputEscapeCr", Boolean.FALSE ); supportWindowsLineEndings = true; } if ( factory.isPropertySupported( "org.codehaus.stax2.automaticEmptyElements" ) ) { factory.setProperty( "org.codehaus.stax2.automaticEmptyElements", Boolean.FALSE ); } IndentingXMLStreamWriter serializer = new IndentingXMLStreamWriter( factory.createXMLStreamWriter( writer ) ); if ( supportWindowsLineEndings ) { serializer.setNewLine( serializer.getLineSeparator() ); } serializer.writeStartDocument( redbackRoleModel.getModelEncoding(), "1.0" ); writeRedbackRoleModel( redbackRoleModel, "redback-role-model", serializer ); serializer.writeEndDocument(); } //-- void write(Writer, RedbackRoleModel)
protected XMLStreamWriter filter(XMLStreamWriter writer) { if (indenting) { IndentingXMLStreamWriter indenter = new IndentingXMLStreamWriter(writer); indenter.setNewLine(newLine); indenter.setIndent(indent); writer = indenter; } return writer; }
private static XMLStreamWriter createXmlStreamWriter(ExportOptions options, OutputStream os) throws XMLStreamException { XMLStreamWriter writer = XML_OUTPUT_FACTORY_SUPPLIER.get().createXMLStreamWriter(os, StandardCharsets.UTF_8.toString()); if (options.isIndent()) { IndentingXMLStreamWriter indentingWriter = new IndentingXMLStreamWriter(writer); indentingWriter.setIndent(INDENT); writer = indentingWriter; } return writer; }
/** * @return System.getProperty("line.separator"); or * {@link #NORMAL_END_OF_LINE} if that fails. */ public static String getLineSeparator() { return IndentingXMLStreamWriter.getLineSeparator(); }
/** * Method write * * @param writer * @param rbacDatabase */ public void write(Writer writer, RbacDatabase rbacDatabase) throws java.io.IOException, XMLStreamException { XMLOutputFactory factory = XMLOutputFactory.newInstance(); boolean supportWindowsLineEndings = false; if ( factory.isPropertySupported( "com.ctc.wstx.outputEscapeCr" ) ) { factory.setProperty( "com.ctc.wstx.outputEscapeCr", Boolean.FALSE ); supportWindowsLineEndings = true; } if ( factory.isPropertySupported( "org.codehaus.stax2.automaticEmptyElements" ) ) { factory.setProperty( "org.codehaus.stax2.automaticEmptyElements", Boolean.FALSE ); } IndentingXMLStreamWriter serializer = new IndentingXMLStreamWriter( factory.createXMLStreamWriter( writer ) ); if ( supportWindowsLineEndings ) { serializer.setNewLine( serializer.getLineSeparator() ); } serializer.writeStartDocument( rbacDatabase.getModelEncoding(), "1.0" ); writeRbacDatabase( rbacDatabase, "rbacDatabase", serializer ); serializer.writeEndDocument(); } //-- void write(Writer, RbacDatabase)
/** * Method write * * @param writer * @param model */ public void write(Writer writer, Model model) throws java.io.IOException, XMLStreamException { XMLOutputFactory factory = XMLOutputFactory.newInstance(); boolean supportWindowsLineEndings = false; if ( factory.isPropertySupported( "com.ctc.wstx.outputEscapeCr" ) ) { factory.setProperty( "com.ctc.wstx.outputEscapeCr", Boolean.FALSE ); supportWindowsLineEndings = true; } if ( factory.isPropertySupported( "org.codehaus.stax2.automaticEmptyElements" ) ) { factory.setProperty( "org.codehaus.stax2.automaticEmptyElements", Boolean.FALSE ); } IndentingXMLStreamWriter serializer = new IndentingXMLStreamWriter( factory.createXMLStreamWriter( writer ) ); if ( supportWindowsLineEndings ) { serializer.setNewLine( serializer.getLineSeparator() ); } serializer.writeStartDocument( model.getModelEncoding(), "1.0" ); writeModel( model, "project", serializer ); serializer.writeEndDocument(); } //-- void write(Writer, Model)
/** * Return an XMLStreamWriter which indents the xml * (ideally XMLOutputFactory would support a property which would set this up for us to avoid a dependency * on a com.sun.xml class, but it doesn't for the present time appear to do so) */ public static XMLStreamWriter getIndentingXmlStreamWriter(Writer writer) throws XMLStreamException, IOException { XMLOutputFactory f = XMLOutputFactory.newInstance(); return new IndentingXMLStreamWriter(f.createXMLStreamWriter(writer)); } }
/** * Method write * * @param writer * @param userDatabase */ public void write(Writer writer, UserDatabase userDatabase) throws java.io.IOException, XMLStreamException { XMLOutputFactory factory = XMLOutputFactory.newInstance(); boolean supportWindowsLineEndings = false; if ( factory.isPropertySupported( "com.ctc.wstx.outputEscapeCr" ) ) { factory.setProperty( "com.ctc.wstx.outputEscapeCr", Boolean.FALSE ); supportWindowsLineEndings = true; } if ( factory.isPropertySupported( "org.codehaus.stax2.automaticEmptyElements" ) ) { factory.setProperty( "org.codehaus.stax2.automaticEmptyElements", Boolean.FALSE ); } IndentingXMLStreamWriter serializer = new IndentingXMLStreamWriter( factory.createXMLStreamWriter( writer ) ); if ( supportWindowsLineEndings ) { serializer.setNewLine( serializer.getLineSeparator() ); } serializer.writeStartDocument( userDatabase.getModelEncoding(), "1.0" ); writeUserDatabase( userDatabase, "userDatabase", serializer ); serializer.writeEndDocument(); } //-- void write(Writer, UserDatabase)
protected AbstractXmlHandler(final Writer dest) throws VeraPDFException { super(); try { this.writer = new IndentingXMLStreamWriter(outputFactory.createXMLStreamWriter(dest)); } catch (XMLStreamException excep) { throw wrapStreamException(excep, "initialising"); //$NON-NLS-1$ } }
IndentingXMLStreamWriter serializer = new IndentingXMLStreamWriter( factory.createXMLStreamWriter( writer ) ); if ( supportWindowsLineEndings ) serializer.setNewLine( serializer.getLineSeparator() ); serializer.writeStartDocument( preparedReleaseModel.getModelEncoding(), "1.0" ); writePreparedReleaseModel( preparedReleaseModel, "prepared-releases", serializer ); serializer.writeEndDocument();
protected AbstractXmlHandler(final Writer dest) throws VeraPDFException { super(); try { this.writer = new IndentingXMLStreamWriter(outputFactory.createXMLStreamWriter(dest)); } catch (XMLStreamException excep) { throw wrapStreamException(excep, "initialising"); //$NON-NLS-1$ } }
IndentingXMLStreamWriter serializer = new IndentingXMLStreamWriter( factory.createXMLStreamWriter( writer ) ); if ( supportWindowsLineEndings ) serializer.setNewLine( serializer.getLineSeparator() ); serializer.writeStartDocument( userDatabase.getModelEncoding(), "1.0" ); writeUserDatabase( userDatabase, "userDatabase", serializer ); serializer.writeEndDocument();
@Override public void output(final BugList bugList, final Writer writer, final CFLintStats stats) throws MarshallerException { try { final XMLOutputFactory xmlOutputFactory = XMLOutputFactory.newInstance(); XMLStreamWriter xtw = new IndentingXMLStreamWriter(xmlOutputFactory.createXMLStreamWriter(writer)); writeIssues(bugList, xtw, stats); xtw.flush(); } catch (XMLStreamException e) { throw new MarshallerException(e); } }
/** * Method write * * @param writer * @param model */ public void write(Writer writer, Model model) throws java.io.IOException, XMLStreamException { XMLOutputFactory factory = XMLOutputFactory.newInstance(); boolean supportWindowsLineEndings = false; if ( factory.isPropertySupported( "com.ctc.wstx.outputEscapeCr" ) ) { factory.setProperty( "com.ctc.wstx.outputEscapeCr", Boolean.FALSE ); supportWindowsLineEndings = true; } if ( factory.isPropertySupported( "org.codehaus.stax2.automaticEmptyElements" ) ) { factory.setProperty( "org.codehaus.stax2.automaticEmptyElements", Boolean.FALSE ); } IndentingXMLStreamWriter serializer = new IndentingXMLStreamWriter( factory.createXMLStreamWriter( writer ) ); if ( supportWindowsLineEndings ) { serializer.setNewLine( serializer.getLineSeparator() ); } serializer.writeStartDocument( model.getModelEncoding(), "1.0" ); writeModel( model, "project", serializer ); serializer.writeEndDocument(); } //-- void write(Writer, Model)
protected AbstractXmlReportWriter(OutputStream os, OutputStream errorStream) throws XMLStreamException, ParserConfigurationException, SAXException { super(os, errorStream); this.saxParser = SAXParserFactory.newInstance().newSAXParser(); IndentingXMLStreamWriter writer = new IndentingXMLStreamWriter(XMLOutputFactory.newFactory().createXMLStreamWriter(os)); this.writer = writer; this.reportHandler = new ReportParserEventHandler(writer); }
/** * Method write * * @param writer * @param continuumDatabase */ public void write(Writer writer, ContinuumDatabase continuumDatabase) throws java.io.IOException, XMLStreamException { XMLOutputFactory factory = XMLOutputFactory.newInstance(); boolean supportWindowsLineEndings = false; if ( factory.isPropertySupported( "com.ctc.wstx.outputEscapeCr" ) ) { factory.setProperty( "com.ctc.wstx.outputEscapeCr", Boolean.FALSE ); supportWindowsLineEndings = true; } if ( factory.isPropertySupported( "org.codehaus.stax2.automaticEmptyElements" ) ) { factory.setProperty( "org.codehaus.stax2.automaticEmptyElements", Boolean.FALSE ); } IndentingXMLStreamWriter serializer = new IndentingXMLStreamWriter( factory.createXMLStreamWriter( writer ) ); if ( supportWindowsLineEndings ) { serializer.setNewLine( serializer.getLineSeparator() ); } serializer.writeStartDocument( continuumDatabase.getModelEncoding(), "1.0" ); writeContinuumDatabase( continuumDatabase, "continuumDatabase", serializer ); serializer.writeEndDocument(); } //-- void write(Writer, ContinuumDatabase)
@Override public void output(final BugList bugList, final Writer writer, final CFLintStats stats) throws MarshallerException { try { final XMLOutputFactory xmlOutputFactory = XMLOutputFactory.newInstance(); XMLStreamWriter xtw = new IndentingXMLStreamWriter(xmlOutputFactory.createXMLStreamWriter(writer)); writeIssues(bugList, xtw, stats); xtw.flush(); } catch (XMLStreamException e) { throw new MarshallerException(e); } }
/** * Method write * * @param writer * @param authenticationKeyDatabase */ public void write(Writer writer, AuthenticationKeyDatabase authenticationKeyDatabase) throws java.io.IOException, XMLStreamException { XMLOutputFactory factory = XMLOutputFactory.newInstance(); boolean supportWindowsLineEndings = false; if ( factory.isPropertySupported( "com.ctc.wstx.outputEscapeCr" ) ) { factory.setProperty( "com.ctc.wstx.outputEscapeCr", Boolean.FALSE ); supportWindowsLineEndings = true; } if ( factory.isPropertySupported( "org.codehaus.stax2.automaticEmptyElements" ) ) { factory.setProperty( "org.codehaus.stax2.automaticEmptyElements", Boolean.FALSE ); } IndentingXMLStreamWriter serializer = new IndentingXMLStreamWriter( factory.createXMLStreamWriter( writer ) ); if ( supportWindowsLineEndings ) { serializer.setNewLine( serializer.getLineSeparator() ); } serializer.writeStartDocument( authenticationKeyDatabase.getModelEncoding(), "1.0" ); writeAuthenticationKeyDatabase( authenticationKeyDatabase, "authenticationKeyDatabase", serializer ); serializer.writeEndDocument(); } //-- void write(Writer, AuthenticationKeyDatabase)
protected AbstractXmlReportWriter(OutputStream os, OutputStream errorStream) throws XMLStreamException, ParserConfigurationException, SAXException { super(os, errorStream); this.saxParser = SAXParserFactory.newInstance().newSAXParser(); IndentingXMLStreamWriter writer = new IndentingXMLStreamWriter(XMLOutputFactory.newFactory().createXMLStreamWriter(os)); this.writer = writer; this.reportHandler = new ReportParserEventHandler(writer); }