|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--com.perdues.db.Schema
This class defines information about one or more databases. A Schema contains information about one or more databases, their tables and fields. Beyond names and types, a Schema object contains information about which fields represent foreign keys and application-level type information about the fields. For example a field type can be a high-level type such as a phone number or an email, not just a varchar or integer.
Schemas work with the Form class to provide very easy and concise database operations: read, insert, update, delete, and very automated validation.
These Schema objects are in principle immutable except that the current database can be changed with the "use" or "useDB" method. This immutability is not enforced, however.
The type information for a column can indicate a Java type or a conceptual type such as "email", stored as a standard database type such as VARCHAR, but validated in a more specific way, and may have one or more specialized presentations as HTML forms.
Validation for application types and certain other operations are determined by DBTypeHandler classes. A Schema has a set of DBTypeHandlers, defined by addTypeHandler.
DBTypeHandler
Constructor Summary | |
Schema(Schema template)
The primary way to build a Schema is with Schema.configure, but you can build one similar to one that already exists with this constructor. |
Method Summary | |
void |
addDatabase(XMLTag tag)
Adds a database, defined by an XMLTag of type "db", to the set of databases described by this Schema. |
void |
addTypeHandler(java.lang.String type,
DBTypeHandler handler)
Adds a handler for a type. |
static Schema |
configure(java.lang.String resourceName)
Loads database definitions from a file or archive member, given its Java "resource name". |
java.util.Enumeration |
databases()
Enumerate all available databases. |
static void |
defTypeHandler(java.lang.String type,
DBTypeHandler handler)
Defines a global ("default") handler for a type. |
DBInfo |
get(java.lang.String databaseName)
Return a Database given its name. |
ColumnInfo |
getColumn(java.lang.String name)
Return a ColumnInfo given a qualified column name, from the default Database. |
DBInfo |
getDB()
Return the default Database. |
TableInfo |
getTable(java.lang.String name)
Get a table from the current database by name or shorthand, or errs if there is none. |
void |
useDB(java.lang.String databaseName)
Sets the current database. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
public Schema(Schema template)
Method Detail |
public static Schema configure(java.lang.String resourceName) throws java.io.IOException
Java resource names are like relative file paths, with "/" always the delimiter between path elements. The paths must be relative to some element of the CLASSPATH, and the first matching file is chosen. For example, if CLASSPATH is /home/myself/classes:/foo/classes, and the the resourceName is "db/config.xml", then the search will first look for a file named /home/myself/classes/db/config.xml, then /foo/classes/db/config.xml. If a CLASSPATH element is an archive file, the relative path indicates an archive member.
public TableInfo getTable(java.lang.String name)
public ColumnInfo getColumn(java.lang.String name)
public DBInfo getDB()
public void useDB(java.lang.String databaseName)
public java.util.Enumeration databases()
public DBInfo get(java.lang.String databaseName)
public void addDatabase(XMLTag tag)
public void addTypeHandler(java.lang.String type, DBTypeHandler handler)
public static void defTypeHandler(java.lang.String type, DBTypeHandler handler)
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |