com.groupdocs.assembly.system.data

Class DataSet

  • java.lang.Object
    • com.groupdocs.assembly.system.data.DataSet


  • public class DataSet
    extends java.lang.Object
    Represents an in-memory cache of data.
    • Constructor Summary

      Constructors 
      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.
    • Constructor Detail

      • DataSet

        public DataSet()
        Initializes a new instance of the DataSet class.
      • DataSet

        public DataSet(java.sql.Connection connection)
                throws java.lang.Exception
        Initializes a new instance of the DataSet class with data taken from Connection. Tables, Relations, Constraints and Indexes will be copied into DataSet.

        By default no schema name will be used.

        Parameters:
        connection - which contains DB data.
        Throws:
        java.lang.Exception - if any errors occur while copying data from Connection.
      • DataSet

        public DataSet(java.sql.Connection connection,
                       java.lang.String schemaName)
                throws java.lang.Exception
        Initializes a new instance of the DataSet class with data taken from Connection. Tables, Relations, Constraints and Indexes will be copied into DataSet.

        DataSet dataSet = new DataSet(conn, "PUBLIC"); // HSQLDB

        or

        DataSet dataSet = new DataSet(conn); // MYSQL's default schema name.

        Parameters:
        connection - which contains DB data.
        schemaName - which contains the tables to be imported.
        Throws:
        java.lang.Exception - if any errors occur while copying data from Connection.
      • DataSet

        public DataSet(java.lang.String dataSetName)
        Initializes a new instance of a DataSet class with the given name.
        Parameters:
        dataSetName - The name of the DataSet.
    • Method Detail

      • getDataSetName

        public java.lang.String getDataSetName()
        Gets the name of the current DataSet.
        Returns:
        The name of the DataSet.
      • setDataSetName

        public void setDataSetName(java.lang.String value)
        Sets the name of the current DataSet.
        Parameters:
        value - The name of the DataSet.
      • getNamespace

        public java.lang.String getNamespace()
        Gets the namespace of the DataSet.
        Returns:
        The namespace of the DataSet.
      • close

        public void close()
                   throws java.lang.Exception
        Throws:
        java.lang.Exception
      • clear

        public void clear()
        Clears the DataSet of any data by removing all rows in all tables.
      • reset

        public void reset()
        Resets the DataSet to its original state. Subclasses should override reset() to restore a DataSet to its original state.
      • readXml

        public XmlReadMode readXml(java.io.InputStream xmlStream,
                                   XmlReadMode mode)
                            throws DataException
        Reads XML schema and data into the DataSet using the specified InputStream and XmlReadMode.
        Parameters:
        xmlStream - The Stream from which to read.
        mode - One of the XmlReadMode values.
        Returns:
        The XmlReadMode used to read the data.
        Throws:
        DataException - if any errors occur while reading or adding data into table
      • readXml

        public XmlReadMode readXml(java.io.InputStream xmlStream)
                            throws DataException
        Reads XML schema and data into the DataSet using the specified 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.
        Parameters:
        xmlStream - data stream
        Returns:
        mode which was used while reading
        Throws:
        DataException - if any errors occur while reading or adding data into table
      • readXml

        public XmlReadMode readXml(java.lang.String fileName)
                            throws DataException
        Reads XML schema and data into the DataSet using the specified file.
        Parameters:
        fileName - The filename (including the path) from which to read.
        Returns:
        The XmlReadMode used to read the data. The returned value is one of XmlReadMode constants.
        Throws:
        DataException
      • readXml

        public XmlReadMode readXml(java.lang.String xmlPath,
                                   XmlReadMode readMode)
                            throws DataException
        Reads XML schema and data into the DataSet using the specified file and XmlReadMode.
        Parameters:
        xmlPath - the specified file
        readMode - XmlReadMode
        Returns:
        mode which was used while reading
        Throws:
        DataException - if any errors occur while reading or adding data into table
      • readXmlSchema

        public void readXmlSchema(java.io.InputStream xmlStream)
                           throws DataException
        Reads the XML schema from the specified Stream into the DataSet.
        Parameters:
        xmlStream - won't be closed after the schema has been read.
        Throws:
        DataException - if any errors occur while reading or adding data into table
      • readXmlSchema

        public void readXmlSchema(java.lang.String fileName)
                           throws DataException
        Reads the XML schema from the specified file into the DataSet.
        Parameters:
        fileName - The file name (including the path) from which to read.
        Throws:
        DataException
      • setLocale

        public void setLocale(java.util.Locale locale)
        Sets the locale information used to compare strings within the table.
        Parameters:
        locale - of this data set
      • isLocaleSpecified

        public boolean isLocaleSpecified()
        Returns:
        true if locale was set
      • getEnforceConstraints

        public boolean getEnforceConstraints()
        Gets a value indicating whether constraint rules are followed when attempting any update operation.
        Returns:
        true if rules are enforced; otherwise false. The default is true.
      • setEnforceConstraints

        public void setEnforceConstraints(boolean value)
        Sets a value indicating whether constraint rules are followed when attempting any update operation.
        Parameters:
        value - true if rules are enforced; otherwise false. The default is true.