Class BomJsonGenerator


public class BomJsonGenerator extends AbstractBomGenerator
  • Field Details

    • prettyPrinter

      private final com.fasterxml.jackson.core.util.DefaultPrettyPrinter prettyPrinter
  • Constructor Details

    • BomJsonGenerator

      public BomJsonGenerator(Bom bom, Version version)
      Constructs a new BomGenerator object.
      Parameters:
      bom - the BOM to generate
      version - the version of the CycloneDX schema to use.
  • Method Details

    • setupObjectMapper

      private void setupObjectMapper()
    • setupPrettyPrinter

      private void setupPrettyPrinter(com.fasterxml.jackson.core.util.DefaultPrettyPrinter prettyPrinter)
    • injectBomFormatAndSpecVersion

      private Bom injectBomFormatAndSpecVersion(Bom bom) throws GeneratorException
      Throws:
      GeneratorException
    • toJsonNode

      public com.fasterxml.jackson.databind.JsonNode toJsonNode()
      Creates a CycloneDX BOM from a set of Components.
      Returns:
      an JSON Document representing a CycloneDX BoM
      Since:
      7.0.0
    • toJsonString

      public String toJsonString() throws GeneratorException
      Throws:
      GeneratorException
    • toString

      public String toString()
      Creates a text representation of a CycloneDX BoM Document. This method calls toJsonString() and will return an empty string if toJsonString() throws an exception. It's preferred to call toJsonString() directly so that exceptions can be caught.
      Overrides:
      toString in class Object
      Returns:
      a String of the BoM
    • toJson

      String toJson(Bom bom, boolean prettyPrint) throws GeneratorException
      Throws:
      GeneratorException