public final class LookupFileVerifier
extends java.lang.Object
Modifier and Type | Field and Description |
---|---|
static java.lang.String |
UTF8_BOM |
Modifier and Type | Method and Description |
---|---|
static java.lang.String |
cleanString(java.lang.String input,
java.lang.Boolean isFirst) |
static java.util.Map<java.lang.String,java.lang.String> |
createReplacementMap(byte[] lookupFileBytes,
java.lang.String lookupFileUri,
java.lang.String delimiter,
boolean caseSensitive)
This creates a value to replacement map from the bytes of a lookup file.
|
static java.lang.String |
getBytesHash(byte[] bytes) |
static byte[] |
getLookupFileBytes(ComponentService serviceProvider,
FileReference lookupFile) |
static java.util.Collection<java.lang.String> |
setupFile(ComponentService serviceProvider,
FileReference lookupFile,
LogService logger,
com.google.common.cache.Cache<java.lang.String,java.util.List<java.lang.String>> lookupLists)
This method reads the lookupFile's values (providing encoding and BOM verification) and
initializes the replacements caching for faster lookup.
|
static java.util.Collection<java.lang.String> |
setupFile(ComponentService serviceProvider,
FileReference lookupFile,
LogService logger,
com.google.common.cache.Cache<java.lang.String,java.util.List<java.lang.String>> lookupLists,
java.lang.Boolean allowSingleSpacesLine,
java.lang.Boolean trimWhitespace)
Overloading the method to keep the signature of the old setupFile method intact.
|
static void |
verifyEncoding(byte[] bytes) |
public static final java.lang.String UTF8_BOM
public static java.lang.String cleanString(java.lang.String input, java.lang.Boolean isFirst)
input
- - single line of Lookup FileisFirst
- - true if that's first line of the file (to be checked for BOM)public static void verifyEncoding(byte[] bytes) throws ComponentConfigurationException
bytes
- - the row bytes presentation of the LookupFileComponentConfigurationException
- - if file isn't fully UTF-8 compatiblepublic static java.lang.String getBytesHash(byte[] bytes)
bytes
- - the row bytes presentation of the LookupFilepublic static byte[] getLookupFileBytes(@Nonnull ComponentService serviceProvider, FileReference lookupFile)
public static java.util.Collection<java.lang.String> setupFile(@Nonnull ComponentService serviceProvider, FileReference lookupFile, LogService logger, com.google.common.cache.Cache<java.lang.String,java.util.List<java.lang.String>> lookupLists)
serviceProvider
- - ComponentServicelookupFile
- - file, containing the masked valueslogger
- - LogServicelookupLists
- - cache for lookup values per hashed inputpublic static java.util.Collection<java.lang.String> setupFile(@Nonnull ComponentService serviceProvider, FileReference lookupFile, LogService logger, com.google.common.cache.Cache<java.lang.String,java.util.List<java.lang.String>> lookupLists, java.lang.Boolean allowSingleSpacesLine, java.lang.Boolean trimWhitespace)
serviceProvider
- - ComponentServicelookupFile
- - file, containing the masked valueslogger
- - LogServicelookupLists
- - cache for lookup values per hashed inputallowSingleSpacesLine
- - allow single line of spaces in the lookup file as a valid
replacement valuetrimWhitespace
- - trim whitespaces for each value in the lookup filepublic static java.util.Map<java.lang.String,java.lang.String> createReplacementMap(byte[] lookupFileBytes, java.lang.String lookupFileUri, java.lang.String delimiter, boolean caseSensitive)
lookupFileBytes
- byte[] of lookup file contentslookupFileUri
- lookup file URIdelimiter
- the literal string delimiter that separates a value/replacement paircaseSensitive
- whether the lookup value is case-sensitive