|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.jdesktop.dataset.DataSet
public class DataSet
A DataSet is the top-level class for managing multiple DataTable
s as a
group, allowing explicit support for master-detail relationships. A DataSet
contains one or more DataTables, one or more DataRelation
s, and one or more
DataValue
s. Through the DataSet API one has a sort of unified access to all
these elements in a single group. As a canonical example, a single DataSet could
have DataTables for Customers, Orders, and OrderItems, and the relationships
between them.
The DataSet internal structure read from a DataSet XML
schema using the createFromSchema(String)
method, which also supports
reading from an InputStream
or File
. The internal structure
can then be persisted back as an XML schema by retrieving its String form
using getSchema()
and then saving that.
Separately, all the data in a DataSet (e.g. rows in the internal DataTables)
can be read (readXml(String)
) or written (writeXml()
).
DataSet has standard methods for adding or removing single DataTables, DataRelationTables, and DataValues. Note that these instances are automatically tracked, so if their names are changed through their own API, that name change is reflected automatically in the DataSet.
DataTable
,
DataRelationTable
,
DataValue
,
DataRelation
Nested Class Summary | |
---|---|
static class |
DataSet.OutputControl
Flag used for writeXml(OutputControl) to indicate whether
all rows, or just modified rows should be spit out. |
Field Summary | |
---|---|
protected static java.lang.String |
DEFAULT_NAME_PREFIX
Prefix used by the name generator for automatically-generated DataSet names. |
Constructor Summary | |
---|---|
DataSet()
Instantiates a DataSet with an automatically-generated name. |
|
DataSet(java.lang.String name)
Instantiates a DataSet with a specific name; the name can be useful when persisting the DataSet or when working with multiple DataSets. |
Method Summary | |
---|---|
void |
clear()
Requests that each DataTable in this DataSet clear itself; this is
a synchronous operation since the clear operation is not anticipated to
take more than a couple of milliseconds at worst. |
static DataSet |
createFromSchema(java.io.File f)
Deprecated. Replaced by DataSetUtility.readDataSetFromXml(Reader, String[]) |
static DataSet |
createFromSchema(java.io.InputStream is)
Deprecated. Replaced by DataSetUtility.readDataSetFromXml(Reader, String[]) |
static DataSet |
createFromSchema(java.lang.String schema)
Deprecated. use DataSetUtils.createFromXmlSchema instead |
DataRelation |
createRelation()
Creates a new DataRelation with an automatically-generated name, and adds it to this DataSet; the table will belong to this DataSet. |
DataRelation |
createRelation(java.lang.String name)
Creates a new, named DataRelation, and adds it to this DataSet; the table will belong to this DataSet. |
DataRelationTable |
createRelationTable()
Creates a new DataRelationTable with an automatically-generated name, and adds it to this DataSet; the table will belong to this DataSet. |
DataRelationTable |
createRelationTable(java.lang.String name)
Creates a new, named DataRelationTable, and adds it to this DataSet; the table will belong to this DataSet. |
DataTable |
createTable()
Creates a new DataTable with an automatically-generated name, and adds it to this DataSet; the table will belong to this DataSet. |
DataTable |
createTable(java.lang.String name)
Creates a new, named DataTable, and adds it to this DataSet; the table will belong to this DataSet. |
DataValue |
createValue()
Creates a new DataValue with an automatically-generated name, and adds it to this DataSet; the table will belong to this DataSet. |
DataValue |
createValue(java.lang.String name)
Creates a new, named DataValue, and adds it to this DataSet; the table will belong to this DataSet. |
void |
dropRelation(DataRelation relation)
Removes a given DataRelation from this DataSet. |
void |
dropRelation(java.lang.String relationName)
Removes a given DataRelation from this DataSet. |
void |
dropRelationTable(DataRelationTable table)
Removes a given DataRelationTable from this DataSet. |
void |
dropRelationTable(java.lang.String tableName)
Removes a given DataRelationTable from this DataSet. |
void |
dropTable(DataTable table)
Removes a given DataTable from this DataSet. |
void |
dropTable(java.lang.String tableName)
Removes a given DataTable from this DataSet. |
void |
dropValue(DataValue value)
Removes a given DataValue from this DataSet. |
void |
dropValue(java.lang.String valueName)
Removes a given DataValue from this DataSet. |
java.util.List<DataRow> |
filterRows(java.util.List<DataRow> rows,
DataSelector ds)
Returns a list of rows that match a given selector; convenience method. |
java.util.List<DataColumn> |
getColumns(java.lang.String path)
|
java.lang.Object |
getElement(java.lang.String path)
Given some path, return the proper element. |
java.lang.String |
getName()
Returns the current name for the DataSet. |
DataRelation |
getRelation(java.lang.String relationName)
Looks up a DataRelation in this set by name. |
java.util.List<DataRelation> |
getRelations()
Retrieves a list of all DataRelation in this set. |
DataRelationTable |
getRelationTable(java.lang.String name)
Looks up a DataRelationTable in this DataSet, by name. |
java.util.List<DataRow> |
getRows(java.lang.String path)
TODO |
java.lang.String |
getSchema()
Deprecated. Replaced by DataSetUtility.writeDataSetAsXml(Writer, DataSet) |
DataTable |
getTable(java.lang.String tableName)
Looks up a DataTable in this DataSet, by name. |
java.util.List<DataTable> |
getTables()
Returns a List of the DataTables in this DataSet. |
DataValue |
getValue(java.lang.String valueName)
Looks up a DataValue in this set by name. |
java.util.List<DataValue> |
getValues()
Retrieves a list of all DataValues in this set. |
protected boolean |
hasElement(java.lang.String name)
Checks whether this DataSet has a relation, table or value by the given name. |
void |
load()
Requests that each DataTable in this DataSet load itself; this is
an asynchronous operation. |
void |
loadAndWait()
Requests that each DataTable in this DataSet load itself; this is
a synchronous operation. |
static void |
main(java.lang.String[] args)
Test function from command line; no arguments needed |
void |
readXml(java.io.File f)
Same as readXml(String) , but using a File as input source. |
void |
readXml(java.io.InputStream is)
Same as readXml(String) , but using an InputStream as input source. |
void |
readXml(java.lang.String xml)
Loads DataSet data from an XML Document in String format; when complete, the DataSet will have been populated from the Document. |
void |
refresh()
Requests that each DataTable in this DataSet refresh itself; this is
an asynchronous operation. |
void |
refreshAndWait()
Requests that each DataTable in this DataSet refresh itself; this is
a synchronous operation. |
void |
save()
Requests that each DataTable in this DataSet save itself; this is
an asynchronous operation. |
void |
saveAndWait()
Requests that each DataTable in this DataSet save itself; this is
a synchronous operation. |
void |
setName(java.lang.String name)
Assigns a new name to this DataSet. |
java.lang.String |
toString()
|
java.lang.String |
writeXml()
Writes out the data in this DataSet as XML, and returns this as a String; all rows are exported. |
java.lang.String |
writeXml(DataSet.OutputControl flags)
Writes out the data in this DataSet as XML, and returns this as a String. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
protected static final java.lang.String DEFAULT_NAME_PREFIX
Constructor Detail |
---|
public DataSet()
public DataSet(java.lang.String name)
setName(String)
for comments about DataSet naming.
name
- The name for the DataSet.Method Detail |
---|
public void setName(java.lang.String name)
DataSetUtils.isValidName(String)
..
name
- The new name for the DataSet.public java.lang.String getName()
public DataTable createTable()
public DataTable createTable(java.lang.String name)
name
- The new DataTable's name.
public DataRelationTable createRelationTable()
public DataRelationTable createRelationTable(java.lang.String name)
name
- The new DataRelationTable's name.
public DataRelation createRelation()
public DataRelation createRelation(java.lang.String name)
name
- The new DataRelation's name.
public DataValue createValue()
public DataValue createValue(java.lang.String name)
name
- The new DataValue's name.
public void dropTable(DataTable table)
table
- The DataTable instance to remove.public void dropTable(java.lang.String tableName)
tableName
- The name of the table to remove.public void dropRelationTable(DataRelationTable table)
table
- The DataRelationTable instance to remove.public void dropRelationTable(java.lang.String tableName)
tableName
- The name of the table to remove.public void dropRelation(DataRelation relation)
relation
- The DataRelation instance to remove.public void dropRelation(java.lang.String relationName)
relationName
- The name of the relation to remove.public void dropValue(DataValue value)
value
- The DataValue instance to remove.public void dropValue(java.lang.String valueName)
valueName
- The name of the value to remove.protected boolean hasElement(java.lang.String name)
name
- The name to lookup.
public java.lang.Object getElement(java.lang.String path)
path
- The identifier for the element in question; see desc.
public java.util.List<DataRow> getRows(java.lang.String path)
public java.util.List<DataRow> filterRows(java.util.List<DataRow> rows, DataSelector ds)
rows
- The rows to select from.ds
- The DataSelector with indices to filter with.
public java.util.List<DataColumn> getColumns(java.lang.String path)
public DataTable getTable(java.lang.String tableName)
tableName
- The name of the table to retrieve.
public java.util.List<DataTable> getTables()
public DataRelationTable getRelationTable(java.lang.String name)
name
- The name of the relation table to retrieve.
public DataValue getValue(java.lang.String valueName)
valueName
- The name of the DataValue.
public java.util.List<DataValue> getValues()
public DataRelation getRelation(java.lang.String relationName)
relationName
- The name of the DataRelation.
public java.util.List<DataRelation> getRelations()
public void load()
DataTable
in this DataSet load itself; this is
an asynchronous operation. See DataTable.load()
; tables must have
been assigned a DataProvider
already.
public void loadAndWait()
DataTable
in this DataSet load itself; this is
a synchronous operation. See DataTable.loadAndWait()
; tables must have
been assigned a DataProvider
already.
public void refresh()
DataTable
in this DataSet refresh itself; this is
an asynchronous operation. See DataTable.refresh()
; tables must have
been assigned a DataProvider
already.
public void refreshAndWait()
DataTable
in this DataSet refresh itself; this is
a synchronous operation. See DataTable.refreshAndWait()
; tables must have
been assigned a DataProvider
already.
public void clear()
DataTable
in this DataSet clear itself; this is
a synchronous operation since the clear operation is not anticipated to
take more than a couple of milliseconds at worst.
See DataTable.clear()
;
public void save()
DataTable
in this DataSet save itself; this is
an asynchronous operation. See DataTable.save()
; tables must have
been assigned a DataProvider
already.
public void saveAndWait()
DataTable
in this DataSet save itself; this is
a synchronous operation. See DataTable.saveAndWait()
; tables must have
been assigned a DataProvider
already.
public static DataSet createFromSchema(java.lang.String schema)
public java.lang.String getSchema()
DataSetUtility.writeDataSetAsXml(Writer, DataSet)
public static DataSet createFromSchema(java.io.File f) throws java.io.FileNotFoundException
DataSetUtility.readDataSetFromXml(Reader, String[])
createFromSchema(String)
, but using a File as input source.
f
- The File to read from.
java.io.FileNotFoundException
public static DataSet createFromSchema(java.io.InputStream is)
DataSetUtility.readDataSetFromXml(Reader, String[])
createFromSchema(String)
, but using a InputStream as input source.
is
- The InputStream to read from.
public void readXml(java.io.File f)
readXml(String)
, but using a File as input source.
f
- The XML Document, as a File.public void readXml(java.io.InputStream is)
readXml(String)
, but using an InputStream as input source.
is
- The XML Document, as an InputStream.public void readXml(java.lang.String xml)
xml
- The XML Document, as a String.public java.lang.String writeXml()
public java.lang.String writeXml(DataSet.OutputControl flags)
flags
- Value indicating whether all rows (OutputControl.ALL_ROWS)
or only new and modified rows should be spit out.
public java.lang.String toString()
toString
in class java.lang.Object
public static void main(java.lang.String[] args)
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |