Class SQLEngine

java.lang.Object
de.businesscode.sqlengine.SQLEngine

public class SQLEngine extends Object
The SQL Engine can transform sql fragments containing references to BindingSets into pure sql, resolving table and column names To resolve the given binding set/group names to the right concrete BindingSets first, it parses the given sql twice, - In phase 2 it will just collect the binding set name - binding item names combination, using BindingsLookupContextObject and BindingSetLookupContextObject - In phase 2 it does then know the concrete BindingSet and BindingItem and can output the appropriate table and column names, using BindingsContextObject and BindingSetContextObject
  • Constructor Details

    • SQLEngine

      public SQLEngine()
  • Method Details

    • getSelectedBindigItemsInOrder

      public List<BindingItem> getSelectedBindigItemsInOrder()
      Getter for a list of all BindindItems used in this sql and mentioned before the table name
    • getAllBindigItemsInOrder

      public List<BindingItem> getAllBindigItemsInOrder()
      Getter for a list of all BindindItems used in this sql
    • getIndex

      public int getIndex(String bindingItem)
      Get first index of selected BindingItem
    • getResultingBindingSets

      public Set<StandardBindingSet> getResultingBindingSets()
      Getter for BindingSets which where chosen base on the BindingSet name and BindingItems
    • getRequestedBindingSetNames

      public Set<Map.Entry<String,String>> getRequestedBindingSetNames()
      Getter for the BindingSet requested for this sql
    • transform

      public String transform(String sql)
      transform
      Parameters:
      sql -
      Returns:
      the transformed sql
    • transform

      public String transform(String sql, Map<String,Object> additionalProps)
      Parameters:
      sql -
      additionalProps -
      Returns:
    • transform

      public String transform(String sql, Bindings bindings)
      transform
      Parameters:
      sql -
      bindings -
      Returns:
      the transformed sql
    • transform

      public String transform(String sql, Bindings bindings, Map<String,Object> additionalProps)
      Parameters:
      sql -
      bindings -
      additionalProps -
      Returns:
    • transformParams

      public String transformParams(String sql, Map<String,Integer> multiplicities, String keyword, String separator, Vector<String> substitutes)
      simple transform parameters into multiplicities of actual question marks ('?') and store the substituted unqualified names
      Parameters:
      sql - input string
      substitutes - List that will contain the substitutions. Unchecked for null.
      multiplicities - map the keywords to number of substitutions needed. If null, number of substitutions is consistently 1
      keyword - pretext that is used for look up of values to transform. If null, 'params' is used.
      Returns:
      the input string with occurences like '$params.some_name_or_other' substituted by '?' (or by '?,?,?' depending on the multiplicity map) and the List of the 'some_name_or_other' in the substitutes List.