Package es.gob.afirma.utils
Class GenericUtilsCommons
- java.lang.Object
-
- es.gob.afirma.utils.GenericUtilsCommons
-
public final class GenericUtilsCommons extends java.lang.ObjectClass with generic utilities.
Project:Library for the integration with the services of @Firma, eVisor and TS@.
- Version:
- 1.1, 18/04/2022.
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static booleanassertArrayValid(byte[] data)Asserts whether a array is valid (not null and not empty).static booleanassertStringValue(java.lang.String value)Asserts whether a value is valid (not null or not empty).static voidcheckInputParameterIsNotNull(java.lang.Object inputParameter, java.lang.String errorMsg)Method that checks if an input parameter isnull.static booleancheckNullValues(java.lang.Object... values)Checks if a value is null.static byte[]getDataFromInputStream(java.io.InputStream input)Reads and converts a bytes stream to byte array.static java.lang.StringgetValueFromMapsTree(java.lang.String path, java.util.Map<java.lang.String,java.lang.Object> treeValues)Retrieves a value from a tree of several maps by a path given.static voidprintResult(byte[] result, Logger logger)Prints the resulting data in base64 format.
-
-
-
Method Detail
-
assertStringValue
public static boolean assertStringValue(java.lang.String value)
Asserts whether a value is valid (not null or not empty).- Parameters:
value- string to validate.- Returns:
- true if string is valid and false otherwise.
-
assertArrayValid
public static boolean assertArrayValid(byte[] data)
Asserts whether a array is valid (not null and not empty).- Parameters:
data- array to validate.- Returns:
- true if array is valid and false otherwise.
-
getValueFromMapsTree
public static java.lang.String getValueFromMapsTree(java.lang.String path, java.util.Map<java.lang.String,java.lang.Object> treeValues)Retrieves a value from a tree of several maps by a path given.- Parameters:
path- path of maps tree separated by '/'.treeValues- collection of maps (type: Map@lt;String, Object@gt;).- Returns:
- value of the key requested.
-
getDataFromInputStream
public static byte[] getDataFromInputStream(java.io.InputStream input) throws java.io.IOExceptionReads and converts a bytes stream to byte array.- Parameters:
input- input stream to convert.- Returns:
- byte array with data.
- Throws:
java.io.IOException- If the first byte cannot be read for any reason other than the end of the file, if the input stream has been closed, or if some other I/O error occurs.
-
checkNullValues
public static boolean checkNullValues(java.lang.Object... values)
Checks if a value is null.- Parameters:
values- collection of values to validate.- Returns:
- true if any parameter is null and false if all parameters are valid (not null).
-
printResult
public static void printResult(byte[] result, Logger logger)Prints the resulting data in base64 format.- Parameters:
result- result bytes.logger- logger object used for print.
-
checkInputParameterIsNotNull
public static void checkInputParameterIsNotNull(java.lang.Object inputParameter, java.lang.String errorMsg)Method that checks if an input parameter isnull. If the input parameter isnullthe method will throw aIllegalArgumentException.- Parameters:
inputParameter- Parameter that represents the element to check.errorMsg- Parameter that represents the error message associated to the exception if the input parameter isnull.
-
-