Package com.bea.xml.stream
Class XMLStreamRecorder
- java.lang.Object
-
- com.bea.xml.stream.ReaderToWriter
-
- com.bea.xml.stream.XMLWriterBase
-
- com.bea.xml.stream.XMLStreamRecorder
-
- All Implemented Interfaces:
javax.xml.stream.XMLStreamWriter
public class XMLStreamRecorder extends XMLWriterBase
Writes XML in a non-xml format to create XML tests.
-
-
Field Summary
-
Fields inherited from class com.bea.xml.stream.XMLWriterBase
context, DEFAULTNS
-
-
Constructor Summary
Constructors Constructor Description XMLStreamRecorder()
XMLStreamRecorder(java.io.Writer writer)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description protected void
closeEndTag()
protected void
closeStartTag()
static void
main(java.lang.String[] args)
protected void
openEndTag()
protected void
openStartTag()
void
write(javax.xml.stream.XMLStreamReader xmlr)
void
writeAttribute(java.lang.String namespaceURI, java.lang.String localName, java.lang.String value)
Writes an attribute to the output streamvoid
writeCData(java.lang.String data)
Writes a CData sectionprotected void
writeCharactersInternal(char[] characters, int start, int length, boolean isAttributeValue)
void
writeComment(java.lang.String data)
Writes an xml comment with the data enclosedvoid
writeDefaultNamespace(java.lang.String namespaceURI)
Writes the default namespace to the streamvoid
writeDTD(java.lang.String dtd)
Write a DTD section.void
writeEntityRef(java.lang.String name)
Writes an entity referenceprotected java.lang.String
writeName(java.lang.String prefix, java.lang.String namespaceURI, java.lang.String localName)
void
writeNamespace(java.lang.String prefix, java.lang.String namespaceURI)
Writes a namespace to the output stream If the prefix argument to this method is the empty string, "xmlns", or null this method will delegate to writeDefaultNamespacevoid
writeProcessingInstruction(java.lang.String target, java.lang.String text)
Writes a processing instructionvoid
writeStartDocument()
Write the XML Declaration.void
writeStartDocument(java.lang.String version)
Write the XML Declaration.void
writeStartDocument(java.lang.String encoding, java.lang.String version)
Write the XML Declaration.protected void
writeType(int type)
-
Methods inherited from class com.bea.xml.stream.XMLWriterBase
close, closeStartElement, flush, getNamespaceContext, getPrefix, getProperty, getURIInternal, isOpen, setConfigurationContext, setDefaultNamespace, setNamespaceContext, setPrefix, setWriter, write, write, write, write, writeAttribute, writeAttribute, writeCharacters, writeCharacters, writeEmptyElement, writeEmptyElement, writeEmptyElement, writeEndDocument, writeEndElement, writeProcessingInstruction, writeRaw, writeStartElement, writeStartElement, writeStartElement, writeStartElementInternal
-
Methods inherited from class com.bea.xml.stream.ReaderToWriter
setStreamWriter, writeAll
-
-
-
-
Method Detail
-
writeName
protected java.lang.String writeName(java.lang.String prefix, java.lang.String namespaceURI, java.lang.String localName) throws javax.xml.stream.XMLStreamException
- Overrides:
writeName
in classXMLWriterBase
- Throws:
javax.xml.stream.XMLStreamException
-
writeType
protected void writeType(int type) throws javax.xml.stream.XMLStreamException
- Throws:
javax.xml.stream.XMLStreamException
-
openStartTag
protected void openStartTag() throws javax.xml.stream.XMLStreamException
- Overrides:
openStartTag
in classXMLWriterBase
- Throws:
javax.xml.stream.XMLStreamException
-
closeStartTag
protected void closeStartTag() throws javax.xml.stream.XMLStreamException
- Overrides:
closeStartTag
in classXMLWriterBase
- Throws:
javax.xml.stream.XMLStreamException
-
openEndTag
protected void openEndTag() throws javax.xml.stream.XMLStreamException
- Overrides:
openEndTag
in classXMLWriterBase
- Throws:
javax.xml.stream.XMLStreamException
-
closeEndTag
protected void closeEndTag() throws javax.xml.stream.XMLStreamException
- Overrides:
closeEndTag
in classXMLWriterBase
- Throws:
javax.xml.stream.XMLStreamException
-
writeAttribute
public void writeAttribute(java.lang.String namespaceURI, java.lang.String localName, java.lang.String value) throws javax.xml.stream.XMLStreamException
Description copied from interface:javax.xml.stream.XMLStreamWriter
Writes an attribute to the output stream- Specified by:
writeAttribute
in interfacejavax.xml.stream.XMLStreamWriter
- Overrides:
writeAttribute
in classXMLWriterBase
- Parameters:
namespaceURI
- the uri of the prefix for this attributelocalName
- the local name of the attributevalue
- the value of the attribute- Throws:
javax.xml.stream.XMLStreamException
- if the namespace URI has not been bound to a prefix and javax.xml.stream.isPrefixDefaulting has not been set to true
-
writeNamespace
public void writeNamespace(java.lang.String prefix, java.lang.String namespaceURI) throws javax.xml.stream.XMLStreamException
Description copied from interface:javax.xml.stream.XMLStreamWriter
Writes a namespace to the output stream If the prefix argument to this method is the empty string, "xmlns", or null this method will delegate to writeDefaultNamespace- Specified by:
writeNamespace
in interfacejavax.xml.stream.XMLStreamWriter
- Overrides:
writeNamespace
in classXMLWriterBase
- Parameters:
prefix
- the prefix to bind this namespace tonamespaceURI
- the uri to bind the prefix to- Throws:
javax.xml.stream.XMLStreamException
-
writeDefaultNamespace
public void writeDefaultNamespace(java.lang.String namespaceURI) throws javax.xml.stream.XMLStreamException
Description copied from interface:javax.xml.stream.XMLStreamWriter
Writes the default namespace to the stream- Specified by:
writeDefaultNamespace
in interfacejavax.xml.stream.XMLStreamWriter
- Overrides:
writeDefaultNamespace
in classXMLWriterBase
- Parameters:
namespaceURI
- the uri to bind the default namespace to- Throws:
javax.xml.stream.XMLStreamException
-
writeComment
public void writeComment(java.lang.String data) throws javax.xml.stream.XMLStreamException
Description copied from interface:javax.xml.stream.XMLStreamWriter
Writes an xml comment with the data enclosed- Specified by:
writeComment
in interfacejavax.xml.stream.XMLStreamWriter
- Overrides:
writeComment
in classXMLWriterBase
- Parameters:
data
- the data contained in the comment, may be null- Throws:
javax.xml.stream.XMLStreamException
-
writeProcessingInstruction
public void writeProcessingInstruction(java.lang.String target, java.lang.String text) throws javax.xml.stream.XMLStreamException
Description copied from interface:javax.xml.stream.XMLStreamWriter
Writes a processing instruction- Specified by:
writeProcessingInstruction
in interfacejavax.xml.stream.XMLStreamWriter
- Overrides:
writeProcessingInstruction
in classXMLWriterBase
- Parameters:
target
- the target of the processing instruction, may not be nulltext
- the data contained in the processing instruction, may not be null- Throws:
javax.xml.stream.XMLStreamException
-
writeDTD
public void writeDTD(java.lang.String dtd) throws javax.xml.stream.XMLStreamException
Description copied from interface:javax.xml.stream.XMLStreamWriter
Write a DTD section. This string represents the entire doctypedecl production from the XML 1.0 specification.- Specified by:
writeDTD
in interfacejavax.xml.stream.XMLStreamWriter
- Overrides:
writeDTD
in classXMLWriterBase
- Parameters:
dtd
- the DTD to be written- Throws:
javax.xml.stream.XMLStreamException
-
writeCData
public void writeCData(java.lang.String data) throws javax.xml.stream.XMLStreamException
Description copied from interface:javax.xml.stream.XMLStreamWriter
Writes a CData section- Specified by:
writeCData
in interfacejavax.xml.stream.XMLStreamWriter
- Overrides:
writeCData
in classXMLWriterBase
- Parameters:
data
- the data contained in the CData Section, may not be null- Throws:
javax.xml.stream.XMLStreamException
-
writeEntityRef
public void writeEntityRef(java.lang.String name) throws javax.xml.stream.XMLStreamException
Description copied from interface:javax.xml.stream.XMLStreamWriter
Writes an entity reference- Specified by:
writeEntityRef
in interfacejavax.xml.stream.XMLStreamWriter
- Overrides:
writeEntityRef
in classXMLWriterBase
- Parameters:
name
- the name of the entity- Throws:
javax.xml.stream.XMLStreamException
-
writeStartDocument
public void writeStartDocument() throws javax.xml.stream.XMLStreamException
Description copied from interface:javax.xml.stream.XMLStreamWriter
Write the XML Declaration. Defaults the XML version to 1.0, and the encoding to utf-8- Specified by:
writeStartDocument
in interfacejavax.xml.stream.XMLStreamWriter
- Overrides:
writeStartDocument
in classXMLWriterBase
- Throws:
javax.xml.stream.XMLStreamException
-
writeStartDocument
public void writeStartDocument(java.lang.String version) throws javax.xml.stream.XMLStreamException
Description copied from interface:javax.xml.stream.XMLStreamWriter
Write the XML Declaration. Defaults the XML version to 1.0- Specified by:
writeStartDocument
in interfacejavax.xml.stream.XMLStreamWriter
- Overrides:
writeStartDocument
in classXMLWriterBase
- Parameters:
version
- version of the xml document- Throws:
javax.xml.stream.XMLStreamException
-
writeStartDocument
public void writeStartDocument(java.lang.String encoding, java.lang.String version) throws javax.xml.stream.XMLStreamException
Description copied from interface:javax.xml.stream.XMLStreamWriter
Write the XML Declaration. Note that the encoding parameter does not set the actual encoding of the underlying output. That must be set when the instance of the XMLStreamWriter is created using the XMLOutputFactory- Specified by:
writeStartDocument
in interfacejavax.xml.stream.XMLStreamWriter
- Overrides:
writeStartDocument
in classXMLWriterBase
- Parameters:
encoding
- encoding of the xml declarationversion
- version of the xml document- Throws:
javax.xml.stream.XMLStreamException
-
writeCharactersInternal
protected void writeCharactersInternal(char[] characters, int start, int length, boolean isAttributeValue) throws javax.xml.stream.XMLStreamException
- Overrides:
writeCharactersInternal
in classXMLWriterBase
- Throws:
javax.xml.stream.XMLStreamException
-
write
public void write(javax.xml.stream.XMLStreamReader xmlr) throws javax.xml.stream.XMLStreamException
- Overrides:
write
in classReaderToWriter
- Throws:
javax.xml.stream.XMLStreamException
-
main
public static void main(java.lang.String[] args) throws java.lang.Exception
- Throws:
java.lang.Exception
-
-