Package org.cyclonedx.generators.xml
Class BomXmlGenerator
- java.lang.Object
-
- org.cyclonedx.CycloneDxSchema
-
- org.cyclonedx.generators.AbstractBomGenerator
-
- org.cyclonedx.generators.xml.BomXmlGenerator
-
public class BomXmlGenerator extends AbstractBomGenerator
-
-
Field Summary
Fields Modifier and Type Field Description private com.fasterxml.jackson.dataformat.xml.util.DefaultXmlPrettyPrinterprettyPrinterprotected static java.lang.StringPROLOG-
Fields inherited from class org.cyclonedx.generators.AbstractBomGenerator
bom, format, mapper, version
-
Fields inherited from class org.cyclonedx.CycloneDxSchema
ALL_VERSIONS, NS_BOM_10, NS_BOM_11, NS_BOM_12, NS_BOM_13, NS_BOM_14, NS_BOM_15, NS_BOM_16, NS_BOM_LATEST, NS_DEPENDENCY_GRAPH_10, VERSION_LATEST
-
-
Constructor Summary
Constructors Constructor Description BomXmlGenerator(Bom bom, Version version)Constructs a new BomXmlGenerator object.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description private javax.xml.parsers.DocumentBuilderbuildSecureDocumentBuilder()Constructs a new document builder with security features enabled.org.w3c.dom.Documentgenerate()Creates a CycloneDX BoM from a set of Components.protected org.w3c.dom.DocumentgenerateDocument(Bom bom)private voidregisterDependencyModule(com.fasterxml.jackson.databind.ObjectMapper mapper, boolean useNamespace)private voidsetupObjectMapper()java.lang.StringtoString()Creates a text representation of a CycloneDX BoM Document.(package private) java.lang.StringtoXML(Bom bom, boolean prettyPrint)java.lang.StringtoXmlString()-
Methods inherited from class org.cyclonedx.generators.AbstractBomGenerator
getFormat, getSchemaVersion, setupObjectMapper
-
Methods inherited from class org.cyclonedx.CycloneDxSchema
getJsonSchema, getXmlSchema, getXmlSchema
-
-
-
-
Field Detail
-
prettyPrinter
private final com.fasterxml.jackson.dataformat.xml.util.DefaultXmlPrettyPrinter prettyPrinter
-
PROLOG
protected static final java.lang.String PROLOG
- See Also:
- Constant Field Values
-
-
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.ParserConfigurationExceptionConstructs 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
-
toXML
java.lang.String toXML(Bom bom, boolean prettyPrint) throws GeneratorException
- Throws:
GeneratorException
-
generate
public org.w3c.dom.Document generate() throws javax.xml.parsers.ParserConfigurationExceptionCreates 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
-
toXmlString
public java.lang.String toXmlString() throws GeneratorException- Throws:
GeneratorException
-
toString
public java.lang.String toString()
Creates a text representation of a CycloneDX BoM Document. This method callstoXmlString()and will return an empty string iftoXmlString()throws an exception. It's preferred to calltoXmlString()directly so that exceptions can be caught.- Overrides:
toStringin classjava.lang.Object- Returns:
- a String of the BoM
- Since:
- 1.1.0
-
-