public final class PackageURL extends Object implements Serializable
Package-URL (aka purl) is a "mostly universal" URL to describe a package. A purl is a URL composed of seven components:
scheme:type/namespace/name@version?qualifiers#subpath
Components are separated by a specific character for unambiguous parsing. A purl must NOT contain a URL Authority i.e. there is no support for username, password, host and port components. A namespace segment may sometimes look like a host but its interpretation is specific to a type.
| Modifier and Type | Class and Description |
|---|---|
static class |
PackageURL.StandardTypes
Convenience constants that defines common Package-URL 'type's.
|
| Constructor and Description |
|---|
PackageURL(String purl)
Constructs a new PackageURL object by parsing the specified string.
|
PackageURL(String type,
String name)
Constructs a new PackageURL object by specifying only the required
parameters necessary to create a valid PackageURL.
|
PackageURL(String type,
String namespace,
String name,
String version,
TreeMap<String,String> qualifiers,
String subpath)
Constructs a new PackageURL object.
|
| Modifier and Type | Method and Description |
|---|---|
String |
canonicalize()
Returns the canonicalized representation of the purl.
|
boolean |
equals(Object o) |
String |
getCoordinates()
Returns only the canonicalized coordinates of the Package URL which includes the type, namespace, name,
and version, and which omits the qualifier and subpath.
|
String |
getName()
Returns the name of the package.
|
String |
getNamespace()
Returns the name prefix such as a Maven groupid, a Docker image owner, a GitHub user or organization.
|
Map<String,String> |
getQualifiers()
Returns extra qualifying data for a package such as an OS, architecture, a distro, etc.
|
String |
getScheme()
Returns the package url scheme.
|
String |
getSubpath()
Returns extra subpath within a package, relative to the package root.
|
String |
getType()
Returns the package "type" or package "protocol" such as maven, npm, nuget, gem, pypi, etc.
|
String |
getVersion()
Returns the version of the package.
|
int |
hashCode() |
boolean |
isBaseEquals(PackageURL purl)
Deprecated.
This method is no longer recommended and will be removed from a future release.
Use |
boolean |
isCanonicalEquals(PackageURL purl)
Evaluates if the specified Package URL has the same canonical value.
|
boolean |
isCoordinatesEquals(PackageURL purl)
Evaluates if the specified Package URL has the same values up to, but excluding
the qualifier (querystring).
|
PackageURLBuilder |
toBuilder() |
String |
toString()
Returns the canonicalized representation of the purl.
|
static String |
uriDecode(String source) |
public PackageURL(String purl) throws MalformedPackageURLException
purl - a valid package URL string to parseMalformedPackageURLException - if parsing failspublic PackageURL(String type, String name) throws MalformedPackageURLException
type - the type of package (i.e. maven, npm, gem, etc)name - the name of the packageMalformedPackageURLException - if parsing failspublic PackageURL(String type, String namespace, String name, String version, TreeMap<String,String> qualifiers, String subpath) throws MalformedPackageURLException
type - the type of package (i.e. maven, npm, gem, etc)namespace - the name prefix (i.e. group, owner, organization)name - the name of the packageversion - the version of the packagequalifiers - an array of key/value pair qualifierssubpath - the subpath stringMalformedPackageURLException - if parsing failspublic PackageURLBuilder toBuilder()
public String getScheme()
public String getType()
public String getNamespace()
public String getName()
public String getVersion()
public Map<String,String> getQualifiers()
public String getSubpath()
public String toString()
public String canonicalize()
@Deprecated public boolean isBaseEquals(PackageURL purl)
Use isCoordinatesEquals(com.github.packageurl.PackageURL) instead.
purl - the Package URL to evaluatepublic boolean isCoordinatesEquals(PackageURL purl)
purl - the Package URL to evaluatepublic String getCoordinates()
public boolean isCanonicalEquals(PackageURL purl)
purl - the Package URL to evaluateCopyright © 2017–2023. All rights reserved.