Package fish.payara.admin.rest.streams
Class XmlStreamWriter
- java.lang.Object
-
- fish.payara.admin.rest.streams.XmlStreamWriter
-
- All Implemented Interfaces:
StreamWriter
public class XmlStreamWriter extends Object implements StreamWriter
AStreamWriterfor handling XML.
-
-
Constructor Summary
Constructors Constructor Description XmlStreamWriter(OutputStream os)Creates aStreamWriterfor handling XML, with anullprefix and postfix.XmlStreamWriter(OutputStream os, String prefix, String postfix)Creates aStreamWriterfor handling XML.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidclose()Closes theOutputStreamassociated with this object.StringgetPostfix()Returns a string of data that must appear at the end of the data stream.StringgetPrefix()Returns a string of data that must appear at the start of the data stream.voidwriteAttribute(String name, Boolean value)Writes aBooleanattribute with the specifiednameandvalue.voidwriteAttribute(String name, String value)Writes aStringattribute with the specifiednameandvalue.voidwriteEndArray()Writes the end of an array.voidwriteEndDocument()Writes the data that is compulsory to appear at the end of the data structure.voidwriteEndObject()Writes the end of an object.voidwriteStartArray(String element)Writes the start of an array, with the specifiedname.voidwriteStartDocument()Writes the data that is compulsory to appear at the start of the data structure.voidwriteStartObject(String element)Writes the start of a new object, with the specifiedname.
-
-
-
Constructor Detail
-
XmlStreamWriter
public XmlStreamWriter(OutputStream os, String prefix, String postfix) throws XMLStreamException
Creates aStreamWriterfor handling XML.- Parameters:
os- The OutputStream to write to.prefix- Any data that needs writing at the start of the stream.postfix- Any data that needs writing at the end of the stream.- Throws:
XMLStreamException- Thrown if any errors occur in creating the XML stream.
-
XmlStreamWriter
public XmlStreamWriter(OutputStream os) throws XMLStreamException
Creates aStreamWriterfor handling XML, with anullprefix and postfix.- Parameters:
os- The OutputStream to write to.- Throws:
XMLStreamException- Thrown if any errors occur in creating the XML stream.
-
-
Method Detail
-
getPostfix
public String getPostfix()
Description copied from interface:StreamWriterReturns a string of data that must appear at the end of the data stream.- Specified by:
getPostfixin interfaceStreamWriter- Returns:
- postfix
-
getPrefix
public String getPrefix()
Description copied from interface:StreamWriterReturns a string of data that must appear at the start of the data stream. E.g. a namespace declaration.- Specified by:
getPrefixin interfaceStreamWriter- Returns:
- prefix
-
writeStartDocument
public void writeStartDocument() throws XMLStreamException, IOExceptionDescription copied from interface:StreamWriterWrites the data that is compulsory to appear at the start of the data structure.
E.g. for XML this might be:<?xml version="1.0" ?>- Specified by:
writeStartDocumentin interfaceStreamWriter- Throws:
XMLStreamExceptionIOException
-
writeEndDocument
public void writeEndDocument() throws XMLStreamException, IOExceptionDescription copied from interface:StreamWriterWrites the data that is compulsory to appear at the end of the data structure.- Specified by:
writeEndDocumentin interfaceStreamWriter- Throws:
XMLStreamExceptionIOException
-
writeStartObject
public void writeStartObject(String element) throws XMLStreamException
Description copied from interface:StreamWriterWrites the start of a new object, with the specifiedname.- Specified by:
writeStartObjectin interfaceStreamWriter- Parameters:
element- The name of the object- Throws:
XMLStreamException
-
writeEndObject
public void writeEndObject() throws XMLStreamExceptionDescription copied from interface:StreamWriterWrites the end of an object. An object must have been started, or an exception will be thrown.- Specified by:
writeEndObjectin interfaceStreamWriter- Throws:
XMLStreamException
-
writeAttribute
public void writeAttribute(String name, String value) throws XMLStreamException
Description copied from interface:StreamWriterWrites aStringattribute with the specifiednameandvalue. E.g. for JSON this will write:"name":"value".- Specified by:
writeAttributein interfaceStreamWriter- Parameters:
name- The name of the attributevalue- The value of the attribute- Throws:
XMLStreamException
-
writeAttribute
public void writeAttribute(String name, Boolean value) throws XMLStreamException
Description copied from interface:StreamWriterWrites aBooleanattribute with the specifiednameandvalue. E.g. for JSON this will write:"name":true/false.- Specified by:
writeAttributein interfaceStreamWriter- Parameters:
name- The name of the attributevalue- The value of the attribute- Throws:
XMLStreamException
-
close
public void close() throws XMLStreamExceptionDescription copied from interface:StreamWriterCloses theOutputStreamassociated with this object. Some OutputStreams require closing before any data will be written.- Specified by:
closein interfaceStreamWriter- Throws:
XMLStreamException
-
writeStartArray
public void writeStartArray(String element) throws Exception
Description copied from interface:StreamWriterWrites the start of an array, with the specifiedname. If the data structure doesn't support arrays, this method will do nothing.- Specified by:
writeStartArrayin interfaceStreamWriter- Parameters:
element- The name of the array- Throws:
Exception- Any exception thrown while writing. E.g. for JSON this might be aJsonGenerationException.
-
writeEndArray
public void writeEndArray() throws ExceptionDescription copied from interface:StreamWriterWrites the end of an array. An array must have been started, or an exception will be thrown. If the data structure doesn't support arrays, this method will do nothing.- Specified by:
writeEndArrayin interfaceStreamWriter- Throws:
Exception- Any exception thrown while writing. E.g. for JSON this might be aJsonGenerationException.
-
-