Package org.apache.maven.api.services
Interface ChecksumAlgorithmService
- All Superinterfaces:
Service
Checksum algorithms service.
- Since:
- 4.0.0
-
Nested Class Summary
Modifier and TypeInterfaceDescriptionstatic interface
The checksum algorithm.static interface
The checksum calculator. -
Method Summary
Modifier and TypeMethodDescriptioncalculate
(byte[] data, Collection<ChecksumAlgorithmService.ChecksumAlgorithm> algorithms) Calculates checksums for specified data.calculate
(InputStream stream, Collection<ChecksumAlgorithmService.ChecksumAlgorithm> algorithms) Calculates checksums for specified stream.calculate
(ByteBuffer data, Collection<ChecksumAlgorithmService.ChecksumAlgorithm> algorithms) Calculates checksums for specified data.calculate
(Path file, Collection<ChecksumAlgorithmService.ChecksumAlgorithm> algorithms) Calculates checksums for specified file.Returns immutable collection of all supported algorithm names.ReturnsChecksumAlgorithmService.ChecksumAlgorithm
for given algorithm name, or throws if algorithm not supported.select
(Collection<String> algorithmNames) Returns a collection ofChecksumAlgorithmService.ChecksumAlgorithm
in same order as algorithm names are ordered, or throws if any of the algorithm name is not supported.
-
Method Details
-
getChecksumAlgorithmNames
Returns immutable collection of all supported algorithm names. -
select
ReturnsChecksumAlgorithmService.ChecksumAlgorithm
for given algorithm name, or throws if algorithm not supported.- Throws:
ChecksumAlgorithmServiceException
- if asked algorithm name is not supported.NullPointerException
- if passed in name isnull
.
-
select
@Nonnull Collection<ChecksumAlgorithmService.ChecksumAlgorithm> select(@Nonnull Collection<String> algorithmNames) Returns a collection ofChecksumAlgorithmService.ChecksumAlgorithm
in same order as algorithm names are ordered, or throws if any of the algorithm name is not supported. The returned collection has equal count of elements as passed in collection of names, and if names contains duplicated elements, the returned list of algorithms will have duplicates as well.- Throws:
ChecksumAlgorithmServiceException
- if any asked algorithm name is not supported.NullPointerException
- if passed in list of names isnull
.
-
calculate
@Nonnull Map<ChecksumAlgorithmService.ChecksumAlgorithm,String> calculate(@Nonnull byte[] data, @Nonnull Collection<ChecksumAlgorithmService.ChecksumAlgorithm> algorithms) Calculates checksums for specified data.- Parameters:
data
- The content for which to calculate checksums, must not benull
.algorithms
- The checksum algorithms to use, must not benull
.- Returns:
- The calculated checksums, indexed by algorithms, never
null
. - Throws:
NullPointerException
- if passed in any parameter isnull
.
-
calculate
@Nonnull Map<ChecksumAlgorithmService.ChecksumAlgorithm,String> calculate(@Nonnull ByteBuffer data, @Nonnull Collection<ChecksumAlgorithmService.ChecksumAlgorithm> algorithms) Calculates checksums for specified data.- Parameters:
data
- The content for which to calculate checksums, must not benull
.algorithms
- The checksum algorithms to use, must not benull
.- Returns:
- The calculated checksums, indexed by algorithms, never
null
. - Throws:
NullPointerException
- if passed in any parameter isnull
.
-
calculate
@Nonnull Map<ChecksumAlgorithmService.ChecksumAlgorithm,String> calculate(@Nonnull Path file, @Nonnull Collection<ChecksumAlgorithmService.ChecksumAlgorithm> algorithms) throws IOException Calculates checksums for specified file.- Parameters:
file
- The file for which to calculate checksums, must not benull
.algorithms
- The checksum algorithms to use, must not benull
.- Returns:
- The calculated checksums, indexed by algorithms, never
null
. - Throws:
NullPointerException
- if passed in any parameter isnull
.IOException
- In case of any IO problem.
-
calculate
@Nonnull Map<ChecksumAlgorithmService.ChecksumAlgorithm,String> calculate(@Nonnull InputStream stream, @Nonnull Collection<ChecksumAlgorithmService.ChecksumAlgorithm> algorithms) throws IOException Calculates checksums for specified stream. Upon this method returns, the stream will be depleted (fully read) but not closed.- Parameters:
stream
- The stream for which to calculate checksums, must not benull
.algorithms
- The checksum algorithms to use, must not benull
.- Returns:
- The calculated checksums, indexed by algorithms, never
null
. - Throws:
NullPointerException
- if passed in any parameter isnull
.IOException
- In case of any IO problem.
-