org.apache.ddlutils.io
Class DatabaseIO

java.lang.Object
  extended byorg.apache.ddlutils.io.DatabaseIO

public class DatabaseIO
extends Object

This class provides functions to read and write database models from/to XML.

Version:
$Revision: 365443 $
Author:
James Strachan, Matthew Hawthorne, Thomas Dudziak

Constructor Summary
DatabaseIO()
           
 
Method Summary
protected  BeanReader getReader()
          Returns a new bean reader configured to read database models.
protected  BeanWriter getWriter(Writer output)
          Returns a new bean writer configured to writer database models.
 boolean isUseInternalDtd()
          Returns whether the internal dtd that comes with DdlUtils is used.
 boolean isValidateXml()
          Returns whether XML is validated upon reading it.
 Database read(File file)
          Reads the database model contained in the specified file.
 Database read(Reader reader)
          Reads the database model given by the reader.
 Database read(String filename)
          Reads the database model contained in the specified file.
 void setUseInternalDtd(boolean useInternalDtd)
          Specifies whether the internal dtd is to be used.
 void setValidateXml(boolean validateXml)
          Specifies whether XML shall be validated upon reading it.
 void write(Database model, OutputStream output)
          Writes the database model to the given output stream.
 void write(Database model, String filename)
          Writes the database model to the specified file.
 void write(Database model, Writer output)
          Writes the database model to the given output writer.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DatabaseIO

public DatabaseIO()
Method Detail

isValidateXml

public boolean isValidateXml()
Returns whether XML is validated upon reading it.

Returns:
true if read XML is validated

setValidateXml

public void setValidateXml(boolean validateXml)
Specifies whether XML shall be validated upon reading it.

Parameters:
validateXml - true if read XML shall be validated

isUseInternalDtd

public boolean isUseInternalDtd()
Returns whether the internal dtd that comes with DdlUtils is used.

Returns:
true if parsing uses the internal dtd

setUseInternalDtd

public void setUseInternalDtd(boolean useInternalDtd)
Specifies whether the internal dtd is to be used.

Parameters:
useInternalDtd - Whether to use the internal dtd

getReader

protected BeanReader getReader()
                        throws IntrospectionException,
                               SAXException,
                               IOException
Returns a new bean reader configured to read database models.

Returns:
The reader
Throws:
IntrospectionException
SAXException
IOException

getWriter

protected BeanWriter getWriter(Writer output)
                        throws IntrospectionException,
                               SAXException,
                               IOException
Returns a new bean writer configured to writer database models.

Parameters:
output - The target output writer
Returns:
The writer
Throws:
IntrospectionException
SAXException
IOException

read

public Database read(String filename)
              throws DdlUtilsException
Reads the database model contained in the specified file.

Parameters:
filename - The model file name
Returns:
The database model
Throws:
DdlUtilsException

read

public Database read(File file)
              throws DdlUtilsException
Reads the database model contained in the specified file.

Parameters:
file - The model file
Returns:
The database model
Throws:
DdlUtilsException

read

public Database read(Reader reader)
              throws DdlUtilsException
Reads the database model given by the reader.

Parameters:
reader - The reader that returns the model XML
Returns:
The database model
Throws:
DdlUtilsException

write

public void write(Database model,
                  String filename)
           throws DdlUtilsException
Writes the database model to the specified file.

Parameters:
model - The database model
filename - The model file name
Throws:
DdlUtilsException

write

public void write(Database model,
                  OutputStream output)
           throws DdlUtilsException
Writes the database model to the given output stream. Note that this method does not flush the stream.

Parameters:
model - The database model
output - The output stream
Throws:
DdlUtilsException

write

public void write(Database model,
                  Writer output)
           throws DdlUtilsException
Writes the database model to the given output writer. Note that this method does not flush the writer.

Parameters:
model - The database model
output - The output writer
Throws:
DdlUtilsException


Copyright © 2005 Apache Software Foundation. All Rights Reserved.