net.sf.dewdrop.sqlml.config
Class Configuration

java.lang.Object
  extended bynet.sf.dewdrop.sqlml.config.Configuration

public class Configuration
extends Object

Author:
Les Hazlewood

Field Summary
protected  boolean columnMetadataJustified
           
protected static int DEFAULT_COLUMN_INDENT_LEVEL
           
protected static boolean DEFAULT_COLUMN_METADATA_JUSTIFIED
           
static Configuration DEFAULT_CONFIG
           
protected static String DEFAULT_INDENT_STRING
           
protected static int DEFAULT_LINES_BETWEEN_COLUMN_DEFINITIONS
           
protected static int DEFAULT_LINES_BETWEEN_ROOT_DEFINITIONS
           
protected static int DEFAULT_MAX_PAGE_WIDTH
           
static boolean DEFAULT_OUTPUT_WRAPPED_IN_TRANSACTION
           
protected static int DEFAULT_ROOT_INDENT_LEVEL
           
protected static int DEFAULT_TABLE_COMPONENT_INDENT_LEVEL
           
protected static boolean DEFAULT_TABLE_OPEN_PAREN_ON_SAME_LINE
           
protected  Dialect dialect
           
protected  int indentLevel
           
protected  String indentString
           
protected  int linesBetweenRootDefinitions
           
protected  int linesBetweenTableComponents
           
protected  String lineSeparator
           
protected  int maxPageWidth
           
protected  boolean outputWrappedInTransaction
           
protected  int rootIndentLevel
           
protected  int tableComponentIndentLevel
           
protected  boolean tableOpenParenOnSameLine
           
 
Constructor Summary
Configuration()
           
Configuration(Dialect dialect)
           
 
Method Summary
 void decrementIndent()
           
 Dialect getDialect()
           
 int getIndentLevel()
           
 String getIndentString()
           
 int getLinesBetweenRootDefinitions()
          Returns the number of new lines inserted between root-level SQL component definitions such as tables, indicies, views, etc.
 int getLinesBetweenTableComponents()
           
 String getLineSeparator()
           
 int getMaxPageWidth()
          Returns the maxPageWidth, which is the maximum number of characters per line.
 int getRootIndentLevel()
          Returns the indent level for all root SchemaComponents relative to the left margin of the page.
 int getTableComponentIndentLevel()
          Returns the column indent level for a column relative to the left margin of its parent table.
 void incrementIndent()
           
 void indent(Writer out)
           
 void indent(Writer out, int num)
           
 boolean isColumnMetadataJustified()
          Returns whether or not column metadata for column definitions will be justified flush with all other column metadata in a table.
 boolean isOutputWrappedInTransaction()
           
 boolean isSpaceUsedForIndents()
          Returns true if the space character is to be used as the indent character in the document, false if a tab is to be used.
 boolean isTableOpenParenOnSameLine()
          Returns true if, when creating a new table, the table's open parenthesis is to be on the same line as the table name and table modifiers.
 void setColumnMetadataJustified(boolean columnMetadataJustified)
          Sets whether or not column metadata is to be justfied when printed out.
 void setDialect(Dialect dialect)
           
 void setIndentLevel(int indentLevel)
           
 void setIndentString(String indentString)
           
 void setLinesBetweenRootDefinitions(int linesBetweenRootDefinitions)
          Sets the number of new lines to be inserted between root-level SQL component definitions such as tables, indices, views, etc.
 void setLinesBetweenTableComponents(int linesBetweenTableComponents)
           
 void setLineSeparator(String lineSeparator)
           
 void setMaxPageWidth(int maxPageWidth)
          Sets the maxPageWidth, which is the maximum number of characters per line.
 void setOutputWrappedInTransaction(boolean outputWrappedInTransaction)
           
 void setRootIndentLevel(int rootIndentLevel)
          Sets the root indent level for all SchemaComponents relative to the left margin of the page.
 void setTableComponentIndentLevel(int tableComponentIndentLevel)
          Sets the indent level for a table component relative to the left margin of its parent table.
 void setTableOpenParenOnSameLine(boolean tableOpenParenOnSameLine)
          Sets whether or not a table definition's opening parenthesis will exist on the same line as the table declaration or not.
 void write(Writer out, String toWrite)
           
 void writeln(Writer out)
           
 void writeln(Writer out, String toWrite)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DEFAULT_CONFIG

