Class DDLWriter

  • All Implemented Interfaces:
    java.io.Closeable, java.io.Flushable, java.lang.Appendable, java.lang.AutoCloseable

    public final class DDLWriter
    extends java.io.Writer
    Replace PrintStream and StringBuffer by a Writer implementation We have various properties to configure output that are in-depended of the schema object:
  • org.castor.ddlgen.CharFormat=SENSITIVE, UPPER and LOWER
  • org.castor.ddlgen.Newline=\n
  • org.castor.ddlgen.Indention=\t These properties are accessed at various places all around ddlgen at the moment.The idea is that these properties are set only once at the new Writer and do not need to be accessed elsewhere. This has the following advantages:
  • improved performance as the properties don't need to be accessed for every object to output
  • functionallity to format genertaed ddl is concentrated in one class: the new Writer
  • all the toDDL(), toDropDDL(), toCreateDDL() methods get much shorter I thought of the following interface for the new Writer (not complete):
  • write(String) outputs String as is
  • writeln(String) calls write(String) followed by newline()
  • newline() output newline and indention of next line
  • indent() increases indention
  • unindent() decreases indention More write() and writeln() methods for other data types may be added on demand. A further improvement could be to offer write(String, Object[]) methods that internally use MessageFormat. This would enable us to use a pattern based approach for DDL generation. These patterns may sometimes be much easier to read and maintain. In addition to the introduction of the new Writer it will be required to pass an instance of the Writer to every method where DDL gets generated. Therefore the parameterless toCreate() method have to be changed to toCreateDDL(DDLWriter). This also applies to other such methods.
Since:
1.1.2
Version:
$Revision: 5951 $ $Date: 2006-04-25 16:09:10 -0600 (Tue, 25 Apr 2006) $
Author:
Le Duc Bao