java.lang.Object
ushiosan.jvm.internal.validators.UResourceValidator
- Direct Known Subclasses:
UResourceImpl
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected static final StringHash Algorithm forresourceHashImpl(InputStream, String)Function.protected static final String[]Empty extensions arrayprotected static final charCharacter used to identify all file extensionsprotected static final intStandard size for data buffersprotected static final charCharacter used to identify all standard file separators -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionallExtensionsImpl(@NotNull String location) Gets all existing extensions in a location.basenameImpl(@NotNull String location, boolean directory, boolean partial) Gets the file base name, without any extension.static byte @NotNull []Create a container with a standard size for handling external data.extensionImpl(String @NotNull [] extensions) Gets the resource extension.nameWithoutSlashesImpl(@NotNull String location) Gets the document without the slashes and the absolute pathprotected static byte[]resourceHashImpl(@NotNull InputStream stream, @NotNull String algorithm) Get the hash of the given stream
-
Field Details
-
FS_EMPTY_EXTENSIONS
Empty extensions array -
FS_STANDARD_FILE_SEPARATOR
protected static final char FS_STANDARD_FILE_SEPARATORCharacter used to identify all standard file separators- See Also:
-
FS_EXTENSION_IDENTIFIER
protected static final char FS_EXTENSION_IDENTIFIERCharacter used to identify all file extensions- See Also:
-
FS_RESOURCE_BUFFER_SIZE_STANDARD
protected static final int FS_RESOURCE_BUFFER_SIZE_STANDARDStandard size for data buffers- See Also:
-
FS_DEFAULT_ALGORITHM
Hash Algorithm forresourceHashImpl(InputStream, String)Function. It must be remembered that 64-bit platforms work better with 64-bit algorithms such as SHA-512 and 32-bit platforms with SHA-256, but it is possible to use both on any platform, it is only done this way for performance reasons.
-
-
Constructor Details
-
UResourceValidator
public UResourceValidator()
-
-
Method Details
-
createByteBuffer
Create a container with a standard size for handling external data.- Returns:
- an empty data array
-
nameWithoutSlashesImpl
Gets the document without the slashes and the absolute path- Parameters:
location- the file location to analyze- Returns:
- the file without the slashes
-
basenameImpl
@NotNull protected static @NotNull String basenameImpl(@NotNull @NotNull String location, boolean directory, boolean partial) Gets the file base name, without any extension.Example:
"build.gradle.kts" -> build | build.gradle "example.file.java" -> example | example.file- Parameters:
location- the file location to analyzedirectory- determines if the resource is a directorypartial- returns the full or partial name- Returns:
- the file base name
-
allExtensionsImpl
Gets all existing extensions in a location.Example:
"build.gradle.kts" -> [gradle, kts] "example.file.java" -> [file, java]- Parameters:
location- the file location to analyze- Returns:
- all file extensions
-
extensionImpl
Gets the resource extension.Example:
"build.gradle.kts" -> Optional["kts"] "example.file.java" -> Optional["java"] "binary_file" -> Optional[empty]- Parameters:
extensions- all extensions extensions- Returns:
- returns the file extension or
Optional.empty()if the extension not exists
-
resourceHashImpl
protected static byte[] resourceHashImpl(@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
-