public static final Configuration DEFAULT_CONFIG

DEFAULT_OUTPUT_WRAPPED_IN_TRANSACTION

public static final boolean DEFAULT_OUTPUT_WRAPPED_IN_TRANSACTION
See Also:
Constant Field Values

DEFAULT_MAX_PAGE_WIDTH

protected static final int DEFAULT_MAX_PAGE_WIDTH
See Also:
Constant Field Values

DEFAULT_ROOT_INDENT_LEVEL

protected static final int DEFAULT_ROOT_INDENT_LEVEL
See Also:
Constant Field Values

DEFAULT_TABLE_OPEN_PAREN_ON_SAME_LINE

protected static final boolean DEFAULT_TABLE_OPEN_PAREN_ON_SAME_LINE
See Also:
Constant Field Values

DEFAULT_INDENT_STRING

protected static final String DEFAULT_INDENT_STRING
See Also:
Constant Field Values

DEFAULT_COLUMN_INDENT_LEVEL

protected static final int DEFAULT_COLUMN_INDENT_LEVEL
See Also:
Constant Field Values

DEFAULT_COLUMN_METADATA_JUSTIFIED

protected static final boolean DEFAULT_COLUMN_METADATA_JUSTIFIED
See Also:
Constant Field Values

DEFAULT_LINES_BETWEEN_ROOT_DEFINITIONS

protected static final int DEFAULT_LINES_BETWEEN_ROOT_DEFINITIONS
See Also:
Constant Field Values

DEFAULT_LINES_BETWEEN_COLUMN_DEFINITIONS

protected static final int DEFAULT_LINES_BETWEEN_COLUMN_DEFINITIONS
See Also:
Constant Field Values

DEFAULT_TABLE_COMPONENT_INDENT_LEVEL

protected static final int DEFAULT_TABLE_COMPONENT_INDENT_LEVEL
See Also:
Constant Field Values

outputWrappedInTransaction

protected boolean outputWrappedInTransaction

maxPageWidth

protected int maxPageWidth

rootIndentLevel

protected int rootIndentLevel

tableOpenParenOnSameLine

protected boolean tableOpenParenOnSameLine

indentString

protected String indentString

tableComponentIndentLevel

protected int tableComponentIndentLevel

columnMetadataJustified

protected boolean columnMetadataJustified

lineSeparator

protected String lineSeparator

linesBetweenRootDefinitions

protected int linesBetweenRootDefinitions

linesBetweenTableComponents

protected int linesBetweenTableComponents

dialect

protected Dialect dialect

indentLevel

protected int indentLevel
Constructor Detail

Configuration

public Configuration()

Configuration

public Configuration(Dialect dialect)
Method Detail

isOutputWrappedInTransaction

public boolean isOutputWrappedInTransaction()
Returns:
Returns the outputWrappedInTransaction.

setOutputWrappedInTransaction

public void setOutputWrappedInTransaction(boolean outputWrappedInTransaction)
Parameters:
outputWrappedInTransaction - The outputWrappedInTransaction to set.

getMaxPageWidth

public int getMaxPageWidth()
Returns the maxPageWidth, which is the maximum number of characters per line.

Returns:
Returns the maxPageWidth, which the maximum number of characters per line.

setMaxPageWidth

public void setMaxPageWidth(int maxPageWidth)

Sets the maxPageWidth, which is the maximum number of characters per line. Any values of maxPageWidth less than 1 are ignored.

Parameters:
maxPageWidth - The maxPageWidth to set.

getRootIndentLevel

public int getRootIndentLevel()
Returns the indent level for all root SchemaComponents relative to the left margin of the page. The root indent level is the number of indent characters an entire schema component definition will be indented from the 1st column on the page. An indent character is either a space or a tab. The character used is determined by rootIndentUsesSpaces(). For example, if indentUsesSpaces() returns true and the rootIndentLevel is set to 4, then 4 spaces will be output before each line in the schema component, thereby indenting the entire component 4 spaces. If indentUsesSpaces() returns false and the rootIndentLevel is set to 4 then 4 tabs will be output before each line in the component, thereby indenting the entire component by 4 tabs. Most common conventions set the rootIndentLevel to 2 or 4 when using spaces and 1 when using tabs.

Returns:
Returns the rootIndentLevel.

setRootIndentLevel

