org.prorefactor.core.schema
Class Schema

java.lang.Object
  extended by org.prorefactor.core.schema.Schema

public class Schema
extends java.lang.Object

Schema is a singleton with methods and fields for working with database schema names, and references to those from 4gl compile units.


Field Summary
static Database nullDatabase
           
static Table nullTable
           
 
Method Summary
 java.lang.String aliasCreate(java.lang.String aliasname, java.lang.String dbname)
          Add a database alias.
 void aliasDelete(java.lang.String aliasname)
          Delete a database alias.
 void clear()
           
 java.util.Iterator getAllTablesIterator()
          Get an iterator through all tables, sorted by db.table name.
 java.util.TreeSet<Database> getDbSet()
          Get databases sorted by name.
static Schema getInstance()
          Schema is a "Singleton"
 void loadSchema(java.lang.String from)
          Load schema names and RECID from a flat file.
 Database lookupDatabase(java.lang.String inName)
          Lookup Database, with alias checks.
 Field lookupField(java.lang.String dbName, java.lang.String tableName, java.lang.String fieldName)
          Lookup a Field, given the db, table, and field names
 Table lookupTable(java.lang.String inName)
          Lookup a table by name.
 Table lookupTable(java.lang.String dbName, java.lang.String tableName)
          Lookup a table, given a database name and a table name.
 Field lookupUnqualifiedField(java.lang.String name)
          Lookup an unqualified schema field name.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

nullDatabase

public static Database nullDatabase

nullTable

public static Table nullTable
Method Detail

getDbSet

public java.util.TreeSet<Database> getDbSet()
Get databases sorted by name.


getInstance

public static Schema getInstance()
Schema is a "Singleton"


clear

public void clear()

aliasCreate

public java.lang.String aliasCreate(java.lang.String aliasname,
                                    java.lang.String dbname)
Add a database alias.

Parameters:
aliasname - The name for the alias
dbname - The database's logical name
Returns:
Empty string.

aliasDelete

public void aliasDelete(java.lang.String aliasname)
Delete a database alias.

Parameters:
aliasname - The name for the alias, null or empty string to delete all.

getAllTablesIterator

public java.util.Iterator getAllTablesIterator()
Get an iterator through all tables, sorted by db.table name.


loadSchema

public void loadSchema(java.lang.String from)
                throws java.io.IOException
Load schema names and RECID from a flat file.

Parameters:
from - The filename to read from.
Throws:
java.io.IOException

lookupDatabase

public Database lookupDatabase(java.lang.String inName)
Lookup Database, with alias checks.


lookupField

public Field lookupField(java.lang.String dbName,
                         java.lang.String tableName,
                         java.lang.String fieldName)
Lookup a Field, given the db, table, and field names


lookupTable

public Table lookupTable(java.lang.String inName)
Lookup a table by name.

Parameters:
inName - The string table name to lookup.
Returns:
A Table, or null if not found. If a name like "db.table" fails on the first lookup try, we next search dictdb for the table, in case it's something like "sports._file". In that case, the Table from the "dictdb" database would be returned. We don't keep meta-schema records in the rest of the databases.

lookupTable

public Table lookupTable(java.lang.String dbName,
                         java.lang.String tableName)
Lookup a table, given a database name and a table name.


lookupUnqualifiedField

public Field lookupUnqualifiedField(java.lang.String name)
Lookup an unqualified schema field name. Does not test for uniqueness. That job is left to the compiler. (In fact, anywhere this is run, the compiler would check that the field name is also unique against temp/work tables.) Returns null if nothing found.



Copyright © 2008 Joanju Software. All Rights Reserved.