/** * Wrap an XMLEventWriter around that StringWriter. */ private XMLEventWriter createXmlEventWriter(StringWriter stringWriter) throws FactoryConfigurationError, XMLStreamException { return new IndentingXMLEventWriter(XMLOutputFactory.newInstance() .createXMLEventWriter(stringWriter)); } }
case XMLStreamConstants.SPACE: out.add(event); afterData(); return; beforeStartElement(); out.add(event); afterStartElement(); return; beforeEndElement(); out.add(event); afterEndElement(); return; case XMLStreamConstants.COMMENT: case XMLStreamConstants.DTD: beforeMarkup(); out.add(event); afterMarkup(); return; afterEndDocument(); break;
protected XMLEventWriter filter(XMLEventWriter writer) { if (indenting) { IndentingXMLEventWriter indenter = new IndentingXMLEventWriter(writer); indenter.setNewLine(newLine); indenter.setIndent(indent); writer = indenter; } return writer; }
/** Prepare to write markup, by writing a new line and indentation. */ protected void beforeMarkup() { int soFar = stack[depth]; if ((soFar & WROTE_DATA) == 0 // no data in this scope && (depth > 0 || soFar != 0)) // not the first line { try { newLineEvent.write(out, depth); if (depth > 0 && getIndent().length() > 0) { afterMarkup(); // indentation was written } } catch (Exception e) { } } }
/** Note that an element was started. */ protected void afterStartElement() { afterMarkup(); ++depth; }
/** * Create an XMLEventWriter for this file. Make it a pretty, indenting * writer. */ private XMLEventWriter createXmlEventWriter(FileWriter fileWriter) throws FactoryConfigurationError, XMLStreamException { XMLOutputFactory factory = XMLOutputFactory.newInstance(); return new IndentingXMLEventWriter(factory .createXMLEventWriter(fileWriter)); }
/** * Create an XMLEventWriter for this file. Make it a pretty, indenting * writer. */ private XMLEventWriter createXmlEventWriter(FileWriter fileWriter) throws FactoryConfigurationError, XMLStreamException { XMLOutputFactory factory = XMLOutputFactory.newInstance(); return new IndentingXMLEventWriter(factory .createXMLEventWriter(fileWriter)); }
/** * Wrap an XMLEventWriter around that StringWriter. */ private XMLEventWriter createXmlEventWriter(StringWriter stringWriter) throws FactoryConfigurationError, XMLStreamException { return new IndentingXMLEventWriter(XMLOutputFactory.newInstance() .createXMLEventWriter(stringWriter)); } }
private void initializeReaderAndWriter(InputStream inputStream, OutputStream outputStream, boolean outputAsXmlFragment) throws WLFormatException { if (inputStream != null) { try { XMLInputFactory xmlInputFactory = XMLInputFactory.newInstance(); xmlEventReader = xmlInputFactory.createXMLEventReader(inputStream, "UTF-8"); } catch (XMLStreamException e) { throw new WLFormatException(e.getMessage(), e); } } if (outputStream != null) { try { XMLOutputFactory xmlOutputFactory = XMLOutputFactory.newInstance(); xmlEventWriter = new IndentingXMLEventWriter(xmlOutputFactory.createXMLEventWriter(outputStream, "UTF-8")); } catch (XMLStreamException e) { throw new WLFormatException(e.getMessage(), e); } } xmlReaderWriter = new XmlReaderWriter(xmlEventReader, xmlEventWriter); xmlReaderWriter.setOutputAsXmlFragment(outputAsXmlFragment); }
private XMLEventWriter createXmlWriter() throws FactoryConfigurationError, XMLStreamException { XMLOutputFactory factory = XMLOutputFactory.newInstance(); return new IndentingXMLEventWriter(factory .createXMLEventWriter(xmlStringWriter)); }
private void initializeReaderAndWriter(InputStream inputStream, OutputStream outputStream, boolean outputAsXmlFragment) throws WLFormatException { if (inputStream != null) { try { XMLInputFactory xmlInputFactory = XMLInputFactory.newInstance(); xmlEventReader = xmlInputFactory.createXMLEventReader(inputStream, "UTF-8"); } catch (XMLStreamException e) { throw new WLFormatException(e.getMessage(), e); } } if (outputStream != null) { try { XMLOutputFactory xmlOutputFactory = XMLOutputFactory.newInstance(); xmlEventWriter = new IndentingXMLEventWriter(xmlOutputFactory.createXMLEventWriter(outputStream, "UTF-8")); } catch (XMLStreamException e) { throw new WLFormatException(e.getMessage(), e); } } xmlReaderWriter = new XmlReaderWriter(xmlEventReader, xmlEventWriter); xmlReaderWriter.setOutputAsXmlFragment(outputAsXmlFragment); }
private void initializeReaderAndWriter(InputStream inputStream, OutputStream outputStream, boolean outputAsXmlFragment) throws WLFormatException { if (inputStream != null) { try { XMLInputFactory xmlInputFactory = XMLInputFactory.newInstance(); xmlEventReader = xmlInputFactory.createXMLEventReader(inputStream, "UTF-8"); } catch (XMLStreamException e) { throw new WLFormatException(e.getMessage(), e); } } if (outputStream != null) { try { XMLOutputFactory xmlOutputFactory = XMLOutputFactory.newInstance(); xmlEventWriter = new IndentingXMLEventWriter(xmlOutputFactory.createXMLEventWriter(outputStream, "UTF-8")); } catch (XMLStreamException e) { throw new WLFormatException(e.getMessage(), e); } } xmlReaderWriter = new XmlReaderWriter(xmlEventReader, xmlEventWriter); xmlReaderWriter.setOutputAsXmlFragment(outputAsXmlFragment); }
public MockJournalWriter(Map<String, String> parameters, String role, ServerInterface server) throws XMLStreamException, FactoryConfigurationError { super(parameters, role, server); xmlWriter = new IndentingXMLEventWriter(XMLOutputFactory.newInstance() .createXMLEventWriter(stringWriter)); }
private void initializeReaderAndWriter( InputStream inputStream, OutputStream outputStream, boolean outputAsXmlFragment) throws WLFormatException { if (inputStream != null) { try { XMLInputFactory xmlInputFactory = XMLInputFactory.newInstance(); xmlEventReader = xmlInputFactory.createXMLEventReader(inputStream, "UTF-8"); } catch (XMLStreamException e) { throw new WLFormatException(e.getMessage(), e); } } if (outputStream != null) { try { XMLOutputFactory xmlOutputFactory = XMLOutputFactory.newInstance(); xmlEventWriter = new IndentingXMLEventWriter(xmlOutputFactory.createXMLEventWriter(outputStream, "UTF-8")); } catch (XMLStreamException e) { throw new WLFormatException(e.getMessage(), e); } } xmlReaderWriter = new XmlReaderWriter(xmlEventReader, xmlEventWriter); xmlReaderWriter.setOutputAsXmlFragment(outputAsXmlFragment); }
/** * Get the name of the journal file from the server parameters, create the * file, wrap it in an XMLEventWriter, and initialize it with a document * header. */ public SingleFileJournalWriter(Map<String, String> parameters, String role, ServerInterface server) throws JournalException { super(parameters, role, server); if (!parameters.containsKey(PARAMETER_JOURNAL_FILENAME)) { throw new JournalException("Parameter '" + PARAMETER_JOURNAL_FILENAME + "' not set."); } try { out = new FileWriter(parameters.get(PARAMETER_JOURNAL_FILENAME)); XMLOutputFactory factory = XMLOutputFactory.newInstance(); writer = new IndentingXMLEventWriter(factory .createXMLEventWriter(out)); } catch (IOException e) { throw new JournalException(e); } catch (XMLStreamException e) { throw new JournalException(e); } }
/** * Get the name of the journal file from the server parameters, create the * file, wrap it in an XMLEventWriter, and initialize it with a document * header. */ public SingleFileJournalWriter(Map<String, String> parameters, String role, ServerInterface server) throws JournalException { super(parameters, role, server); if (!parameters.containsKey(PARAMETER_JOURNAL_FILENAME)) { throw new JournalException("Parameter '" + PARAMETER_JOURNAL_FILENAME + "' not set."); } try { out = new FileWriter(parameters.get(PARAMETER_JOURNAL_FILENAME)); XMLOutputFactory factory = XMLOutputFactory.newInstance(); writer = new IndentingXMLEventWriter(factory .createXMLEventWriter(out)); } catch (IOException e) { throw new JournalException(e); } catch (XMLStreamException e) { throw new JournalException(e); } }
new IndentingXMLEventWriter(factory.createXMLEventWriter(new BufferedWriter(stringBuilderWriter)));
/** * check state, send the open request, open a very special writer, write the * file opening, set state */ @Override public void openFile(String repositoryHash, String filename, Date currentDate) throws JournalException { try { super.testStateChange(State.FILE_OPEN); writer = new RmiTransportWriter(receiver, repositoryHash, filename); xmlWriter = new IndentingXMLEventWriter(XMLOutputFactory .newInstance() .createXMLEventWriter(new BufferedWriter(writer, bufferSize))); parent.writeDocumentHeader(xmlWriter, repositoryHash, currentDate); super.setState(State.FILE_OPEN); } catch (XMLStreamException e) { throw new JournalException(e); } catch (FactoryConfigurationError e) { throw new JournalException(e); } }
/** * check state, send the open request, open a very special writer, write the * file opening, set state */ @Override public void openFile(String repositoryHash, String filename, Date currentDate) throws JournalException { try { super.testStateChange(State.FILE_OPEN); writer = new RmiTransportWriter(receiver, repositoryHash, filename); xmlWriter = new IndentingXMLEventWriter(XMLOutputFactory .newInstance() .createXMLEventWriter(new BufferedWriter(writer, bufferSize))); parent.writeDocumentHeader(xmlWriter, repositoryHash, currentDate); super.setState(State.FILE_OPEN); } catch (XMLStreamException e) { throw new JournalException(e); } catch (FactoryConfigurationError e) { throw new JournalException(e); } }
@Override public void openFile(String repositoryHash, String filename, Date currentDate) throws JournalException { howManyOpenFileRequests++; this.repositoryHash = repositoryHash; this.filename = filename; this.currentDate = currentDate; try { stringWriter = new StringWriter(); xmlWriter = new IndentingXMLEventWriter(XMLOutputFactory.newInstance() .createXMLEventWriter(stringWriter)); } catch (XMLStreamException e) { throw new JournalException(e); } catch (FactoryConfigurationError e) { throw new JournalException(e); } }