Class UResourceValidator

java.lang.Object
ushiosan.jvm.internal.validators.UResourceValidator
Direct Known Subclasses:
UResourceImpl

public abstract class UResourceValidator extends Object
  • Field Details

    • FS_EMPTY_EXTENSIONS

      protected static final String[] FS_EMPTY_EXTENSIONS
      Empty extensions array
    • FS_STANDARD_FILE_SEPARATOR

      protected static final char FS_STANDARD_FILE_SEPARATOR
      Character used to identify all standard file separators
      See Also:
    • FS_EXTENSION_IDENTIFIER

      protected static final char FS_EXTENSION_IDENTIFIER
      Character used to identify all file extensions
      See Also:
    • FS_RESOURCE_BUFFER_SIZE_STANDARD

      protected static final int FS_RESOURCE_BUFFER_SIZE_STANDARD
      Standard size for data buffers
      See Also:
    • FS_DEFAULT_ALGORITHM

      protected static final String FS_DEFAULT_ALGORITHM
      Hash Algorithm for resourceHashImpl(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

    • nameWithoutSlashesImpl

      @NotNull protected static @NotNull String nameWithoutSlashesImpl(@NotNull @NotNull String location)
      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)
      Gets the file base name, without any extension.

      Example:

      
       "build.gradle.kts" -> build
       "example.file.java" -> example
       
      Parameters:
      location - the file location to analyze
      Returns:
      the file base name
    • allExtensionsImpl

      protected static String @NotNull [] allExtensionsImpl(@NotNull @NotNull String location)
      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

      @NotNull protected static @NotNull Optional<String> extensionImpl(String @NotNull [] extensions)
      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 stream
      algorithm - hash algorithm
      Returns:
      the stream hash
      Throws:
      NoSuchAlgorithmException - error if algorithm not exists
      IOException - error to read stream content