Class AbstractDemo

java.lang.Object
dev.frostlake.demo.AbstractDemo
Direct Known Subclasses:
DMLOperationsDemo, EngineDemo, LateralJoinDemo, MergeOperationsDemo, PrimaryKeyDemo, QueryOperatorsDemo, StagesDemo, StreamsAndTasksDemo, WarehousesDemo

public abstract class AbstractDemo extends Object
Abstract base class for demo applications Provides common functionality for engine management, output formatting, and database operations
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    protected DatabaseEngine
    The engine the demo runs against; created by setup(), released by shutdown().
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    final void
    Execute the demo with proper setup and cleanup
    protected abstract String
    Get the demo title to display at the start
    protected int
    Get maximum number of rows to display in result sets Subclasses can override to show more or fewer rows
    protected int
    getRowCount(String tableName)
    Get the row count from a table
    protected void
    Execute a query and print its results
    protected void
    Print a result set with formatted output Subclasses can override for custom formatting
    protected void
    printResultSet(ResultSet result, int columnWidth)
    Print a result set with specified column width
    protected void
    Print a section header with box formatting
    protected void
    Print a horizontal line separator
    protected void
    Print a subsection header
    protected void
    Print an info line with a checkmark
    protected void
    printTable(String tableName)
    Query a table and print its contents
    protected void
    Print demo title with formatting
    protected abstract void
    Main entry point - subclasses should implement this to define their demo logic
    protected void
    Initialize the Frostlake engine
    protected void
    setupDatabase(String databaseName)
    Setup a database - create if doesn't exist and use it
    protected void
    Shutdown the engine and release resources

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

  • Constructor Details

    • AbstractDemo

      public AbstractDemo()
  • Method Details

    • runDemo

      protected abstract void runDemo() throws Exception
      Main entry point - subclasses should implement this to define their demo logic
      Throws:
      Exception - if any demo step fails; execute() reports it and still shuts down
    • getDemoTitle

      protected abstract String getDemoTitle()
      Get the demo title to display at the start
      Returns:
      the title execute() prints before running the demo
    • execute

      public final void execute()
      Execute the demo with proper setup and cleanup
    • setup

      protected void setup()
      Initialize the Frostlake engine
    • shutdown

      protected void shutdown()
      Shutdown the engine and release resources
    • setupDatabase

      protected void setupDatabase(String databaseName)
      Setup a database - create if doesn't exist and use it
      Parameters:
      databaseName - the database to create (if missing) and make current, with schema PUBLIC
    • printTitle

      protected void printTitle(String title)
      Print demo title with formatting
      Parameters:
      title - the text framed between === markers
    • printSectionHeader

      protected void printSectionHeader(String title)
      Print a section header with box formatting
      Parameters:
      title - the heading centered inside the box border
    • printSubsection

      protected void printSubsection(String title)
      Print a subsection header
      Parameters:
      title - the heading framed between --- markers
    • printSuccess

      protected void printSuccess(String message)
      Print an info line with a checkmark
      Parameters:
      message - the text printed after the checkmark
    • printTable

      protected void printTable(String tableName)
      Query a table and print its contents
      Parameters:
      tableName - the table whose full contents are selected and printed
    • printQuery

      protected void printQuery(String sql)
      Execute a query and print its results
      Parameters:
      sql - the query to run against the engine
    • printResultSet

      protected void printResultSet(ResultSet result)
      Print a result set with formatted output Subclasses can override for custom formatting
      Parameters:
      result - the result set to print, at the default 20-character column width
    • printResultSet

      protected void printResultSet(ResultSet result, int columnWidth)
      Print a result set with specified column width
      Parameters:
      result - the result set to print, capped at getMaxDisplayRows() rows
      columnWidth - width of each printed column; longer values are truncated with an ellipsis
    • getMaxDisplayRows

      protected int getMaxDisplayRows()
      Get maximum number of rows to display in result sets Subclasses can override to show more or fewer rows
      Returns:
      the row display cap, 100 unless overridden
    • getRowCount

      protected int getRowCount(String tableName)
      Get the row count from a table
      Parameters:
      tableName - the table to count
      Returns:
      how many rows a SELECT * over the table yields
    • printSeparator

      protected void printSeparator()
      Print a horizontal line separator