Class BomXmlGenerator

    • Field Detail

      • prettyPrinter

        private final com.fasterxml.jackson.dataformat.xml.util.DefaultXmlPrettyPrinter prettyPrinter
    • Constructor Detail

      • BomXmlGenerator

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

      • setupObjectMapper

        private void setupObjectMapper()
      • registerDependencyModule

        private void registerDependencyModule​(com.fasterxml.jackson.databind.ObjectMapper mapper,
                                              boolean useNamespace)
      • buildSecureDocumentBuilder

        private javax.xml.parsers.DocumentBuilder buildSecureDocumentBuilder()
                                                                      throws javax.xml.parsers.ParserConfigurationException
        Constructs a new document builder with security features enabled.
        Returns:
        a new document builder
        Throws:
        javax.xml.parsers.ParserConfigurationException - thrown if there is a parser configuration exception
      • generateDocument

        protected org.w3c.dom.Document generateDocument​(Bom bom)
                                                 throws javax.xml.parsers.ParserConfigurationException
        Throws:
        javax.xml.parsers.ParserConfigurationException
      • generate

        public org.w3c.dom.Document generate()
                                      throws javax.xml.parsers.ParserConfigurationException
        Creates a CycloneDX BoM from a set of Components.
        Returns:
        an XML Document representing a CycloneDX BoM
        Throws:
        javax.xml.parsers.ParserConfigurationException - if an error occurs
        Since:
        1.1.0
      • toString

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