public void setRootIndentLevel(int rootIndentLevel)
Sets the root indent level for all SchemaComponents relative to the left margin of the page. Any values of rootIndentLevel less than zero are ignored.

Parameters:
rootIndentLevel - The table indent level to set.
See Also:
getRootIndentLevel()

isSpaceUsedForIndents

public boolean isSpaceUsedForIndents()
Returns true if the space character is to be used as the indent character in the document, false if a tab is to be used.

Returns:
Returns the spaceUsedForIndents value.

setIndentString

public void setIndentString(String indentString)

getIndentString

public String getIndentString()

isTableOpenParenOnSameLine

public boolean isTableOpenParenOnSameLine()
Returns true if, when creating a new table, the table's open parenthesis is to be on the same line as the table name and table modifiers. Returns false if the table's opening parenthesis is to be on a new line directly under the start of the table declaration. This is provided purely to satisfy personal preferences.

Returns:
Returns the tableOpenParenOnNewLine.

setTableOpenParenOnSameLine

public void setTableOpenParenOnSameLine(boolean tableOpenParenOnSameLine)
Sets whether or not a table definition's opening parenthesis will exist on the same line as the table declaration or not.

Parameters:
tableOpenParenOnSameLine - The boolean value to set.

getTableComponentIndentLevel

public int getTableComponentIndentLevel()
Returns the column indent level for a column relative to the left margin of its parent table.

Returns:
Returns the column indent level for a column relative to the left margin of its parent table.

setTableComponentIndentLevel

public void setTableComponentIndentLevel(int tableComponentIndentLevel)
Sets the indent level for a table component relative to the left margin of its parent table. For example, if tableComponentIndentLevel is set to 4, and getTableIndentLevel() equals 4, and isSpaceUsedForIndents() is true, then the table component will be printed starting on the 8th column. Any values for tableComponentIndentLevel less than zero will be ignored.

Parameters:
tableComponentIndentLevel - The tableComponentIndentLevel to set.

isColumnMetadataJustified

public boolean isColumnMetadataJustified()

Returns whether or not column metadata for column definitions will be justified flush with all other column metadata in a table.

For example:

Metadata Justified:

     column_name          char(36),
     another_column_name  integer not null,
     some_other_column    varchar(100) not null unique,
     ...
 

Metadata Not Justified:

     column_name char(36),
     another_column_name integer not null,
     some_other_column varchar(100) not null unique,
     ...
 

Although purely a personal preference, metadata justification almost always makes column definitions easier to read.

Returns:
Returns the columnMetadataJustified.

setColumnMetadataJustified

public void setColumnMetadataJustified(boolean columnMetadataJustified)
Sets whether or not column metadata is to be justfied when printed out.

Parameters:
columnMetadataJustified - The boolean to set.
See Also:
isColumnMetadataJustified()

getLineSeparator

public String getLineSeparator()

setLineSeparator

public void setLineSeparator(String lineSeparator)

getLinesBetweenRootDefinitions

public int getLinesBetweenRootDefinitions()
Returns the number of new lines inserted between root-level SQL component definitions such as tables, indicies, views, etc.

Returns:
Returns the number of new lines inserted between SQL component definitions.

setLinesBetweenRootDefinitions

public void setLinesBetweenRootDefinitions(int linesBetweenRootDefinitions)
Sets the number of new lines to be inserted between root-level SQL component definitions such as tables, indices, views, etc. Any value of linesBetweenRootDefinitions less than zero will be ignored.

Parameters:
linesBetweenRootDefinitions - The number to set.

getLinesBetweenTableComponents

public int getLinesBetweenTableComponents()
Returns:
Returns the linesBetweenTableComponents.

setLinesBetweenTableComponents

public void setLinesBetweenTableComponents(int linesBetweenTableComponents)
Parameters:
linesBetweenTableComponents - The linesBetweenTableComponents to set.

setDialect

public void setDialect(Dialect dialect)

getDialect

public Dialect getDialect()

getIndentLevel

public int getIndentLevel()

setIndentLevel

public void setIndentLevel(int indentLevel)

incrementIndent

public void incrementIndent()

decrementIndent

public void decrementIndent()

indent

public final void indent(Writer out)

indent

public final void indent(Writer out,
                         int num)

write

public final void write(Writer out,
                        String toWrite)

writeln

public final void writeln(Writer out,
                          String toWrite)

writeln

public final void writeln(Writer out)