Class ThreatJsonWriter<T extends IThreat>
java.lang.Object
java.io.Writer
be.kuleuven.cs.distrinet.sparta.io.ThreatJsonWriter<T>
- All Implemented Interfaces:
Closeable,Flushable,Appendable,AutoCloseable
Writes
Threats to a character-output stream.
A newLine() method is provided, which uses the platform's own notion of line
separator as defined by the system property line.separator. Not all platforms
use the newline character ('\n') to terminate lines. Calling this method to
terminate each output line is therefore preferred to writing a newline
character directly.-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionThreatJsonWriter(Writer writer, Class<T> tClass) Create a new ThreatWriter to provided support for writing out a default set of threat properties to text-based files. -
Method Summary
Modifier and TypeMethodDescriptionvoidclose()Closes the stream, flushing it first.voidflush()Flushes the stream.voidnewLine()Writes a line separator.voidwrite(char[] cbuf, int off, int len) Writes a portion of an array of characters.voidWrite-out multiple threatsvoidwritePretty(List<T> threats) Write-out multiple threats
-
Field Details
-
writer
-
-
Constructor Details
-
ThreatJsonWriter
Create a new ThreatWriter to provided support for writing out a default set of threat properties to text-based files.- Parameters:
writer- a writer
-
-
Method Details
-
close
Closes the stream, flushing it first. Once the stream has been closed, further write() or flush() invocations will cause an IOException to be thrown. Closing a previously closed stream has no effe- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable- Specified by:
closein classWriter- Throws:
IOException
-
flush
Flushes the stream. If the stream has saved any characters from the various write() methods in a buffer, write them immediately to their intended destination. Then, if that destination is another character or byte stream, flush it. Thus one flush() invocation will flush all the buffers in a chain of Writers and OutputStreams. If the intended destination of this stream is an abstraction provided by the underlying operating system, for example a file, then flushing the stream guarantees only that bytes previously written to the stream are passed to the operating system for writing; it does not guarantee that they are actually written to a physical device such as a disk drive.- Specified by:
flushin interfaceFlushable- Specified by:
flushin classWriter- Throws:
IOException
-
write
Writes a portion of an array of characters.- Specified by:
writein classWriter- Parameters:
cbuf- Array of charactersoff- Offset from which to start writing characterslen- Number of characters to write- Throws:
IndexOutOfBoundsException- Implementations should throw this exception if off is negative, or len is negative, or off + len is negative or greater than the length of the given arrayIOException- If an I/O error occurs
-
write
Write-out multiple threats- Parameters:
threats- theThreats to write out- Throws:
IOException- If an I/O error occurs.
-
writePretty
Write-out multiple threats- Parameters:
threats- theThreats to write out- Throws:
IOException- If an I/O error occurs.
-
newLine
Writes a line separator. The line separator string is defined by the system property line.separator, and is not necessarily a single newline ('\n') character.- Throws:
IOException- If an I/O error occurs.
-