Interface DAOUtils

All Known Implementing Classes:
DAOUtilsImpl

public interface DAOUtils
  • Method Details

    • getStopWords

      String[] getStopWords()
      An array of strings to eliminate from database search queries.
    • getList

      String getList(String[] stringArray)
      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

      String getQuotedList(String[] stringArray)
      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

      String getListFromResultSet(ResultSet resultSet, String field) throws SQLException
      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

      String 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.
      Parameters:
      collection - The Collection holding the values.
      Returns:
      A string that can be used as a list in an SQL expression.
    • getListFromStringCollection

      String getListFromStringCollection(Collection collection)
      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

      Collection getCollectionFromResultSet(ResultSet resultSet, String field) throws SQLException
      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

      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.
      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

      Collection getCollectionFromBeans(Collection collection, String field) throws Exception
      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

      Collection getIntegersFromStrings(Collection collection)
      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

      String getDebugMessage(ResultSet resultSet) throws SQLException
      Retrieves a string indicating the number of rows and columns returned from a ResultSet.
      Parameters:
      resultSet - The ResultSet to produce a debugging message for.
      Returns:
      A string indicating the number of rows and columns returned from a ResultSet.
      Throws:
      SQLException
    • getQuotedList

      String getQuotedList(Map map) throws Exception
      Given a Map of string keys, returns a single string that can be used as a list in an SQL expression. Each of the elements of the incoming Map are quoted and separated by commas.
      Parameters:
      map - The Map to convert into a quoted string.
      Returns:
      A string that can be used as a list in an SQL expression.
      Throws:
      Exception
    • outputCsv

      void outputCsv(Collection data, Writer out) throws IOException
      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

      String prepareSearchString(String searchString)
      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

      String getEncrypted(String stringToEncrypt, String encryptionType, String publicKeyFile)
      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

      String getEncrypted(String stringToEncrypt, String encryptionType, String publicKeyFile, String oneWayAlgorithm)
    • getDecrypted

      String getDecrypted(String stringToDecrypt, String encryptionType, String privateKeyFile)
      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

      void generateTwoWayKey(String keyFile) throws Exception
      Throws:
      Exception
    • generateKeyPair

      String generateKeyPair(String publicFile, String privateFile, boolean savePrivate) throws Exception
      Throws:
      Exception