writer = new IndentingXMLStreamWriter(factory.createXMLStreamWriter(out, charSet)); } else { writer = factory.createXMLStreamWriter(out, charSet);
/** * Returns the name of the current event type. * * @return The name of the current event type. */ public String getEventTypeName() { return XMLStreamUtils.getEventTypeName(getEventType()); }
public void ignorableWhitespace(char[] ch, int start, int length) throws SAXException { super.ignorableWhitespace(ch, start, length); characters(ch, start, length); }
/** * @return System.getProperty("line.separator"); or * {@link #NORMAL_END_OF_LINE} if that fails. */ public static String getLineSeparator() { return IndentingXMLStreamWriter.getLineSeparator(); }
public static XMLStreamWriter createFilteredWriter(XMLStreamWriter writer, EventFilter filter) { XMLEventWriter eventWriter = new XMLStreamEventWriter(writer); eventWriter = new EventWriterFilter(eventWriter, filter); return new XMLEventStreamWriter(eventWriter); }
public synchronized void setPrefix(String prefix, String nsURI) throws XMLStreamException { peekNamespaceStack().setPrefix(prefix, nsURI); }
public synchronized void setDefaultNamespace(String nsURI) throws XMLStreamException { peekNamespaceStack().setDefaultNamespace(nsURI); }
/** * Creates an {@link XMLEventWriter} that writes to the provided * {@link XMLStreamWriter}. * * @param writer The destination stream. * @return An {@link XMLEventWriter} that writes to the provided * {@link XMLStreamWriter}. */ public XMLEventWriter createXMLEventWriter(XMLStreamWriter writer) { return new XMLStreamEventWriter(writer); }
/** * Creates and adds an {@link EndElement} event. * * @param ns The element namespace. * @param localName The element name. * @throws XMLStreamException If an error occurs adding the event. */ public void addEndElement(String ns, String localName) throws XMLStreamException { addEndElement(ns, localName, (Iterator) null); }
/** * Creates and adds a {@link StartElement} event. * * @param name The qualified element name. * @param context The element's {@link NamespaceContext}, or <code>null</code>. * @throws XMLStreamException If an error occurs adding the event. */ public void addStartElement(QName name, NamespaceContext context) throws XMLStreamException { addStartElement(name, null, null, context); }
public synchronized void flush() throws XMLStreamException { if (!closed) { sendCachedEvents(); } }
/** * Calculates the STAX {@link Location}from the SAX {@link Locator} * registered with this handler. If no {@link Locator}was provided, then * this method will return <code>null</code>. */ public Location getCurrentLocation() { if (docLocator != null) { return new SAXLocation(docLocator); } else { return null; } }
/** Prepare to end an element, by writing a new line and indentation. */ protected void beforeEndElement() { if (depth > 0 && stack[depth] == WROTE_MARKUP) { // but not data try { writeNewLine(depth - 1); } catch (Exception ignored) { } } }
public boolean hasText() { switch (getEventType()) { case XMLStreamConstants.SPACE : case XMLStreamConstants.CHARACTERS : case XMLStreamConstants.COMMENT : case XMLStreamConstants.CDATA : case XMLStreamConstants.ENTITY_REFERENCE : return true; default : return false; } }
/** Note that a document was ended. */ protected void afterEndDocument() { depth = 0; if (stack[0] == WROTE_MARKUP) { // but not data try { newLineEvent.write(out, 0); } catch (Exception ignored) { } } stack[0] = 0; // start fresh }
/** * Returns the read end of the pipe, from which events written to the write * end of the pipe will be available. * * @return The read end of the pipe. */ public synchronized XMLEventReader getReadEnd() { if (readEnd == null) { readEnd = new PipedXMLEventReader(this); } return readEnd; }
/** * Returns the write end of the pipe, whose events will be available from * the read end of this pipe. * * @return The write end of the pipe. */ public synchronized XMLEventWriter getWriteEnd() { if (writeEnd == null) { writeEnd = new PipedXMLEventWriter(this); } return writeEnd; }
/** * Creates and adds an {@link EndElement} event. * * @param name The element name. * @see XMLEventFactory#createEndElement(QName, Iterator) * @throws XMLStreamException If an error occurs adding the event. */ public void addEndElement(QName name) throws XMLStreamException { addEndElement(name, (Iterator) null); }
/** * Creates and adds a {@link StartElement} event. * * @param localName The local name of the element. * @param context The element's {@link NamespaceContext}, or <code>null</code>. * @throws XMLStreamException If an error occurs adding the event. */ public void addStartElement(String localName, NamespaceContext context) throws XMLStreamException { addStartElement(localName, null, null, context); }
/** * Creates and adds an {@link EndElement} event. * * @param localName The unqualified element name. * @throws XMLStreamException If an error occurs adding the event. */ public void addEndElement(String localName) throws XMLStreamException { addEndElement(localName, (Iterator) null); }