Package com.softslate.commerce.daos.core
Interface DAOUtils
- All Known Implementing Classes:
DAOUtilsImpl
public interface DAOUtils
-
Method Summary
Modifier and TypeMethodDescriptiongenerateKeyPair
(String publicFile, String privateFile, boolean savePrivate) void
generateTwoWayKey
(String keyFile) getCollectionFromBeans
(Collection collection, String field) Given a Collection of beans representing a ResultSet, and a field name for a field, returns a Collection of Integers representing each field's value in the incoming Collection.getCollectionFromCollection
(Collection collection, String field) Given a Collection of Maps representing a ResultSet, and a field name for a field, returns a Collection of Strings representing each field's value in the incoming Collection.getCollectionFromResultSet
(ResultSet resultSet, String field) Given a ResultSet and a field name for a field, returns a Collection of Strings representing each field value in the ResultSet.getDebugMessage
(ResultSet resultSet) Retrieves a string indicating the number of rows and columns returned from aResultSet
.getDecrypted
(String stringToDecrypt, String encryptionType, String privateKeyFile) Decrypts a string using the given encryption type.getEncrypted
(String stringToEncrypt, String encryptionType, String publicKeyFile) Encrypts a string using the given encryption type.getEncrypted
(String stringToEncrypt, String encryptionType, String publicKeyFile, String oneWayAlgorithm) getIntegersFromStrings
(Collection collection) Given a Collection of Strings, returns a collection of Integers corresponding to the strings.Given an array of strings, returns a single string that can be used as a list in an SQL expression.getListFromCollection
(Collection collection, String field) Given a Collection of Maps representing a ResultSet, and a field name for a field, returns a String list representing each field's value in the incoming Collection.getListFromResultSet
(ResultSet resultSet, String field) Given a ResultSet and a field name, returns a single string that can be used as a list in an SQL expression.getListFromStringCollection
(Collection collection) Given a Collection of Strings, returns a String list representing each element's value in the incoming Collection.getQuotedList
(String[] stringArray) Given an array of strings, returns a single string that can be used as a list in an SQL expression.getQuotedList
(Map map) Given aMap
of string keys, returns a single string that can be used as a list in an SQL expression.String[]
An array of strings to eliminate from database search queries.void
outputCsv
(Collection data, Writer out) Outputs a matrix of strings as comma-separated values.prepareSearchString
(String searchString) Prepares a string for insertion into an SQL search expression.
-
Method Details
-
getStopWords
String[] getStopWords()An array of strings to eliminate from database search queries. -
getList
Given an array of strings, returns a single string that can be used as a list in an SQL expression. Each of the elements of the incoming array are separated by commas.- Parameters:
stringArray
- The array of strings to convert into a comma-separated list.- Returns:
- A string that can be used as a list in an SQL expression.
-
getQuotedList
Given an array of strings, returns a single string that can be used as a list in an SQL expression. Each of the elements of the incoming array are quoted and separated by commas.- Parameters:
stringArray
- The array of strings to convert into a quoted string.- Returns:
- A string that can be used as a list in an SQL expression.
-
getListFromResultSet
Given a ResultSet and a field name, returns a single string that can be used as a list in an SQL expression. Each of the elements of the incoming ResultSet corresponding to the given field are separated by commas. Helpful for older databases that do not support sub queries.- Parameters:
resultSet
- The ResultSet holding the values.field
- The name of the field whose values are to be returned in a list.- Returns:
- A string that can be used as a list in an SQL expression
- Throws:
SQLException
-
getListFromCollection
Given a Collection of Maps representing a ResultSet, and a field name for a field, returns a String list representing each field's value in the incoming Collection.- Parameters:
collection
- The Collection holding the values.- Returns:
- A string that can be used as a list in an SQL expression.
-
getListFromStringCollection
Given a Collection of Strings, returns a String list representing each element's value in the incoming Collection.- Parameters:
collection
- The Collection holding the values.- Returns:
- A string that can be used as a list in an SQL expression.
-
getCollectionFromResultSet
Given a ResultSet and a field name for a field, returns a Collection of Strings representing each field value in the ResultSet.- Parameters:
resultSet
- The ResultSet holding the values.field
- The name of the field whose values are to be returned in a Colleciton.- Returns:
- A Collection of Strings representing each field value in the ResultSet
- Throws:
SQLException
-
getCollectionFromCollection
Given a Collection of Maps representing a ResultSet, and a field name for a field, returns a Collection of Strings representing each field's value in the incoming Collection.- Parameters:
collection
- The Collection holding the values.field
- The name of the field whose values are to be returned in a Collection.- Returns:
- A Collection of Strings representing each field's value in the incoming Collection
-
getCollectionFromBeans
Given a Collection of beans representing a ResultSet, and a field name for a field, returns a Collection of Integers representing each field's value in the incoming Collection.- Parameters:
collection
- The Collection holding the values.field
- The name of the field whose values are to be returned in a Collection.- Returns:
- a Collection of Integers
- Throws:
Exception
-
getIntegersFromStrings
Given a Collection of Strings, returns a collection of Integers corresponding to the strings.- Parameters:
collection
- A collection of Strings- Returns:
- A collection of Integers
-
getDebugMessage
Retrieves a string indicating the number of rows and columns returned from aResultSet
.- Parameters:
resultSet
- TheResultSet
to produce a debugging message for.- Returns:
- A string indicating the number of rows and columns returned from
a
ResultSet
. - Throws:
SQLException
-
getQuotedList
Given aMap
of string keys, returns a single string that can be used as a list in an SQL expression. Each of the elements of the incomingMap
are quoted and separated by commas.- Parameters:
map
- TheMap
to convert into a quoted string.- Returns:
- A string that can be used as a list in an SQL expression.
- Throws:
Exception
-
outputCsv
Outputs a matrix of strings as comma-separated values. This implementation encloses problem values in double-quotes, prepends backslash to embedded double-quotes and backslashes, and represents embedded newlines as backslash-n.- Parameters:
data
- List of String arrays or Object arrays.out
- The stream to write to.- Throws:
IOException
-
prepareSearchString
Prepares a string for insertion into an SQL search expression. Adds % to the beginning and end of the string and in between each word. Also strips the string of characters dangerous to an SQL search expression.- Parameters:
searchString
-- Returns:
- A string acceptable for a LIKE expression.
-
getEncrypted
Encrypts a string using the given encryption type.- Parameters:
stringToEncrypt
- The String to encrypt.encryptionType
- "noEncryption", "keyPairStore", "keyPairNoStore", or "oneWay".- Returns:
- The encrypted string
-
getEncrypted
-
getDecrypted
Decrypts a string using the given encryption type.- Parameters:
stringToDecrypt
- The String to decrypt.encryptionType
- "noEncryption", "keyPairStore", "keyPairNoStore", or "oneWay".- Returns:
- The decrypted string
-
generateTwoWayKey
- Throws:
Exception
-
generateKeyPair
- Throws:
Exception
-