public class DataSet
extends java.lang.Object
Constructor and Description |
---|
DataSet()
Initializes a new instance of the
DataSet class. |
DataSet(java.sql.Connection connection)
Initializes a new instance of the DataSet class with data taken from Connection.
|
DataSet(java.sql.Connection connection,
java.lang.String schemaName)
Initializes a new instance of the DataSet class with data taken from Connection.
|
DataSet(java.lang.String dataSetName)
Initializes a new instance of a
DataSet class with the given name. |
Modifier and Type | Method and Description |
---|---|
void |
clear()
Clears the
DataSet of any data by removing all rows in all tables. |
void |
close() |
java.lang.String |
getDataSetName()
Gets the name of the current
DataSet . |
boolean |
getEnforceConstraints()
Gets a value indicating whether constraint rules are followed when attempting any update operation.
|
java.lang.String |
getNamespace()
Gets the namespace of the
DataSet . |
DataRelationCollection |
getRelations()
Get the collection of relations that link tables and allow navigation from parent tables to child tables.
|
DataTableCollection |
getTables()
Gets the collection of tables contained in the
DataSet . |
boolean |
isLocaleSpecified() |
XmlReadMode |
readXml(java.io.InputStream xmlStream)
Reads XML schema and data into the DataSet using the specified
InputStream . |
XmlReadMode |
readXml(java.io.InputStream xmlStream,
XmlReadMode mode)
Reads XML schema and data into the DataSet using the specified
InputStream and XmlReadMode . |
XmlReadMode |
readXml(java.lang.String fileName)
Reads XML schema and data into the
DataSet using the specified file. |
XmlReadMode |
readXml(java.lang.String xmlPath,
XmlReadMode readMode)
Reads XML schema and data into the DataSet using the specified file and
XmlReadMode . |
void |
readXmlSchema(java.io.InputStream xmlStream)
Reads the XML schema from the specified Stream into the DataSet.
|
void |
readXmlSchema(java.lang.String fileName)
Reads the XML schema from the specified file into the
DataSet . |
void |
reset()
Resets the
DataSet to its original state. |
void |
setDataSetName(java.lang.String value)
Sets the name of the current
DataSet . |
void |
setEnforceConstraints(boolean value)
Sets a value indicating whether constraint rules are followed when attempting any update operation.
|
void |
setLocale(java.util.Locale locale)
Sets the locale information used to compare strings within the table.
|
public DataSet()
DataSet
class.public DataSet(java.sql.Connection connection) throws java.lang.Exception
By default no schema name will be used.
connection
- which contains DB data.java.lang.Exception
- if any errors occur while copying data from Connection.public DataSet(java.sql.Connection connection, java.lang.String schemaName) throws java.lang.Exception
DataSet dataSet = new DataSet(conn, "PUBLIC"); // HSQLDB
or
DataSet dataSet = new DataSet(conn); // MYSQL's default schema name.
connection
- which contains DB data.schemaName
- which contains the tables to be imported.java.lang.Exception
- if any errors occur while copying data from Connection.public java.lang.String getDataSetName()
DataSet
.DataSet
.public void setDataSetName(java.lang.String value)
DataSet
.value
- The name of the DataSet
.public java.lang.String getNamespace()
DataSet
.DataSet
.public DataTableCollection getTables()
DataSet
.DataTableCollection
contained by this DataSet
. An empty collection is returned if no DataTable
objects exist.public DataRelationCollection getRelations()
DataRelationCollection
that contains a collection of DataRelation
objects. An empty collection is returned if no DataRelation
objects exist.public void close() throws java.lang.Exception
java.lang.Exception
public void clear()
DataSet
of any data by removing all rows in all tables.public void reset()
public XmlReadMode readXml(java.io.InputStream xmlStream, XmlReadMode mode) throws DataException
InputStream
and XmlReadMode
.xmlStream
- The Stream from which to read.mode
- One of the XmlReadMode
values.DataException
- if any errors occur while reading or adding data into tablepublic XmlReadMode readXml(java.io.InputStream xmlStream) throws DataException
InputStream
.
The readXml(InputStream, XmlReadMode)
method provides a way to read either data only, or both data and schema into a DataSet from an XML document,
whereas the readXmlSchema(InputStream)
method reads only the schema.
To read both data and schema, use one of the readXML
overloads that includes the mode parameter, and set its value to ReadSchema.
If an in-line schema is specified, the in-line schema is used to extend the existing relational structure prior to loading the data.
If there are any conflicts (for example, the same column in the same table defined with different data types) an exception is raised.xmlStream
- data streamDataException
- if any errors occur while reading or adding data into tablepublic XmlReadMode readXml(java.lang.String fileName) throws DataException
DataSet
using the specified file.fileName
- The filename (including the path) from which to read.XmlReadMode
constants.DataException
public XmlReadMode readXml(java.lang.String xmlPath, XmlReadMode readMode) throws DataException
XmlReadMode
.xmlPath
- the specified filereadMode
- XmlReadMode
DataException
- if any errors occur while reading or adding data into tablepublic void readXmlSchema(java.io.InputStream xmlStream) throws DataException
xmlStream
- won't be closed after the schema has been read.DataException
- if any errors occur while reading or adding data into tablepublic void readXmlSchema(java.lang.String fileName) throws DataException
DataSet
.fileName
- The file name (including the path) from which to read.DataException
public void setLocale(java.util.Locale locale)
locale
- of this data setpublic boolean isLocaleSpecified()
public boolean getEnforceConstraints()
public void setEnforceConstraints(boolean value)
value
- true if rules are enforced; otherwise false. The default is true.