Package org.nd4j.common.validation
Class Nd4jCommonValidator
- java.lang.Object
-
- org.nd4j.common.validation.Nd4jCommonValidator
-
public class Nd4jCommonValidator extends Object
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static StringgetPath(File f)Null-safe and "no absolute path exists" safe method for getting the path of a file for validation purposesstatic ValidationResultisValidFile(@NonNull File f)Validate whether the specified file is a valid file (must exist and be non-empty)static ValidationResultisValidFile(@NonNull File f, String formatType, boolean allowEmpty)Validate whether the specified file is a valid filestatic ValidationResultisValidJson(@NonNull File f, Charset charset)Validate whether the specified file is a valid JSON file.protected static ValidationResultisValidJson(String content, File f)static ValidationResultisValidJSON(String s)Validate whether the specified String is valid JSON.static ValidationResultisValidJsonUTF8(@NonNull File f)static ValidationResultisValidZipFile(@NonNull File f, boolean allowEmpty)Validate whether the specified file is a valid Zip filestatic ValidationResultisValidZipFile(@NonNull File f, boolean allowEmpty, String... requiredEntries)Validate whether the specified file is a valid Zip filestatic ValidationResultisValidZipFile(@NonNull File f, boolean allowEmpty, List<String> requiredEntries)Validate whether the specified file is a valid Zip file, and contains all of the required entries
-
-
-
Method Detail
-
isValidFile
public static ValidationResult isValidFile(@NonNull @NonNull File f)
Validate whether the specified file is a valid file (must exist and be non-empty)- Parameters:
f- File to check- Returns:
- Result of validation
-
isValidFile
public static ValidationResult isValidFile(@NonNull @NonNull File f, String formatType, boolean allowEmpty)
Validate whether the specified file is a valid file- Parameters:
f- File to checkformatType- Name of the file format to include in validation resultsallowEmpty- If true: allow empty files to pass. False: empty files will fail validation- Returns:
- Result of validation
-
isValidJsonUTF8
public static ValidationResult isValidJsonUTF8(@NonNull @NonNull File f)
-
isValidJson
public static ValidationResult isValidJson(@NonNull @NonNull File f, Charset charset)
Validate whether the specified file is a valid JSON file. Note that this does not match the JSON content against a specific schema- Parameters:
f- File to checkcharset- Character set for file- Returns:
- Result of validation
-
isValidJSON
public static ValidationResult isValidJSON(String s)
Validate whether the specified String is valid JSON. Note that this does not match the JSON content against a specific schema- Parameters:
s- JSON String to check- Returns:
- Result of validation
-
isValidJson
protected static ValidationResult isValidJson(String content, File f)
-
isValidZipFile
public static ValidationResult isValidZipFile(@NonNull @NonNull File f, boolean allowEmpty)
Validate whether the specified file is a valid Zip file- Parameters:
f- File to checkallowEmpty- If true: allow empty zip files to pass validation. False: empty zip files will fail validation.- Returns:
- Result of validation
-
isValidZipFile
public static ValidationResult isValidZipFile(@NonNull @NonNull File f, boolean allowEmpty, String... requiredEntries)
Validate whether the specified file is a valid Zip file- Parameters:
f- File to checkallowEmpty- If true: allow empty zip files to pass validation. False: empty zip files will fail validation.- Returns:
- Result of validation
-
isValidZipFile
public static ValidationResult isValidZipFile(@NonNull @NonNull File f, boolean allowEmpty, List<String> requiredEntries)
Validate whether the specified file is a valid Zip file, and contains all of the required entries- Parameters:
f- File to checkallowEmpty- If true: allow empty zip files to pass validation. False: empty zip files will fail validation.requiredEntries- If non-null, all of the specified entries must be present for the file to pass validation- Returns:
- Result of validation
-
-