Class ThreatOutputStream
java.lang.Object
java.io.OutputStream
be.kuleuven.cs.distrinet.sparta.io.ThreatOutputStream
- All Implemented Interfaces:
Closeable,Flushable,AutoCloseable
- Direct Known Subclasses:
ThreatXlsxOutputStream
As not all output files are text-based (for example, xlsx),
ThreatOutputStream enables the use of OutputStream to export
information on elicited Threats.-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionCreate a newThreatOutputStreamthat writes to out.ThreatOutputStream(OutputStream out, Map<String, Function<Threat, ? extends Object>> properties) Create a newThreatOutputStreamthat writes to out. -
Method Summary
Modifier and TypeMethodDescriptionvoidclose()voidflush()Retrieve the set of properties that are being exported by thisThreatWriter.abstract voidWrite-out a threatvoidWrite-out multiple threatsMethods inherited from class java.io.OutputStream
nullOutputStream, write, write, write
-
Field Details
-
outputStream
-
-
Constructor Details
-
ThreatOutputStream
Create a newThreatOutputStreamthat writes to out.- Parameters:
out- theOutputStreamto use.
-
ThreatOutputStream
public ThreatOutputStream(OutputStream out, Map<String, Function<Threat, ? extends Object>> properties) Create a newThreatOutputStreamthat writes to out. If any of the provided functions return aModelElement, theThreatWriterwill attempt to retrieve the name of the element when writing it to the output writer. Unlike the text-basedThreatWriterhierarchy, Double values are deliberately left raw so subclasses can emit typed (numeric) cells (seeThreatProperties.forTypedOutput(Map)).- Parameters:
out- theOutputStreamto use.properties- a set of functions, which applied to a threat provide the property to write out
-
-
Method Details
-
close
- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable- Overrides:
closein classOutputStream- Throws:
IOException
-
flush
- Specified by:
flushin interfaceFlushable- Overrides:
flushin classOutputStream- Throws:
IOException
-
getProperties
Retrieve the set of properties that are being exported by thisThreatWriter.- Returns:
- a
Mapcontaining the property name and the function to apply on a threat to retrieve that property
-
write
Write-out a threat- Parameters:
threat- theThreatto write out- Throws:
IOException- 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.
-