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