Class GoogleGuavaUtils
java.lang.Object
eu.europa.esig.dss.utils.guava.impl.GoogleGuavaUtils
- All Implemented Interfaces:
IUtils
Google Guava implementation of Utils
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionboolean
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 collectionboolean
compareInputStreams
(InputStream stream1, InputStream stream2) Compares content of twoInputStream
s<T> boolean
containsAny
(Collection<T> superCollection, Collection<T> subCollection) This method returns boolean result whether thesuperCollection
contains any element of thesubCollection
Ex.void
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[]
Transforms a HEX-encoded string to byte arraygetFileNameExtension
(String filename) This method returns an extension for the given filename Ex.long
Gets the size of the InputStream contentboolean
isArrayEmpty
(byte[] array) Checks if the byte array is null or emptyboolean
isArrayEmpty
(char[] array) Checks if the char 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
(char[] array) Checks if the char 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.boolean
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
Checks if the Boolean value is set to true NOTE: if null, returns false!joinStrings
(Collection<String> strings, String separator) Joins the strings with the given separator Ex.Lists all files from thefolder
with the givenextensions
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
substringAfter
(String text, String after) Returns a substring after the specified character Ex.toBase64
(byte[] bytes) Transforms the binaries to String base64-encoded representationbyte[]
Reads the InputStream and returns the resulting byte arraytoHex
(byte[] bytes) Transforms the binaries to String HEX representationTrims the string, by removing all leading and descending spaces and lines Ex.Converts a string to its upper case representation Ex.void
write
(byte[] content, OutputStream os) Writescontent
toos
-
Constructor Details
-
GoogleGuavaUtils
public GoogleGuavaUtils()Default constructor
-
-
Method Details
-
isStringEmpty
Description copied from interface:IUtils
Checks if the string is empty Ex. "nowina" = false; "" = true NOTE: blank string (e.g. " ") is not empty!- Specified by:
isStringEmpty
in interfaceIUtils
- Parameters:
text
-String
- Returns:
- TRUE if the string is empty, FALSE otherwise
-
isStringNotEmpty
Description copied from interface:IUtils
Checks if the string is not empty Ex. "nowina" = true; "" = false NOTE: blank string (e.g. " ") is not empty!- Specified by:
isStringNotEmpty
in interfaceIUtils
- Parameters:
text
-String
- Returns:
- TRUE if the string is not empty, FALSE otherwise
-
isStringBlank
Description copied from interface:IUtils
Checks if the string is blank Ex. "nowina" = false; " " = true- Specified by:
isStringBlank
in interfaceIUtils
- Parameters:
text
-String
- Returns:
- TRUE if the string is blank, FALSE otherwise
-
isStringNotBlank
Description copied from interface:IUtils
Checks if the string is not blank Ex. "nowina" = true; " " = false- Specified by:
isStringNotBlank
in interfaceIUtils
- Parameters:
text
-String
- Returns:
- TRUE if the string is not blank, FALSE otherwise
-
areStringsEqual
Description copied from interface:IUtils
Checks if the strings are equal Ex. "nowina" == "nowina" = true; "nowina" == "Nowina" = false- Specified by:
areStringsEqual
in interfaceIUtils
- Parameters:
text1
-String
text2
-String
- Returns:
- TRUE if the strings are equal, FALSE otherwise
-
areStringsEqualIgnoreCase
Description copied from interface:IUtils
Checks if the strings are equal with case ignore Ex. "nowina" == "Nowina" = true; "water" == "fire" = false- Specified by:
areStringsEqualIgnoreCase
in interfaceIUtils
- Parameters:
text1
-String
text2
-String
- Returns:
- TRUE if the strings are equal with case ignore, FALSE otherwise
-
isStringDigits
Description copied from interface:IUtils
Checks if the string contains only digits Ex. "123" = true; "1a2b" = false- Specified by:
isStringDigits
in interfaceIUtils
- Parameters:
text
-String
- Returns:
- TRUE if the string contains only digits, FALSE otherwise
-
trim
Description copied from interface:IUtils
Trims the string, by removing all leading and descending spaces and lines Ex. " 123 " = "123" -
joinStrings
Description copied from interface:IUtils
Joins the strings with the given separator Ex. "Nowina" "123", "," = "Nowina,123"- Specified by:
joinStrings
in interfaceIUtils
- Parameters:
strings
- a collection ofString
sseparator
-String
- Returns:
- the joined string
-
substringAfter
Description copied from interface:IUtils
Returns a substring after the specified character Ex. "aaaaa?bbb", "?" = "bbb"- Specified by:
substringAfter
in interfaceIUtils
- Parameters:
text
-String
to get a substring fromafter
-String
string to get a substring after which- Returns:
- the substring
-
endsWithIgnoreCase
Description copied from interface:IUtils
Checks if the string ends with case ignore Ex. "hello", "LO" = true; "hello", "a" = false- Specified by:
endsWithIgnoreCase
in interfaceIUtils
- Parameters:
text
-String
to checkexpected
-String
the end string to check- Returns:
- TRUE if the string ends with case ignore, FALSE otherwise
-
getFileNameExtension
Description copied from interface:IUtils
This method returns an extension for the given filename Ex. "file.xml" = "xml"; "document.pdf" = "pdf"- Specified by:
getFileNameExtension
in interfaceIUtils
- Parameters:
filename
-String
representing a filename extracted from a file- Returns:
String
extension
-
lowerCase
Description copied from interface:IUtils
Converts a string to its lower case representation Ex. "Nowina" = "nowina" -
upperCase
Description copied from interface:IUtils
Converts a string to its upper case representation Ex. "Nowina" = "NOWINA" -
isArrayEmpty
Description copied from interface:IUtils
Checks if the array is null or empty- Specified by:
isArrayEmpty
in interfaceIUtils
- Parameters:
array
- to check- Returns:
- TRUE if the array is null or empty, FALSE otherwise
-
isArrayNotEmpty
Description copied from interface:IUtils
Checks if the array is not null nor empty- Specified by:
isArrayNotEmpty
in interfaceIUtils
- Parameters:
array
- to check- Returns:
- TRUE if the array is not null nor empty, FALSE otherwise
-
isArrayEmpty
public boolean isArrayEmpty(byte[] array) Description copied from interface:IUtils
Checks if the byte array is null or empty- Specified by:
isArrayEmpty
in interfaceIUtils
- Parameters:
array
- byte array to check- Returns:
- TRUE if the byte array is null or empty, FALSE otherwise
-
isArrayNotEmpty
public boolean isArrayNotEmpty(byte[] array) Description copied from interface:IUtils
Checks if the byte array is not null nor empty- Specified by:
isArrayNotEmpty
in interfaceIUtils
- Parameters:
array
- byte array to check- Returns:
- TRUE if the byte array is not null nor empty, FALSE otherwise
-
isArrayEmpty
public boolean isArrayEmpty(char[] array) Description copied from interface:IUtils
Checks if the char array is null or empty- Specified by:
isArrayEmpty
in interfaceIUtils
- Parameters:
array
- char array to check- Returns:
- TRUE if the char array is null or empty, FALSE otherwise
-
isArrayNotEmpty
public boolean isArrayNotEmpty(char[] array) Description copied from interface:IUtils
Checks if the char array is not null nor empty- Specified by:
isArrayNotEmpty
in interfaceIUtils
- Parameters:
array
- char array to check- Returns:
- TRUE if the char array is not null nor empty, FALSE otherwise
-
subarray
public byte[] subarray(byte[] array, int start, int length) Description copied from interface:IUtils
Returns a subArray, starting from positionstart
with the defined lengthlength
-
isTrue
Description copied from interface:IUtils
Checks if the Boolean value is set to true NOTE: if null, returns false! -
isCollectionEmpty
Description copied from interface:IUtils
Checks if the collection is null or empty- Specified by:
isCollectionEmpty
in interfaceIUtils
- Parameters:
collection
- to check- Returns:
- TRUE if the collection is null or empty, FALSE otherwise
-
isCollectionNotEmpty
Description copied from interface:IUtils
Checks if the collection is not null nor empty- Specified by:
isCollectionNotEmpty
in interfaceIUtils
- Parameters:
collection
- to check- Returns:
- TRUE if the collection is not null nor empty, FALSE otherwise
-
isMapEmpty
Description copied from interface:IUtils
Checks if the map is null or empty- Specified by:
isMapEmpty
in interfaceIUtils
- Parameters:
map
- to check- Returns:
- TRUE if the map is null or empty, FALSE otherwise
-
isMapNotEmpty
Description copied from interface:IUtils
Checks if the map is not null nor empty- Specified by:
isMapNotEmpty
in interfaceIUtils
- Parameters:
map
- to check- Returns:
- TRUE if the map is not null nor empty, FALSE otherwise
-
collectionSize
Description copied from interface:IUtils
Gets the size of the collection- Specified by:
collectionSize
in interfaceIUtils
- Parameters:
collection
-Collection
- Returns:
- size of the collection
-
isHexEncoded
Description copied from interface:IUtils
Checks if the string is HEX (base16) encoded- Specified by:
isHexEncoded
in interfaceIUtils
- Parameters:
hexString
-String
- Returns:
- TRUE if he string is HEX encoded, FALSE otherwise
-
toHex
Description copied from interface:IUtils
Transforms the binaries to String HEX representation -
fromHex
Description copied from interface:IUtils
Transforms a HEX-encoded string to byte array -
isBase64Encoded
Description copied from interface:IUtils
Checks if the string is base64-encoded- Specified by:
isBase64Encoded
in interfaceIUtils
- Parameters:
base64String
-String
- Returns:
- TRUE if he string is base64-encoded, FALSE otherwise
-
toBase64
Description copied from interface:IUtils
Transforms the binaries to String base64-encoded representation -
fromBase64
Description copied from interface:IUtils
Transforms a base64-encoded string to byte array- Specified by:
fromBase64
in interfaceIUtils
- Parameters:
base64
-String
base64-encoded- Returns:
- byte array
-
toByteArray
Description copied from interface:IUtils
Reads the InputStream and returns the resulting byte array- Specified by:
toByteArray
in interfaceIUtils
- Parameters:
is
-InputStream
- Returns:
- byte array
- Throws:
IOException
- if an exception occurs
-
closeQuietly
Description copied from interface:IUtils
Closes quietly- Specified by:
closeQuietly
in interfaceIUtils
- Parameters:
closeable
-Closeable
-
copy
Description copied from interface:IUtils
Copiesis
toos
- Specified by:
copy
in interfaceIUtils
- Parameters:
is
-InputStream
to copyos
-OutputStream
to write the value into- Throws:
IOException
- if an exception occurs
-
write
Description copied from interface:IUtils
Writescontent
toos
- Specified by:
write
in interfaceIUtils
- Parameters:
content
- byte array to writeos
-OutputStream
to write the value into- Throws:
IOException
- if an exception occurs
-
getInputStreamSize
Description copied from interface:IUtils
Gets the size of the InputStream content- Specified by:
getInputStreamSize
in interfaceIUtils
- Parameters:
is
-InputStream
- Returns:
- size
- Throws:
IOException
- if an exception occurs
-
compareInputStreams
Description copied from interface:IUtils
Compares content of twoInputStream
s- Specified by:
compareInputStreams
in interfaceIUtils
- Parameters:
stream1
-InputStream
stream2
-InputStream
- Returns:
- TRUE if the content of two
InputStream
is equal, FALSE otherwise - Throws:
IOException
- if an exception on InputStream read occurs
-
cleanDirectory
Description copied from interface:IUtils
Cleans the directory- Specified by:
cleanDirectory
in interfaceIUtils
- Parameters:
directory
-File
- Throws:
IOException
- if an exception occurs
-
listFiles
Description copied from interface:IUtils
Lists all files from thefolder
with the givenextensions
-
reverseList
Description copied from interface:IUtils
Creates a reversed copy of the list- Specified by:
reverseList
in interfaceIUtils
- Type Parameters:
T
- the class of list elements- Parameters:
list
-List
to get a reversed copy of- Returns:
- reversed list
-
containsAny
Description copied from interface:IUtils
This method returns boolean result whether thesuperCollection
contains any element of thesubCollection
Ex. {'A', 'B', 'C'}, {'B', 'C', 'D'} = TRUE- Specified by:
containsAny
in interfaceIUtils
- Type Parameters:
T
- object- Parameters:
superCollection
- first collectionsubCollection
- second collection- Returns:
- TRUE if both collection intersect each other, FALSE otherwise
-