java.lang.Object
ushiosan.jvm.internal.validators.UResourceValidator
ushiosan.jvm.internal.filesystem.UResourceImpl
ushiosan.jvm.filesystem.UResource
-
Field Summary
Fields inherited from class ushiosan.jvm.internal.validators.UResourceValidator
FS_DEFAULT_ALGORITHM, FS_EMPTY_EXTENSIONS, FS_EXTENSION_IDENTIFIER, FS_RESOURCE_BUFFER_SIZE_STANDARD, FS_STANDARD_FILE_SEPARATOR -
Method Summary
Modifier and TypeMethodDescriptionallExtensions(@NotNull File file) Gets all existing extensions in a resource location.allExtensions(@NotNull Path path) Gets all existing extensions in a resource location.allExtensions(@NotNull ZipEntry entry) Gets all existing extensions in a resource location.Gets the resource basename, without any extension.Gets the resource basename, without any extension.Gets the resource basename, without any extension.Gets the resource basename, without any extension.Gets the resource basename, without any extension.Gets the resource basename, without any extension.static voidReleases connections to all virtual file systems created by thepathOf(URI)method for jar or jrt files.static voidReleases connections to all virtual file systems created by thepathOf(URI)method for jar or jrt files.Gets the resource extension.Gets the resource extension.Gets the resource extension.static @NotNull FileSystemfileSystem(@NotNull URI uri) Gets a valid file system depending on the scheme of the given urlstatic @NotNull FileSystemfileSystem(@NotNull URL url) Returns a valid file system depending on the scheme of the given urlGets the path of an uri in the file system (if the scheme is supported).Gets the path of an url in the file system (if the scheme is supported).static byte[]resourceHash(@NotNull File file) Get the hash of the given resourcestatic byte[]resourceHash(@NotNull File file, @NotNull String algorithm) Get the hash of the given resourcestatic byte[]resourceHash(@NotNull InputStream stream) Get the hash of the given streamstatic byte[]resourceHash(@NotNull InputStream stream, @NotNull String algorithm) Get the hash of the given streamstatic byte[]resourceHash(@NotNull Path path) Get the hash of the given resourcestatic byte[]resourceHash(@NotNull Path path, @NotNull String algorithm) Get the hash of the given resourcestatic byte[]resourceHash(@NotNull ZipFile file, @NotNull ZipEntry entry) Get the hash of the given resourcestatic byte[]Get the hash of the given resourceresourceHashStr(byte[] hash) Get the hash of the given resource This method returns the hash as hexadecimal string.resourceHashStr(@NotNull InputStream stream) Get the hash of the given resource This method returns the hash as hexadecimal string.resourceHashStr(@NotNull InputStream stream, @NotNull String algorithm) Get the hash of the given resource This method returns the hash as hexadecimal string.resourceName(@NotNull File file) Gets the resource name without the slashes and the absolute pathresourceName(@NotNull Path path) Gets the resource name without the slashes and the absolute pathresourceName(@NotNull ZipEntry entry) Gets the resource name without the slashes and the absolute pathGenerates a stream where it recursively iterates through all the directories within the given destination.userDirectory(String @NotNull ... items) Gets a specific path within the user's folder.Methods inherited from class ushiosan.jvm.internal.filesystem.UResourceImpl
extensionsEntryOf, extensionsFileOf, extensionsPathOf, jrtFileAccess, jrtModuleName, namedEntryOf, namedFileOf, namedPathOf, regexEntryOf, regexEntryOf, regexEntryOf, regexFileOf, regexFileOf, regexFileOf, regexPathOf, regexPathOf, regexPathOfMethods inherited from class ushiosan.jvm.internal.validators.UResourceValidator
allExtensionsImpl, basenameImpl, createByteBuffer, extensionImpl, nameWithoutSlashesImpl, resourceHashImpl
-
Method Details
-
userDirectory
Gets a specific path within the user's folder.- Parameters:
items- the relative user's folder location- Returns:
- the resolved user relative path
-
resourceWalk
@SafeVarargs @NotNull public static @NotNull Stream<Path> resourceWalk(@NotNull @NotNull Path path, boolean recursive, Predicate<Path> @NotNull ... predicates) throws IOException Generates a stream where it recursively iterates through all the directories within the given destination.- Parameters:
path- base directoryrecursive- determines if the stream is required to be recursive or just the first directorypredicates- filters applied to the stream- Returns:
- a stream with all the given settings
- Throws:
IOException- error if directory not exists or location is not a valid directory- See Also:
-
resourceName
Gets the resource name without the slashes and the absolute path- Parameters:
path- the resource location to analyze- Returns:
- the resource without the slashes
-
resourceName
Gets the resource name without the slashes and the absolute path- Parameters:
file- the resource location to analyze- Returns:
- the resource without the slashes
-
resourceName
Gets the resource name without the slashes and the absolute path- Parameters:
entry- the resource location to analyze- Returns:
- the resource without the slashes
-
basename
Gets the resource basename, without any extension.- Parameters:
path- the resource location to analyzepartial- returns the full or partial name- Returns:
- the resource basename
-
basename
Gets the resource basename, without any extension.- Parameters:
path- the resource location to analyze- Returns:
- the resource basename
-
basename
Gets the resource basename, without any extension.- Parameters:
file- the resource location to analyzepartial- returns the full or partial name- Returns:
- the resource basename
-
basename
Gets the resource basename, without any extension.- Parameters:
file- the resource location to analyze- Returns:
- the resource basename
-
basename
Gets the resource basename, without any extension.- Parameters:
entry- the resource location to analyzepartial- returns the full or partial name- Returns:
- the resource basename
-
basename
Gets the resource basename, without any extension.- Parameters:
entry- the resource location to analyze- Returns:
- the resource basename
-
allExtensions
Gets all existing extensions in a resource location.- Parameters:
path- the resource location to analyze- Returns:
- all resource extensions
- Throws:
IllegalArgumentException- error if resource is an invalid regular file- See Also:
-
allExtensions
Gets all existing extensions in a resource location.- Parameters:
file- the resource location to analyze- Returns:
- all resource extensions
- Throws:
IllegalArgumentException- error if resource is an invalid regular file- See Also:
-
allExtensions
Gets all existing extensions in a resource location.- Parameters:
entry- the resource location to analyze- Returns:
- all resource extensions
- Throws:
IllegalArgumentException- error if resource is an invalid regular file- See Also:
-
extension
Gets the resource extension.- Parameters:
path- the resource location to analyze- Returns:
- returns the resource extension or
Optional.empty()if the extension not exists - Throws:
IllegalArgumentException- error if resource is an invalid regular file- See Also:
-
extension
Gets the resource extension.- Parameters:
file- the resource location to analyze- Returns:
- returns the resource extension or
Optional.empty()if the extension not exists - Throws:
IllegalArgumentException- error if resource is an invalid regular file- See Also:
-
extension
Gets the resource extension.- Parameters:
entry- the resource location to analyze- Returns:
- returns the resource extension or
Optional.empty()if the extension not exists - Throws:
IllegalArgumentException- error if resource is an invalid regular file- See Also:
-
resourceHash
public static byte[] resourceHash(@NotNull @NotNull InputStream stream, @NotNull @NotNull String algorithm) throws IOException, NoSuchAlgorithmException Get the hash of the given stream- Parameters:
stream- the content streamalgorithm- hash algorithm- Returns:
- the stream hash
- Throws:
NoSuchAlgorithmException- error if algorithm not existsIOException- error to read stream content
-
resourceHash
public static byte[] resourceHash(@NotNull @NotNull InputStream stream) throws IOException, NoSuchAlgorithmException Get the hash of the given stream- Parameters:
stream- the content stream- Returns:
- the stream hash
- Throws:
NoSuchAlgorithmException- error if algorithm not existsIOException- error to read stream content
-
resourceHash
public static byte[] resourceHash(@NotNull @NotNull Path path, @NotNull @NotNull String algorithm) throws IOException, NoSuchAlgorithmException Get the hash of the given resource- Parameters:
path- the resource locationalgorithm- hash algorithm- Returns:
- the resource hash
- Throws:
NoSuchAlgorithmException- error if algorithm not existsIOException- error to read stream content
-
resourceHash
public static byte[] resourceHash(@NotNull @NotNull Path path) throws IOException, NoSuchAlgorithmException Get the hash of the given resource- Parameters:
path- the resource location- Returns:
- the resource hash
- Throws:
NoSuchAlgorithmException- error if algorithm not existsIOException- error to read stream content
-
resourceHash
public static byte[] resourceHash(@NotNull @NotNull File file, @NotNull @NotNull String algorithm) throws IOException, NoSuchAlgorithmException Get the hash of the given resource- Parameters:
file- the resource locationalgorithm- hash algorithm- Returns:
- the resource hash
- Throws:
NoSuchAlgorithmException- error if algorithm not existsIOException- error to read stream content
-
resourceHash
public static byte[] resourceHash(@NotNull @NotNull File file) throws IOException, NoSuchAlgorithmException Get the hash of the given resource- Parameters:
file- the resource location- Returns:
- the resource hash
- Throws:
NoSuchAlgorithmException- error if algorithm not existsIOException- error to read stream content
-
resourceHash
public static byte[] resourceHash(@NotNull @NotNull ZipFile file, @NotNull @NotNull ZipEntry entry, @NotNull @NotNull String algorithm) throws IOException, NoSuchAlgorithmException Get the hash of the given resource- Parameters:
file- the root zip fileentry- the resource locationalgorithm- hash algorithm- Returns:
- the resource hash
- Throws:
NoSuchAlgorithmException- error if algorithm not existsIOException- error to read stream content
-
resourceHash
public static byte[] resourceHash(@NotNull @NotNull ZipFile file, @NotNull @NotNull ZipEntry entry) throws IOException, NoSuchAlgorithmException Get the hash of the given resource- Parameters:
file- the root zip fileentry- the resource location- Returns:
- the resource hash
- Throws:
NoSuchAlgorithmException- error if algorithm not existsIOException- error to read stream content
-
resourceHashStr
Get the hash of the given resource This method returns the hash as hexadecimal string.- Parameters:
hash- resource hash- Returns:
- hash as hexadecimal string
-
resourceHashStr
@NotNull public static @NotNull String resourceHashStr(@NotNull @NotNull InputStream stream, @NotNull @NotNull String algorithm) throws IOException, NoSuchAlgorithmException Get the hash of the given resource This method returns the hash as hexadecimal string.- Parameters:
stream- the content streamalgorithm- hash algorithm- Returns:
- hash as hexadecimal string
- Throws:
NoSuchAlgorithmException- error if algorithm not existsIOException- error to read stream content
-
resourceHashStr
@NotNull public static @NotNull String resourceHashStr(@NotNull @NotNull InputStream stream) throws IOException, NoSuchAlgorithmException Get the hash of the given resource This method returns the hash as hexadecimal string.- Parameters:
stream- the content stream- Returns:
- hash as hexadecimal string
- Throws:
NoSuchAlgorithmException- error if algorithm not existsIOException- error to read stream content
-
fileSystem
Returns a valid file system depending on the scheme of the given url- Parameters:
url- the url to inspect- Returns:
- valid filesystem
- Throws:
IOException- error if url schema is not supported
-
fileSystem
Gets a valid file system depending on the scheme of the given url- Parameters:
uri- the url to inspect- Returns:
- valid filesystem
- Throws:
IOException- error if url schema is not supported
-
disposeFilesystems
public static void disposeFilesystems()Releases connections to all virtual file systems created by thepathOf(URI)method for jar or jrt files.If you do not want to free all file systems then use the
disposeFilesystemsIf(Function)method. -
disposeFilesystemsIf
Releases connections to all virtual file systems created by thepathOf(URI)method for jar or jrt files.- Parameters:
filter- The action responsible for filtering the elements that must be deleted.
-
pathOf
Gets the path of an url in the file system (if the scheme is supported).If the schema is a jar file, the virtual representation of the file as a directory will be returned.
- Parameters:
url- the url to inspect- Returns:
- a valid file path
- Throws:
IOException- error if given url is not supported
-
pathOf
Gets the path of an uri in the file system (if the scheme is supported).If the schema is a jar file, the virtual representation of the file as a directory will be returned.
Important
For files within a
"jrt"file system it is necessary to recreate the URI object for it to work correctly. If it is accessed from theURIobject itself, the path structure would be as follows:
which is incorrect and the correct way would be the following:/jrt:/<module-name>/<file-path>
I still don't know why the/modules/<module-name>/<file-path>Pathclass does this, but the most reliable thing for now is to recreate theURIwith the correct information. When I find a more efficient way, I'll include it in future updates.- Parameters:
uri- the url to inspect- Returns:
- a valid file path
- Throws:
IOException- error if given url is not supported
-