Class StatementBuilder

java.lang.Object
net.sf.jailer.database.StatementBuilder

public class StatementBuilder extends Object
Builds compact SQL-statements of the pattern: HEAD ITEM {SEPARATOR ITEM}* TERMINATOR. (for example, an 'INSERT' with a 'values'-list)
Author:
Ralf Wisser
  • Constructor Details

    • StatementBuilder

      public StatementBuilder(int maxBodySize)
      Constructor.
      Parameters:
      maxBodySize - the maximal size of a body-list
  • Method Details

    • isAppendable

      public boolean isAppendable(String head)
      Checks whether an item is appendable to previously appended items.
      Parameters:
      head - the statements head
      Returns:
      true iff item is appendable
    • build

      public String build()
      Builds the SQL-statement and resets the builder.
      Returns:
      the SQL-statement
    • append

      public void append(String head, String item, String separator, String terminator)
      Appends an item.
      Parameters:
      head - same head as previously appended, if any
      item - the item
      separator - separates the items
      terminator - terminates the statement
    • isEmpty

      public boolean isEmpty()
      Checks if builder is empty.
      Returns:
      true if builder is empty
    • size

      public int size()
      Returns the number of items in the current statement.
      Returns:
      the number of items
    • getItems

      public List<String> getItems()
      Returns the items of the current statement.
      Returns:
      the list of items
    • getMaxBodySize

      public int getMaxBodySize()
      Gets the maximal size of a body-list.
      Returns:
      the maximal number of items per statement