pl.kernelpanic.dbmonster.schema
Class SchemaUtil

java.lang.Object
  extended bypl.kernelpanic.dbmonster.schema.SchemaUtil

public final class SchemaUtil
extends Object

Utility to manipulate schema.

Version:
$Id: SchemaUtil.html,v 1.1 2007/06/21 08:38:14 sbahloul Exp $
Author:
Piotr Maj <piotr.maj@kernelpanic.pl>

Field Summary
static String COLUMN
          Column key.
static String CRLF
          System dependent line separator.
static String DATA_GENERATOR
          Data generator key.
static String DTD
          DTD identifier.
static String DTD_URL
          DTD url.
static String KEY
          Primary key key.
static String KEY_GENERATOR
          Key generator key.
static String PROJECT
          Project key.
static String SCHEMA_WRAPPER
          Schema key.
static String TABLE
          Table key.
 
Method Summary
static List getProperties(Object object)
          Returns object's properties.
static boolean isHidden(Object object, String name)
          Checks if property is public and not excluded.
static Schema loadSchema(InputStream is, Log log)
          Loads a schema from an input stream.
static Schema loadSchema(InputStream is, Log log, ClassLoader classloader)
           
static Schema loadSchema(String fileName, Log log)
          Loads a schema from a file.
static Schema loadSchema(String fileName, Log log, ClassLoader classloader)
           
static Schema loadSchema(URL url, Log log)
          Loads a schema from an url.
static void serializeColumn(Writer writer, Column column)
          Dumps a column to XML.
static void serializeGenerator(Writer writer, Object generator)
          Dumps a generator to XML.
static void serializeKey(Writer writer, Key key)
          Dumps a key to XML representation.
static void serializeSchema(Writer writer, Schema schema)
          Dumps the schema to XML file.
static void serializeTable(Writer writer, Table table)
          Dumps a table to XML representation.
static List validateColumn(Column column)
          Validates the column.
static List validateKey(Key key)
          Validates key.
static List validateSchema(Schema schema)
          Validate schema.
static List validateTable(Table table)
          Validates table.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DTD

public static final String DTD
DTD identifier.

See Also:
Constant Field Values

DTD_URL

public static final String DTD_URL
DTD url.

See Also:
Constant Field Values

PROJECT

public static final String PROJECT
Project key.

See Also:
Constant Field Values

SCHEMA_WRAPPER

public static final String SCHEMA_WRAPPER
Schema key.

See Also:
Constant Field Values

TABLE

public static final String TABLE
Table key.

See Also:
Constant Field Values

COLUMN

public static final String COLUMN
Column key.

See Also:
Constant Field Values

KEY

public static final String KEY
Primary key key.

See Also:
Constant Field Values

KEY_GENERATOR

public static final String KEY_GENERATOR
Key generator key.

See Also:
Constant Field Values

DATA_GENERATOR

public static final String DATA_GENERATOR
Data generator key.

See Also:
Constant Field Values

CRLF

public static final String CRLF
System dependent line separator.

Method Detail

loadSchema

public static final Schema loadSchema(String fileName,
                                      Log log)
                               throws Exception
Loads a schema from a file.

Parameters:
fileName - the name of the file which contains schema definition.
log - logger
Returns:
the schema
Throws:
Exception - if schema cannot be loaded.

loadSchema

public static final Schema loadSchema(String fileName,
                                      Log log,
                                      ClassLoader classloader)
                               throws Exception
Throws:
Exception

loadSchema

public static final Schema loadSchema(URL url,
                                      Log log)
                               throws Exception
Loads a schema from an url.

Parameters:
url - url
log - logger
Returns:
the schema
Throws:
Exception - on errors

loadSchema

public static final Schema loadSchema(InputStream is,
                                      Log log)
                               throws Exception
Loads a schema from an input stream.

Parameters:
is - input stream
log - logger
Returns:
the schema
Throws:
Exception - if schema cannot be loaded.

loadSchema

public static final Schema loadSchema(InputStream is,
                                      Log log,
                                      ClassLoader classloader)
                               throws Exception
Throws:
Exception

validateSchema

public static final List validateSchema(Schema schema)
Validate schema.

Parameters:
schema - schema to validate
Returns:
list of error messages or null if schema is ok

validateTable

public static final List validateTable(Table table)
Validates table.

Parameters:
table - table to validate
Returns:
list of error messages or null if table is OK.

validateKey

public static final List validateKey(Key key)
Validates key.

Parameters:
key - key to validate
Returns:
list of error messages or null is key is ok

validateColumn

public static final List validateColumn(Column column)
Validates the column.

Parameters:
column - column to validate
Returns:
list of error messages or null if column is ok

getProperties

public static final List getProperties(Object object)
Returns object's properties. A property is the one which has a public getter and setter and is not reserved DBMonster's property.

Parameters:
object - an schema element
Returns:
list of properties

isHidden

public static final boolean isHidden(Object object,
                                     String name)
Checks if property is public and not excluded.

Parameters:
object - an object to check
name - property name
Returns:
true if property is hidden

serializeSchema

public static final void serializeSchema(Writer writer,
                                         Schema schema)
                                  throws Exception
Dumps the schema to XML file.

Parameters:
writer - writer we are appending to
schema - schema to dump
Throws:
Exception - on errors

serializeTable

public static final void serializeTable(Writer writer,
                                        Table table)
                                 throws Exception
Dumps a table to XML representation.

Parameters:
writer - writer we are appengind to
table - table to serialize
Throws:
Exception - on errors

serializeKey

public static final void serializeKey(Writer writer,
                                      Key key)
                               throws Exception
Dumps a key to XML representation.

Parameters:
writer - writer we are appending to
key - key to dump
Throws:
Exception - on errors

serializeColumn

public static final void serializeColumn(Writer writer,
                                         Column column)
                                  throws Exception
Dumps a column to XML.

Parameters:
writer - writer we are appending to
column - column to dump
Throws:
Exception - on errors

serializeGenerator

public static final void serializeGenerator(Writer writer,
                                            Object generator)
                                     throws Exception
Dumps a generator to XML.

Parameters:
writer - writter we are appending to
generator - generator
Throws:
Exception - on errors


Copyright © 2003-2005 .:. kernelpanic.pl .:.. All Rights Reserved.