Package com.mckoi.database.interpret
Class ColumnChecker
- java.lang.Object
-
- com.mckoi.database.interpret.ColumnChecker
-
abstract class ColumnChecker extends java.lang.Object
A class that abstracts the checking of information in a table. This is abstracted because the behaviour is shared between ALTER and CREATE statement.
-
-
Constructor Summary
Constructors Constructor Description ColumnChecker()
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description (package private) void
checkColumnList(java.util.ArrayList list)
Checks all the columns in the list and throws an exception if any column names are not found in the columns in this create.(package private) void
checkExpression(Expression expression)
Resolves all the variables in the expression throwing a DatabaseException if any errors found.(package private) abstract java.lang.String
resolveColumnName(java.lang.String col_name)
Returns the resolved column name if the column exists within the table being checked under, or null if it doesn't.(package private) static ColumnChecker
standardColumnChecker(DatabaseConnection database, TableName tname)
Given a DatabaseConnection and a TableName object, this returns an implementation of ColumnChecker that is able to check that the column name exists in the table, and that the reference is not ambigious.(package private) static java.util.ArrayList
stripColumnList(java.lang.String table_domain, java.util.ArrayList column_list)
Calls the 'stripTableName' method on all elements in the given list.(package private) static java.lang.String
stripTableName(java.lang.String table_domain, java.lang.String column)
Given a column name string, this will strip off the preceeding table name if there is one specified.
-
-
-
Method Detail
-
stripTableName
static java.lang.String stripTableName(java.lang.String table_domain, java.lang.String column)
Given a column name string, this will strip off the preceeding table name if there is one specified. For example, 'Customer.id' would become 'id'. This also checks that the table specification is in the given table domain. For example, stripTableName("Customer", "Customer.id") would not throw an error but stripTableName("Order", "Customer.di") would.
-
stripColumnList
static java.util.ArrayList stripColumnList(java.lang.String table_domain, java.util.ArrayList column_list)
Calls the 'stripTableName' method on all elements in the given list.
-
resolveColumnName
abstract java.lang.String resolveColumnName(java.lang.String col_name) throws DatabaseException
Returns the resolved column name if the column exists within the table being checked under, or null if it doesn't. Throws an error if the column name is abiguous.- Throws:
DatabaseException
-
checkExpression
void checkExpression(Expression expression) throws DatabaseException
Resolves all the variables in the expression throwing a DatabaseException if any errors found. This checks that all variables point to a column in the table being created.- Throws:
DatabaseException
-
checkColumnList
void checkColumnList(java.util.ArrayList list) throws DatabaseException
Checks all the columns in the list and throws an exception if any column names are not found in the columns in this create. Additionally sets the entry with the correct column resolved to.- Throws:
DatabaseException
-
standardColumnChecker
static ColumnChecker standardColumnChecker(DatabaseConnection database, TableName tname)
Given a DatabaseConnection and a TableName object, this returns an implementation of ColumnChecker that is able to check that the column name exists in the table, and that the reference is not ambigious.
-
-