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 voidcloseEndTag()protected voidcloseStartTag()static voidmain(java.lang.String[] args)protected voidopenEndTag()protected voidopenStartTag()voidwrite(javax.xml.stream.XMLStreamReader xmlr)voidwriteAttribute(java.lang.String namespaceURI, java.lang.String localName, java.lang.String value)Writes an attribute to the output streamvoidwriteCData(java.lang.String data)Writes a CData sectionprotected voidwriteCharactersInternal(char[] characters, int start, int length, boolean isAttributeValue)voidwriteComment(java.lang.String data)Writes an xml comment with the data enclosedvoidwriteDefaultNamespace(java.lang.String namespaceURI)Writes the default namespace to the streamvoidwriteDTD(java.lang.String dtd)Write a DTD section.voidwriteEntityRef(java.lang.String name)Writes an entity referenceprotected java.lang.StringwriteName(java.lang.String prefix, java.lang.String namespaceURI, java.lang.String localName)voidwriteNamespace(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 writeDefaultNamespacevoidwriteProcessingInstruction(java.lang.String target, java.lang.String text)Writes a processing instructionvoidwriteStartDocument()Write the XML Declaration.voidwriteStartDocument(java.lang.String version)Write the XML Declaration.voidwriteStartDocument(java.lang.String encoding, java.lang.String version)Write the XML Declaration.protected voidwriteType(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:
writeNamein 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:
openStartTagin classXMLWriterBase- Throws:
javax.xml.stream.XMLStreamException
-
closeStartTag
protected void closeStartTag() throws javax.xml.stream.XMLStreamException- Overrides:
closeStartTagin classXMLWriterBase- Throws:
javax.xml.stream.XMLStreamException
-
openEndTag
protected void openEndTag() throws javax.xml.stream.XMLStreamException- Overrides:
openEndTagin classXMLWriterBase- Throws:
javax.xml.stream.XMLStreamException
-
closeEndTag
protected void closeEndTag() throws javax.xml.stream.XMLStreamException- Overrides:
closeEndTagin 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.XMLStreamExceptionDescription copied from interface:javax.xml.stream.XMLStreamWriterWrites an attribute to the output stream- Specified by:
writeAttributein interfacejavax.xml.stream.XMLStreamWriter- Overrides:
writeAttributein 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.XMLStreamExceptionDescription copied from interface:javax.xml.stream.XMLStreamWriterWrites 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:
writeNamespacein interfacejavax.xml.stream.XMLStreamWriter- Overrides:
writeNamespacein 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.XMLStreamExceptionDescription copied from interface:javax.xml.stream.XMLStreamWriterWrites the default namespace to the stream- Specified by:
writeDefaultNamespacein interfacejavax.xml.stream.XMLStreamWriter- Overrides:
writeDefaultNamespacein 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.XMLStreamExceptionDescription copied from interface:javax.xml.stream.XMLStreamWriterWrites an xml comment with the data enclosed- Specified by:
writeCommentin interfacejavax.xml.stream.XMLStreamWriter- Overrides:
writeCommentin 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.XMLStreamExceptionDescription copied from interface:javax.xml.stream.XMLStreamWriterWrites a processing instruction- Specified by:
writeProcessingInstructionin interfacejavax.xml.stream.XMLStreamWriter- Overrides:
writeProcessingInstructionin 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.XMLStreamExceptionDescription copied from interface:javax.xml.stream.XMLStreamWriterWrite a DTD section. This string represents the entire doctypedecl production from the XML 1.0 specification.- Specified by:
writeDTDin interfacejavax.xml.stream.XMLStreamWriter- Overrides:
writeDTDin 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.XMLStreamExceptionDescription copied from interface:javax.xml.stream.XMLStreamWriterWrites a CData section- Specified by:
writeCDatain interfacejavax.xml.stream.XMLStreamWriter- Overrides:
writeCDatain 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.XMLStreamExceptionDescription copied from interface:javax.xml.stream.XMLStreamWriterWrites an entity reference- Specified by:
writeEntityRefin interfacejavax.xml.stream.XMLStreamWriter- Overrides:
writeEntityRefin classXMLWriterBase- Parameters:
name- the name of the entity- Throws:
javax.xml.stream.XMLStreamException
-
writeStartDocument
public void writeStartDocument() throws javax.xml.stream.XMLStreamExceptionDescription copied from interface:javax.xml.stream.XMLStreamWriterWrite the XML Declaration. Defaults the XML version to 1.0, and the encoding to utf-8- Specified by:
writeStartDocumentin interfacejavax.xml.stream.XMLStreamWriter- Overrides:
writeStartDocumentin classXMLWriterBase- Throws:
javax.xml.stream.XMLStreamException
-
writeStartDocument
public void writeStartDocument(java.lang.String version) throws javax.xml.stream.XMLStreamExceptionDescription copied from interface:javax.xml.stream.XMLStreamWriterWrite the XML Declaration. Defaults the XML version to 1.0- Specified by:
writeStartDocumentin interfacejavax.xml.stream.XMLStreamWriter- Overrides:
writeStartDocumentin 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.XMLStreamExceptionDescription copied from interface:javax.xml.stream.XMLStreamWriterWrite 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:
writeStartDocumentin interfacejavax.xml.stream.XMLStreamWriter- Overrides:
writeStartDocumentin 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:
writeCharactersInternalin classXMLWriterBase- Throws:
javax.xml.stream.XMLStreamException
-
write
public void write(javax.xml.stream.XMLStreamReader xmlr) throws javax.xml.stream.XMLStreamException- Overrides:
writein classReaderToWriter- Throws:
javax.xml.stream.XMLStreamException
-
main
public static void main(java.lang.String[] args) throws java.lang.Exception- Throws:
java.lang.Exception
-
-