Render

Render a package-url to a string

Rendering to a string supports 2 options. With pkg scheme (current spec standard) or scheme-less (backwards compatible).

This behavior is controlled by RenderFlavor.

The default behavior can be installed JVM-wide, or can be specified when calling toString(RenderFlavor).

pkg scheme

PackageUrl purl = PackageUrl.parse("maven:junit/junit@4.12");
System.out.println(purl.toString(PackageUrl.RenderFlavor.SCHEME));

Or set the default:

PackageUrl.RenderFlavor.setDefault(PackageUrl.RenderFlavor.SCHEME);
System.out.println(purl.toString());

scheme-less

PackageUrl purl = PackageUrl.parse("maven:junit/junit@4.12");
System.out.println(purl.toString(PackageUrl.RenderFlavor.SCHEMELESS));

Or set the default:

PackageUrl.RenderFlavor.setDefault(PackageUrl.RenderFlavor.SCHEMELESS);
System.out.println(purl.toString());