Class ThreatTextWriter

java.lang.Object
java.io.Writer
be.kuleuven.cs.distrinet.sparta.io.ThreatWriter
be.kuleuven.cs.distrinet.sparta.io.ThreatTextWriter
All Implemented Interfaces:
Closeable, Flushable, Appendable, AutoCloseable

public class ThreatTextWriter extends ThreatWriter
Simple textwriter for outputing threats to a set of text files. Users of this class should rely a specific text format for automated processing. Other output formats are more suitable for post-processing.
  • Constructor Details

    • ThreatTextWriter

      public ThreatTextWriter(Writer writer)
      Create a new ThreatTextWriter to provided support for writing out a default set of threat properties to text files.
      Parameters:
      writer - a writer
    • ThreatTextWriter

      public ThreatTextWriter(Writer writer, Map<String,Function<Threat,? extends Object>> properties)
      Create a new ThreatTextWriter to provided support for writing out a default set of threat properties to text files. If any of the provided functions return a ModelElement, the ThreatWriter will attempt to retrieve the name of the element when writing it to the output writer.
      Parameters:
      writer - a writer
      properties - a set of functions, which applied to a threat provide the property to write out
  • Method Details

    • write

      public void write(Threat threat) throws IOException
      Write-out a threat
      Specified by:
      write in class ThreatWriter
      Parameters:
      threat - the Threat to write out
      Throws:
      IOException - If an I/O error occurs.
    • fileNameSuggestion

      public static String fileNameSuggestion(Threat threat)
      Provide a suggested filename for writing out the threat. This suggestion concatenates a number of the Threat's properties to attempt to obtain unique filenames for every Threat.
      Parameters:
      threat - The threat for which to generate a suggested filename.
      Returns:
      The suggested filename.