Package eu.europa.esig.dss.utils
Interface IUtils
- All Known Implementing Classes:
ApacheCommonsUtils
,GoogleGuavaUtils
public interface IUtils
-
Method Summary
Modifier and Type Method Description boolean
areStringsEqual(String text1, String text2)
Checks if the strings are equal Ex.boolean
areStringsEqualIgnoreCase(String text1, String text2)
Checks if the strings are equal with case ignore Ex.void
cleanDirectory(File directory)
Cleans the directoryvoid
closeQuietly(Closeable closeable)
Closes quietlyint
collectionSize(Collection collection)
Gets the size of the collectionvoid
copy(InputStream is, OutputStream os)
Copiesis
toos
boolean
endsWithIgnoreCase(String text, String expected)
Checks if the string ends with case ignore Ex.byte[]
fromBase64(String base64)
Transforms a base64-encoded string to byte arraybyte[]
fromHex(String hex)
Transforms a HEX-encoded string to byte arraylong
getInputStreamSize(InputStream is)
Gets the size of the InputStream contentboolean
isArrayEmpty(byte[] array)
Checks if the byte array is null or emptyboolean
isArrayEmpty(Object[] array)
Checks if the array is null or emptyboolean
isArrayNotEmpty(byte[] array)
Checks if the byte array is not null nor emptyboolean
isArrayNotEmpty(Object[] array)
Checks if the array is not null nor emptyboolean
isBase64Encoded(String base64String)
Checks if the string is base64-encodedboolean
isCollectionEmpty(Collection collection)
Checks if the collection is null or emptyboolean
isCollectionNotEmpty(Collection collection)
Checks if the collection is not null nor emptyboolean
isHexEncoded(String hexString)
Checks if the string is HEX (base16) encodedboolean
isMapEmpty(Map<?,?> map)
Checks if the map is null or emptyboolean
isMapNotEmpty(Map<?,?> map)
Checks if the map is not null nor emptyboolean
isStringBlank(String text)
Checks if the string is blank Ex.boolean
isStringDigits(String text)
Checks if the string contains only digits Ex. "123" = true; "1a2b" = falseboolean
isStringEmpty(String text)
Checks if the string is empty Ex.boolean
isStringNotBlank(String text)
Checks if the string is not blank Ex.boolean
isStringNotEmpty(String text)
Checks if the string is not empty Ex.boolean
isTrue(Boolean bool)
Checks if the Boolean value is set to true NOTE: if null, returns false!String
joinStrings(Collection<String> strings, String separator)
Joins the strings with the given separator Ex.Collection<File>
listFiles(File folder, String[] extensions, boolean recursive)
Lists all files from thefolder
with the givenextensions
String
lowerCase(String text)
Converts a string to its lower case representation Ex.<T> List<T>
reverseList(List<T> list)
Creates a reversed copy of the listbyte[]
subarray(byte[] array, int start, int length)
Returns a subArray, starting from positionstart
with the defined lengthlength
String
substringAfter(String text, String after)
Returns a substring after the specified character Ex.String
toBase64(byte[] bytes)
Transforms the binaries to String base64-encoded representationbyte[]
toByteArray(InputStream is)
Reads the InputStream and returns the resulting byte arrayString
toHex(byte[] bytes)
Transforms the binaries to String HEX representationString
trim(String text)
Trims the string, by removing all leading and descending spaces and lines Ex. " 123 " = "123"String
upperCase(String text)
Converts a string to its upper case representation Ex.void
write(byte[] content, OutputStream os)
Writescontent
toos
-
Method Details
-
isStringEmpty
Checks if the string is empty Ex. "nowina" = false; "" = true NOTE: blank string (e.g. " ") is not empty!- Parameters:
text
-String
- Returns:
- TRUE if the string is empty, FALSE otherwise
-
isStringNotEmpty
Checks if the string is not empty Ex. "nowina" = true; "" = false NOTE: blank string (e.g. " ") is not empty!- Parameters:
text
-String
- Returns:
- TRUE if the string is not empty, FALSE otherwise
-
isStringBlank
Checks if the string is blank Ex. "nowina" = false; " " = true- Parameters:
text
-String
- Returns:
- TRUE if the string is blank, FALSE otherwise
-
isStringNotBlank
Checks if the string is not blank Ex. "nowina" = true; " " = false- Parameters:
text
-String
- Returns:
- TRUE if the string is not blank, FALSE otherwise
-
areStringsEqual
Checks if the strings are equal Ex. "nowina" == "nowina" = true; "nowina" == "Nowina" = false -
areStringsEqualIgnoreCase
Checks if the strings are equal with case ignore Ex. "nowina" == "Nowina" = true; "water" == "fire" = false -
isStringDigits
Checks if the string contains only digits Ex. "123" = true; "1a2b" = false- Parameters:
text
-String
- Returns:
- TRUE if the string contains only digits, FALSE otherwise
-
trim
Trims the string, by removing all leading and descending spaces and lines Ex. " 123 " = "123"- Parameters:
text
-String
- Returns:
- the trimmed string
-
joinStrings
Joins the strings with the given separator Ex. "Nowina" "123", "," = "Nowina,123" -
substringAfter
Returns a substring after the specified character Ex. "aaaaa?bbb", "?" = "bbb" -
endsWithIgnoreCase
Checks if the string ends with case ignore Ex. "hello", "LO" = true; "hello", "a" = false -
lowerCase
Converts a string to its lower case representation Ex. "Nowina" = "nowina"- Parameters:
text
-String
- Returns:
- the lower case string
-
upperCase
Converts a string to its upper case representation Ex. "Nowina" = "NOWINA"- Parameters:
text
-String
- Returns:
- the upper case string
-
isArrayEmpty
Checks if the array is null or empty- Parameters:
array
- to check- Returns:
- TRUE if the array is null or empty, FALSE otherwise
-
isArrayNotEmpty
Checks if the array is not null nor empty- Parameters:
array
- to check- Returns:
- TRUE if the array is not null nor empty, FALSE otherwise
-
isArrayEmpty
boolean isArrayEmpty(byte[] array)Checks if the byte array is null or empty- Parameters:
array
- byte array to check- Returns:
- TRUE if the byte array is null or empty, FALSE otherwise
-
isArrayNotEmpty
boolean isArrayNotEmpty(byte[] array)Checks if the byte array is not null nor empty- Parameters:
array
- byte array to check- Returns:
- TRUE if the byte array is not null nor empty, FALSE otherwise
-
subarray
byte[] subarray(byte[] array, int start, int length)Returns a subArray, starting from positionstart
with the defined lengthlength
- Parameters:
array
- byte array to get subArray fromstart
- the start index of the subArraylength
- the length of the subArray- Returns:
- subArray
-
isTrue
Checks if the Boolean value is set to true NOTE: if null, returns false!- Parameters:
bool
-Boolean
- Returns:
- TRUE if the value is set to true, FALSE otherwise
-
isCollectionEmpty
Checks if the collection is null or empty- Parameters:
collection
- to check- Returns:
- TRUE if the collection is null or empty, FALSE otherwise
-
isCollectionNotEmpty
Checks if the collection is not null nor empty- Parameters:
collection
- to check- Returns:
- TRUE if the collection is not null nor empty, FALSE otherwise
-
isMapEmpty
Checks if the map is null or empty- Parameters:
map
- to check- Returns:
- TRUE if the map is null or empty, FALSE otherwise
-
isMapNotEmpty
Checks if the map is not null nor empty- Parameters:
map
- to check- Returns:
- TRUE if the map is not null nor empty, FALSE otherwise
-
collectionSize
Gets the size of the collection- Parameters:
collection
-Collection
- Returns:
- size of the collection
-
isHexEncoded
Checks if the string is HEX (base16) encoded- Parameters:
hexString
-String
- Returns:
- TRUE if he string is HEX encoded, FALSE otherwise
-
toHex
Transforms the binaries to String HEX representation- Parameters:
bytes
- byte array- Returns:
String
HEX-encoded
-
fromHex
Transforms a HEX-encoded string to byte array- Parameters:
hex
-String
hex-encoded- Returns:
- byte array
-
isBase64Encoded
Checks if the string is base64-encoded- Parameters:
base64String
-String
- Returns:
- TRUE if he string is base64-encoded, FALSE otherwise
-
toBase64
Transforms the binaries to String base64-encoded representation- Parameters:
bytes
- byte array- Returns:
String
base64-encoded
-
fromBase64
Transforms a base64-encoded string to byte array- Parameters:
base64
-String
base64-encoded- Returns:
- byte array
-
toByteArray
Reads the InputStream and returns the resulting byte array- Parameters:
is
-InputStream
- Returns:
- byte array
- Throws:
IOException
- if an exception occurs
-
closeQuietly
Closes quietly- Parameters:
closeable
-Closeable
-
copy
Copiesis
toos
- Parameters:
is
-InputStream
to copyos
-OutputStream
to write the value into- Throws:
IOException
- if an exception occurs
-
write
Writescontent
toos
- Parameters:
content
- byte array to writeos
-OutputStream
to write the value into- Throws:
IOException
- if an exception occurs
-
getInputStreamSize
Gets the size of the InputStream content- Parameters:
is
-InputStream
- Returns:
- size
- Throws:
IOException
- if an exception occurs
-
cleanDirectory
Cleans the directory- Parameters:
directory
-File
- Throws:
IOException
- if an exception occurs
-
listFiles
Lists all files from thefolder
with the givenextensions
-
reverseList
Creates a reversed copy of the list- Type Parameters:
T
- the class of list elements- Parameters:
list
-List
to get a reversed copy of- Returns:
- reversed list
-