|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.jdesktop.dataset.io.schema.XMLDataSetSchemaReader
public class XMLDataSetSchemaReader
An XMLDataSetSchemaReader
instantiates a DataSet
from
an XML Schema. Each instance of XMLDataSetSchemaReader
works against a single XML datasource,
e.g. an InputStream
; once instantiated against that InputStream, the reader
methods (e.g. readDataSet()
) may be used to load the DataSet
.
DataSetSchemaReader
classes do not load data, only the DataSet
schema.
Typical usage:
InputStream xmlIS = getClass().getResourceAsStream("resources/products.xsd");
XMLDataSetSchemaReader reader = new XMLDataSetSchemaReader(xmlIS);
DataSet dataSet = reader.readDataSet();
xmlIS.close();
You can also use the single-line utility method
DataSetUtility.readDataSetFromXml(InputStream, String[])
.
Constructor Summary | |
---|---|
XMLDataSetSchemaReader(java.io.InputStream xmlInputStream)
Instantiates a new XMLDataSetSchemaReader for an input stream holding a DataSet
schema in XML format. |
|
XMLDataSetSchemaReader(java.io.Reader xmlReader)
Instantiates a new XMLDataSetSchemaReader for an input stream holding a DataSet
schema in XML format. |
Method Summary | |
---|---|
java.util.List<java.lang.String> |
addRelations(DataSet dataSet,
java.lang.String... tableNames)
Adds all DataRelation for the named DataTable
to the specified DataSet , as read from the schema which this reader
is reading from. |
java.util.List<java.lang.String> |
addTables(DataSet dataSet,
java.lang.String... tableNames)
Appends one or more DataTable to a DataSet
from the schema represented by this reader. |
DataSet |
readDataSet()
Instantiates a new DataSet from the InputStream
specified in the constructor. |
DataSet |
readDataSet(java.lang.String... tableNames)
Instantiates a new DataSet from the InputStream specified in the
implementing class, with the DataSet schema loaded but without data, for the tables
and columns given in the tableNames parameter. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public XMLDataSetSchemaReader(java.io.InputStream xmlInputStream) throws SchemaReaderException
XMLDataSetSchemaReader
for an input stream holding a DataSet
schema in XML format. The input stream cannot be changed once the reader in instantiated,
and the caller is responsible for closing the stream once the schema is loaded. See class documentation for more details.
xmlInputStream
- A InputStream
holding DataSet
schema contents in XML format.
The stream must be readable, and the caller is responsible for closing the stream once
done.
SchemaReaderException
public XMLDataSetSchemaReader(java.io.Reader xmlReader) throws SchemaReaderException
XMLDataSetSchemaReader
for an input stream holding a DataSet
schema in XML format. The input stream cannot be changed once the reader in instantiated,
and the caller is responsible for closing the stream once the schema is loaded. See class documentation for more details.
xmlReader
- A InputStream
holding DataSet
schema contents in XML format.
The stream must be readable, and the caller is responsible for closing the stream once
done.
SchemaReaderException
Method Detail |
---|
public DataSet readDataSet() throws SchemaReaderException
DataSet
from the InputStream
specified in the constructor. If the schema contains multiple DataTables
or DataRelations
, all of them are loaded
from the schema into the new DataSet
.
readDataSet
in interface DataSetSchemaReader
DataSet
instantiated from the InputStream
specified for the implementing class, including all tables and relations in the schema.
ashktheman.dataset.io.SchemaReaderException
- If an error occurred while loading the schema.
SchemaReaderException
public DataSet readDataSet(java.lang.String... tableNames) throws SchemaReaderException
DataSet
from the InputStream
specified in the
implementing class, with the DataSet
schema loaded but without data, for the tables
and columns given in the tableNames
parameter.
readDataSet
in interface DataSetSchemaReader
tableNames
- One or more table names to load from the schema. Each name can be either a table, or a
table and column, dot-separated. If no columns are specified, all columns in the table are
read from the schema; if columns are listed, only those columns are loaded. DataRelations
for those tables and columns loaded from the schema are also instantiated automatically through
addRelations(org.jdesktop.dataset.DataSet, String[])
.
DataSet
instantiated from the InputStream
specified for the implementing class, including only the tables and columns listed in the
tableNames
parameter.
ashktheman.dataset.io.SchemaReaderException
- If an error occurred while loading the schema.
SchemaReaderException
public java.util.List<java.lang.String> addRelations(DataSet dataSet, java.lang.String... tableNames) throws SchemaReaderException
DataRelation
for the named DataTable
to the specified DataSet
, as read from the schema which this reader
is reading from. All DataRelations
for the table are dropped from the DataSet
and re-added.
addRelations
in interface DataSetSchemaReader
dataSet
- The DataSet
to which to add the relations.tableNames
- One or more table names for which to read relations from the schema. Only those relations
for columns in the DataTable (as currently loaded) are added.
List
of the DataRelation
names loaded from the schema.
org.jdesktop.dataset.io.SchemaReaderException
- If an error occurred while reading the schema.
SchemaReaderException
public java.util.List<java.lang.String> addTables(DataSet dataSet, java.lang.String... tableNames) throws SchemaReaderException
DataTable
to a DataSet
from the schema represented by this reader. If the table, by name, is found in the DataSet
,
the table is skipped; if you want to re-add a table (for example, to pick up changes in table structure),
drop the table from the DataSet
before calling this method.
addTables
in interface DataSetSchemaReader
dataSet
- The DataSet
to which to add the tables.tableNames
- One or more table names to load from the schema and add to the DataSet
.
Each name can be either a table, or a table and column, dot-separated.
If no columns are specified, all columns in the table are read from the schema;
if columns are listed, only those columns are loaded. DataRelations
for those tables and columns are not loaded from the schema; to that end, use
addRelations(DataSet, String...)
.
List
of the table names that were actually found. You can check this to
verify that all tables requested were loaded.
org.jdesktop.dataset.io.SchemaReaderException
- If an error occurred while reading the schema.
SchemaReaderException
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |