36
36
import java .util .function .IntPredicate ;
37
37
import java .util .stream .Collectors ;
38
38
import java .util .stream .IntStream ;
39
+
39
40
import org .jspecify .annotations .Nullable ;
40
41
41
42
/**
45
46
* </pre>
46
47
* <p>
47
48
* Components are separated by a specific character for unambiguous parsing.
48
- * A purl must NOT contain a URL Authority i.e. there is no support for username,
49
+ * A purl must NOT contain a URL Authority, i.e., there is no support for username,
49
50
* password, host and port components. A namespace segment may sometimes look
50
- * like a host but its interpretation is specific to a type.
51
+ * like a host, but its interpretation is specific to a type.
51
52
* </p>
52
53
* <p>SPEC: <a href="https://github.com/package-url/purl-spec">https://github.com/package-url/purl-spec</a></p>
53
54
*
@@ -87,8 +88,8 @@ public PackageURL(final String type, final String name) throws MalformedPackageU
87
88
/**
88
89
* Constructs a new PackageURL object.
89
90
*
90
- * @param type the type of package (i.e. maven, npm, gem, etc), not {@code null}
91
- * @param namespace the name prefix (i.e. group, owner, organization)
91
+ * @param type the type of package (i.e., maven, npm, gem, etc. ), not {@code null}
92
+ * @param namespace the name prefix (i.e., group, owner, organization)
92
93
* @param name the name of the package, not {@code null}
93
94
* @param version the version of the package
94
95
* @param qualifiers an array of key/value pair qualifiers
@@ -115,7 +116,7 @@ public PackageURL(final String type, final @Nullable String namespace, final Str
115
116
* Constructs a new PackageURL object.
116
117
*
117
118
* @param type the type of package (i.e. maven, npm, gem, etc)
118
- * @param namespace the name prefix (i.e. group, owner, organization)
119
+ * @param namespace the name prefix (i.e., group, owner, organization)
119
120
* @param name the name of the package
120
121
* @param version the version of the package
121
122
* @param qualifiers an array of key/value pair qualifiers
@@ -124,14 +125,17 @@ public PackageURL(final String type, final @Nullable String namespace, final Str
124
125
* @throws NullPointerException if {@code type} or {@code name} are {@code null}
125
126
* @since 1.6.0
126
127
*/
128
+ @ SuppressWarnings ("deprecation" )
127
129
public PackageURL (final String type , final @ Nullable String namespace , final String name , final @ Nullable String version ,
128
- final @ Nullable Map <String , @ Nullable String > qualifiers , final @ Nullable String subpath )
130
+ final @ Nullable Map <String , String > qualifiers , final @ Nullable String subpath )
129
131
throws MalformedPackageURLException {
130
132
this (type , namespace , name , version , (qualifiers != null ) ? new TreeMap <>(qualifiers ) : null , subpath );
131
133
}
132
134
133
135
/**
134
- * The PackageURL scheme constant
136
+ * The PackageURL scheme constant.
137
+ *
138
+ * @since 1.6.0
135
139
*/
136
140
public static final String SCHEME = "pkg" ;
137
141
@@ -180,16 +184,12 @@ public PackageURL(final String type, final @Nullable String namespace, final Str
180
184
* Converts this {@link PackageURL} to a {@link PackageURLBuilder}.
181
185
*
182
186
* @return the builder
183
- * @deprecated Use {@link PackageURLBuilder#aPackageURL(PackageURL)} or {@link PackageURLBuilder#aPackageURL(String)}
187
+ * @since 1.5.0
188
+ * @deprecated use {@link PackageURLBuilder#aPackageURL(PackageURL)} or {@link PackageURLBuilder#aPackageURL(String)}
184
189
*/
190
+ @ Deprecated
185
191
public PackageURLBuilder toBuilder () {
186
- return PackageURLBuilder .aPackageURL ()
187
- .withType (getType ())
188
- .withNamespace (getNamespace ())
189
- .withName (getName ())
190
- .withVersion (getVersion ())
191
- .withQualifiers (getQualifiers ())
192
- .withSubpath (getSubpath ());
192
+ return PackageURLBuilder .aPackageURL (this );
193
193
}
194
194
195
195
/**
@@ -592,7 +592,7 @@ private static byte percentDecode(final byte[] bytes, final int start) {
592
592
return ((byte ) ((c1 << 4 ) + c2 ));
593
593
}
594
594
595
- public static String percentDecode (final String source ) {
595
+ private static String percentDecode (final String source ) {
596
596
if (source .isEmpty ()) {
597
597
return source ;
598
598
}
@@ -634,8 +634,16 @@ public static String percentDecode(final String source) {
634
634
return new String (buffer .array (), 0 , buffer .position (), StandardCharsets .UTF_8 );
635
635
}
636
636
637
+ /**
638
+ * URI decodes the given string.
639
+ *
640
+ * @param source the encoded string
641
+ * @return the decoded string
642
+ * @since 1.4.2
643
+ * @deprecated this method was made public in error in version 1.4.2 and will be removed without a replacement
644
+ */
637
645
@ Deprecated
638
- public String uriDecode (final String source ) {
646
+ public @ Nullable String uriDecode (final @ Nullable String source ) {
639
647
return source != null ? percentDecode (source ) : null ;
640
648
}
641
649
@@ -649,7 +657,7 @@ private static byte[] percentEncode(byte b) {
649
657
return new byte [] {(byte ) PERCENT_CHAR , b1 , b2 };
650
658
}
651
659
652
- public static String percentEncode (final String source ) {
660
+ private static String percentEncode (final String source ) {
653
661
if (source .isEmpty ()) {
654
662
return source ;
655
663
}
@@ -841,10 +849,11 @@ private String encodePath(final String path) {
841
849
842
850
/**
843
851
* Evaluates if the specified Package URL has the same values up to, but excluding
844
- * the qualifier (querystring). This includes equivalence of: scheme, type, namespace,
845
- * name, and version, but excludes qualifier and subpath from evaluation.
846
- * @deprecated
847
- * This method is no longer recommended and will be removed from a future release.
852
+ * the qualifier (querystring).
853
+ * This includes equivalence of the scheme, type, namespace, name, and version, but excludes qualifier and subpath
854
+ * from evaluation.
855
+ *
856
+ * @deprecated This method is no longer recommended and will be removed from a future release.
848
857
* <p> Use {@link PackageURL#isCoordinatesEquals} instead.</p>
849
858
*
850
859
* @param purl the Package URL to evaluate
@@ -859,8 +868,9 @@ public boolean isBaseEquals(final PackageURL purl) {
859
868
860
869
/**
861
870
* Evaluates if the specified Package URL has the same values up to, but excluding
862
- * the qualifier (querystring). This includes equivalence of: scheme, type, namespace,
863
- * name, and version, but excludes qualifier and subpath from evaluation.
871
+ * the qualifier (querystring).
872
+ * This includes equivalence of the scheme, type, namespace, name, and version, but excludes qualifier and subpath
873
+ * from evaluation.
864
874
*
865
875
* @param purl the Package URL to evaluate, not {@code null}
866
876
* @return true if equivalence passes, false if not
@@ -925,41 +935,199 @@ public int hashCode() {
925
935
* @since 1.0.0
926
936
*/
927
937
public static final class StandardTypes {
938
+ /**
939
+ * Arch Linux and other users of the libalpm/pacman package manager.
940
+ *
941
+ * @since 1.6.0
942
+ */
928
943
public static final String ALPM = "alpm" ;
944
+ /**
945
+ * APK-based packages.
946
+ *
947
+ * @since 1.6.0
948
+ */
929
949
public static final String APK = "apk" ;
950
+ /**
951
+ * Bitbucket-based packages.
952
+ */
930
953
public static final String BITBUCKET = "bitbucket" ;
954
+ /**
955
+ * Bitnami-based packages.
956
+ *
957
+ * @since 1.6.0
958
+ */
931
959
public static final String BITNAMI = "bitnami" ;
960
+ /**
961
+ * Rust.
962
+ *
963
+ * @since 1.2.0
964
+ */
932
965
public static final String CARGO = "cargo" ;
966
+ /**
967
+ * CocoaPods.
968
+ *
969
+ * @since 1.6.0
970
+ */
933
971
public static final String COCOAPODS = "cocoapods" ;
972
+ /**
973
+ * Composer PHP packages.
974
+ */
934
975
public static final String COMPOSER = "composer" ;
976
+ /**
977
+ * Conan C/C++ packages.
978
+ *
979
+ * @since 1.6.0
980
+ */
935
981
public static final String CONAN = "conan" ;
982
+ /**
983
+ * Conda packages.
984
+ *
985
+ * @since 1.6.0
986
+ */
936
987
public static final String CONDA = "conda" ;
988
+ /**
989
+ * CPAN Perl packages.
990
+ *
991
+ * @since 1.6.0
992
+ */
937
993
public static final String CPAN = "cpan" ;
994
+ /**
995
+ * CRAN R packages.
996
+ *
997
+ * @since 1.6.0
998
+ */
938
999
public static final String CRAN = "cran" ;
1000
+ /**
1001
+ * Debian, Debian derivatives, and Ubuntu packages.
1002
+ *
1003
+ * @since 1.6.0
1004
+ */
939
1005
public static final String DEB = "deb" ;
1006
+ /**
1007
+ * Docker images.
1008
+ */
940
1009
public static final String DOCKER = "docker" ;
1010
+ /**
1011
+ * RubyGems.
1012
+ */
941
1013
public static final String GEM = "gem" ;
1014
+ /**
1015
+ * Plain, generic packages that do not fit anywhere else, such as for "upstream-from-distro" packages.
1016
+ */
942
1017
public static final String GENERIC = "generic" ;
1018
+ /**
1019
+ * GitHub-based packages.
1020
+ */
943
1021
public static final String GITHUB = "github" ;
1022
+ /**
1023
+ * Go packages.
1024
+ */
944
1025
public static final String GOLANG = "golang" ;
1026
+ /**
1027
+ * Haskell packages.
1028
+ */
945
1029
public static final String HACKAGE = "hackage" ;
1030
+ /**
1031
+ * Hex packages.
1032
+ *
1033
+ * @since 1.6.0
1034
+ */
946
1035
public static final String HEX = "hex" ;
1036
+ /**
1037
+ * Hugging Face ML models.
1038
+ *
1039
+ * @since 1.6.0
1040
+ */
947
1041
public static final String HUGGINGFACE = "huggingface" ;
1042
+ /**
1043
+ * Lua packages installed with LuaRocks.
1044
+ *
1045
+ * @since 1.6.0
1046
+ */
948
1047
public static final String LUAROCKS = "luarocks" ;
1048
+ /**
1049
+ * Maven JARs and related artifacts.
1050
+ *
1051
+ * @since 1.0.0
1052
+ */
949
1053
public static final String MAVEN = "maven" ;
1054
+ /**
1055
+ * MLflow ML models (Azure ML, Databricks, etc.).
1056
+ *
1057
+ * @since 1.6.0
1058
+ */
950
1059
public static final String MLFLOW = "mlflow" ;
1060
+ /**
1061
+ * Nixos packages
1062
+ *
1063
+ * @since 1.6.0
1064
+ */
951
1065
public static final String NIX = "nix" ;
1066
+ /**
1067
+ * Node NPM packages.
1068
+ *
1069
+ * @since 1.0.0
1070
+ */
952
1071
public static final String NPM = "npm" ;
1072
+ /**
1073
+ * NuGet .NET packages.
1074
+ *
1075
+ * @since 1.0.0
1076
+ */
953
1077
public static final String NUGET = "nuget" ;
1078
+ /**
1079
+ * All artifacts stored in registries that conform to the
1080
+ * <a href="https://github.com/opencontainers/distribution-spec">OCI Distribution Specification</a>, including
1081
+ * container images built by Docker and others.
1082
+ *
1083
+ * @since 1.6.0
1084
+ */
954
1085
public static final String OCI = "oci" ;
1086
+ /**
1087
+ * Dart and Flutter packages.
1088
+ *
1089
+ * @since 1.6.0
1090
+ */
955
1091
public static final String PUB = "pub" ;
1092
+ /**
1093
+ * Python packages.
1094
+ */
956
1095
public static final String PYPI = "pypi" ;
1096
+ /**
1097
+ * QNX packages.
1098
+ *
1099
+ * @since 1.6.0
1100
+ */
957
1101
public static final String QPKG = "qpkg" ;
1102
+ /**
1103
+ * RPMs.
1104
+ */
958
1105
public static final String RPM = "rpm" ;
1106
+ /**
1107
+ * ISO-IEC 19770-2 Software Identification (SWID) tags.
1108
+ *
1109
+ * @since 1.6.0
1110
+ */
959
1111
public static final String SWID = "swid" ;
1112
+ /**
1113
+ * Swift packages.
1114
+ *
1115
+ * @since 1.6.0
1116
+ */
960
1117
public static final String SWIFT = "swift" ;
1118
+ /**
1119
+ * Debian, Debian derivatives, and Ubuntu packages.
1120
+ *
1121
+ * @deprecated use {@link #DEB} instead
1122
+ */
961
1123
@ Deprecated
962
1124
public static final String DEBIAN = "deb" ;
1125
+ /**
1126
+ * Nixos packages.
1127
+ *
1128
+ * @since 1.1.0
1129
+ * @deprecated use {@link #NIX} instead
1130
+ */
963
1131
@ Deprecated
964
1132
public static final String NIXPKGS = "nix" ;
965
1133
0 commit comments