Package fish.payara.admin.rest.streams
Interface StreamWriter
-
- All Known Implementing Classes:
JsonStreamWriter
,XmlStreamWriter
public interface StreamWriter
Defines an interface that will handle streaming a data structure to anOutputStream
.
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description void
close()
Closes theOutputStream
associated with this object.String
getPostfix()
Returns a string of data that must appear at the end of the data stream.String
getPrefix()
Returns a string of data that must appear at the start of the data stream.void
writeAttribute(String name, Boolean value)
Writes aBoolean
attribute with the specifiedname
andvalue
.void
writeAttribute(String name, String value)
Writes aString
attribute with the specifiedname
andvalue
.void
writeEndArray()
Writes the end of an array.void
writeEndDocument()
Writes the data that is compulsory to appear at the end of the data structure.void
writeEndObject()
Writes the end of an object.void
writeStartArray(String element)
Writes the start of an array, with the specifiedname
.void
writeStartDocument()
Writes the data that is compulsory to appear at the start of the data structure.void
writeStartObject(String element)
Writes the start of a new object, with the specifiedname
.
-
-
-
Method Detail
-
getPostfix
String getPostfix()
Returns a string of data that must appear at the end of the data stream.- Returns:
- postfix
-
getPrefix
String getPrefix()
Returns a string of data that must appear at the start of the data stream. E.g. a namespace declaration.- Returns:
- prefix
-
writeStartDocument
void writeStartDocument() throws Exception
Writes 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" ?>
- Throws:
Exception
- Any exception thrown while writing. E.g. for JSON this might be aJsonGenerationException
.
-
writeEndDocument
void writeEndDocument() throws Exception
Writes the data that is compulsory to appear at the end of the data structure.- Throws:
Exception
- Any exception thrown while writing. E.g. for JSON this might be aJsonGenerationException
.
-
writeStartObject
void writeStartObject(String element) throws Exception
Writes the start of a new object, with the specifiedname
.- Parameters:
element
- The name of the object- Throws:
Exception
- Any exception thrown while writing. E.g. for JSON this might be aJsonGenerationException
.
-
writeEndObject
void writeEndObject() throws Exception
Writes the end of an object. An object must have been started, or an exception will be thrown.- Throws:
Exception
- Any exception thrown while writing. E.g. for JSON this might be aJsonGenerationException
.
-
writeStartArray
void writeStartArray(String element) throws Exception
Writes the start of an array, with the specifiedname
. If the data structure doesn't support arrays, this method will do nothing.- Parameters:
element
- The name of the array- Throws:
Exception
- Any exception thrown while writing. E.g. for JSON this might be aJsonGenerationException
.
-
writeEndArray
void writeEndArray() throws Exception
Writes 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.- Throws:
Exception
- Any exception thrown while writing. E.g. for JSON this might be aJsonGenerationException
.
-
writeAttribute
void writeAttribute(String name, String value) throws Exception
Writes aString
attribute with the specifiedname
andvalue
. E.g. for JSON this will write:"name":"value"
.- Parameters:
name
- The name of the attributevalue
- The value of the attribute- Throws:
Exception
- Any exception thrown while writing. E.g. for JSON this might be aJsonGenerationException
.
-
writeAttribute
void writeAttribute(String name, Boolean value) throws Exception
Writes aBoolean
attribute with the specifiedname
andvalue
. E.g. for JSON this will write:"name":true/false
.- Parameters:
name
- The name of the attributevalue
- The value of the attribute- Throws:
Exception
- Any exception thrown while writing. E.g. for JSON this might be aJsonGenerationException
.
-
close
void close() throws Exception
Closes theOutputStream
associated with this object. Some OutputStreams require closing before any data will be written.- Throws:
Exception
- Any exception thrown while closing the OutputStream. E.g. for JSON this might be aJsonGenerationException
.
-
-