Class LiquibaseStatementsWriter

java.lang.Object
org.fastnate.generator.statements.AbstractStatementsWriter
org.fastnate.generator.statements.LiquibaseStatementsWriter
All Implemented Interfaces:
Closeable, AutoCloseable, StatementsWriter

public class LiquibaseStatementsWriter extends AbstractStatementsWriter
Generates statements for the Liquibase changelog file.
Author:
Tobias Liefke
See Also:
  • Field Details

    • OUTPUT_FILE_KEY

      public static final String OUTPUT_FILE_KEY
      Settings key for the generated XML file, if not given in the constructor.
      See Also:
    • VERSION_KEY

      public static final String VERSION_KEY
      Settings key for the generated liquibase version, if not given in the constructor.
      See Also:
    • DATE_PRECISIONS

      private static final RelativeDate.Precision[] DATE_PRECISIONS
    • ISO_DATETIMESECONDS_FORMAT

      private static final org.apache.commons.lang3.time.FastDateFormat ISO_DATETIMESECONDS_FORMAT
    • dialect

      private final GeneratorDialect dialect
      The current database dialect (in case any plain SQL statement needs to be written).
    • writer

      private final XMLStreamWriter writer
      The receiver of our XML elements.
    • relativeDatesSupported

      private final boolean relativeDatesSupported
      Indicates if our liquibase version supports relative dates.
    • outputStream

      private OutputStream outputStream
      The outputstream to close, if this writer is closed.
    • changeSetId

      private String changeSetId
      The ID of the next created change set.
    • changeSetAuthour

      private String changeSetAuthour
      The author of the next created change set.
    • changeSetComment

      private String changeSetComment
      The comment of the next created change set.
    • changeSetStarted

      private boolean changeSetStarted
      Indicates if we are currently in a changeSet.
  • Constructor Details

    • LiquibaseStatementsWriter

      public LiquibaseStatementsWriter(GeneratorContext context) throws XMLStreamException, FileNotFoundException
      Creates a new writer which generates an XML file with "UTF-8" encoding.
      Parameters:
      context - contains all the settings that we need to build the file
      Throws:
      XMLStreamException - if already the root element could not be created
      FileNotFoundException - if the parent directory does not exist
    • LiquibaseStatementsWriter

      public LiquibaseStatementsWriter(GeneratorDialect dialect, OutputStream outputStream, String version) throws XMLStreamException
      Creates a new writer which generates an XML file with "UTF-8" encoding.
      Parameters:
      dialect - the database dialect for any plain SQL statement
      outputStream - the target stream, will be close when this wirter is closed
      version - the liquibase version - this is only for the referenced schema and won't change anything else
      Throws:
      XMLStreamException - if already the root element could not be created
    • LiquibaseStatementsWriter

      public LiquibaseStatementsWriter(GeneratorDialect dialect, XMLStreamWriter writer, String version) throws XMLStreamException
      Creates a new writer.
      Parameters:
      dialect - the database dialect for any plain SQL statement
      writer - the stream writer for generating the XML
      version - the liquibase version - this is only for the referenced schema and won't change anything else
      Throws:
      XMLStreamException - if already the root element could not be created
    • LiquibaseStatementsWriter

      public LiquibaseStatementsWriter(OutputStream outputStream, String version) throws XMLStreamException
      Creates a new writer which generates an XML file with "UTF-8" encoding and use the H2 dialect for any plain statement.
      Parameters:
      outputStream - the target stream, will be close when this wirter is closed
      version - the liquibase version - this is only for the referenced schema and won't change anything else
      Throws:
      XMLStreamException - if already the root element could not be created
    • LiquibaseStatementsWriter

      public LiquibaseStatementsWriter(XMLStreamWriter writer, String version) throws XMLStreamException
      Creates a new writer which uses H2 for any plain statement.
      Parameters:
      writer - the stream writer for generating the XML
      version - the liquibase version - this is only for the referenced schema and won't change anything else
      Throws:
      XMLStreamException - if already the root element could not be created
  • Method Details