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