|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.holub.database.UnmodifiableTable
public class UnmodifiableTable
This decorator of the Table class just wraps another table,
but restricts access to methods that don't modify the table.
The following methods toss an
UnsupportedOperationException
when called:
public void insert( String[] columnNames, Object[] values ) public void insert( Object[] values ) public void update( Selector where ) public void delete( Selector where ) public void store ()Other methods delegate to the wrapped Table. All methods of the
Table
that are declared to return a
Table
actually return an
UnmodifiableTable
.
Refer to the Table
interface for method documentation.
This code may be used freely by yourself with the following restrictions:
|
Nested Class Summary |
---|
Nested classes/interfaces inherited from interface com.holub.database.Table |
---|
Table.Exporter, Table.Importer |
Field Summary |
---|
Fields inherited from interface com.holub.database.Table |
---|
ALL, THIS_LEVEL |
Constructor Summary | |
---|---|
UnmodifiableTable(Table wrapped)
|
Method Summary | |
---|---|
void |
begin()
begin a transaction |
Object |
clone()
Return an UnmodifieableTable that wraps a clone of the currently wrapped table. |
void |
commit(boolean all)
Commit a transaction. |
int |
delete(com.holub.database.Selector w)
Delete from the table all rows approved by the Selector. |
void |
export(Table.Exporter exporter)
Build a representation of the Table using the specified Exporter. |
Table |
extract()
Extract the wrapped table. |
int |
insert(Collection v)
A convenience overload of Table.insert(Object[]) |
int |
insert(Collection c,
Collection v)
A convenience overload of Table.insert(String[],Object[]) |
int |
insert(Object[] v)
In this version of insert, values must have as many elements as there are columns, and the values must be in the order specified when the Table was created. |
int |
insert(String[] c,
Object[] v)
Insert new values into the table corresponding to the specified column names. |
boolean |
isDirty()
Return true if this table has changed since it was created. |
String |
name()
Return the table name that was passed to the constructor (or read from the disk in the case of a table that was loaded from the disk.) |
void |
rename(String s)
Rename the table to the indicated name. |
void |
rollback(boolean all)
Roll back a transaction. |
Cursor |
rows()
Return an iterator across the rows of the current table. |
Table |
select(com.holub.database.Selector where)
A more efficient version of select(where, null, null); |
Table |
select(com.holub.database.Selector w,
Collection r)
Convenience method, translates Collection to String array, then calls String-array version. |
Table |
select(com.holub.database.Selector w,
Collection r,
Collection o)
A convenience method that translates Collections to arrays, then calls Table.select(Selector,String[],Table[]) ; |
Table |
select(com.holub.database.Selector where,
String[] requestedColumns)
A more efficient version of select(where, requestedColumns, null); |
Table |
select(com.holub.database.Selector w,
String[] r,
Table[] o)
Create an unmodifiable table that contains selected rows from the current table. |
String |
toString()
|
int |
update(com.holub.database.Selector w)
Update cells in the table. |
Methods inherited from class java.lang.Object |
---|
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Constructor Detail |
---|
public UnmodifiableTable(Table wrapped)
Method Detail |
---|
public Object clone() throws CloneNotSupportedException
clone
in interface Table
clone
in class Object
CloneNotSupportedException
public int insert(String[] c, Object[] v)
Table
values[i]
is put into the column specified
in columnNames[i]
. Columns that are not
specified are initialized to null
.
insert
in interface Table
public int insert(Object[] v)
Table
insert
in interface Table
public int insert(Collection c, Collection v)
Table
Table.insert(String[],Object[])
insert
in interface Table
public int insert(Collection v)
Table
Table.insert(Object[])
insert
in interface Table
public int update(com.holub.database.Selector w)
Table
Selector
object serves
as a visitor whose includeInSelect(...)
method
is called for each row in the table. The return value is ignored,
but the Selector can modify cells as it examines them. Its your
responsibility not to modify primary-key and other constant
fields.
update
in interface Table
public int delete(com.holub.database.Selector w)
Table
delete
in interface Table
public void begin()
Table
begin
in interface Table
public void commit(boolean all)
Table
commit
in interface Table
all
- if false, commit only the innermost transaction,
otherwise commit all transactions at all levels.Table.THIS_LEVEL
,
Table.ALL
public void rollback(boolean all)
Table
rollback
in interface Table
all
- if false, commit only the innermost transaction,
otherwise commit all transactions at all levels.Table.THIS_LEVEL
,
Table.ALL
public Table select(com.holub.database.Selector w, String[] r, Table[] o)
Table
Selector
argument
specifies a strategy object that determines which
rows will be included in the result.
Table
.
If the other
argument is present, this methods
"joins" all rows
from the current table and the other
table and
then selects rows from the "join."
If the two tables contain identically named columns, then
only the column from the current table is included in the
result.
Joins are performed by creating the Cartesian product of the current and "other" tables, using the Selector to determine which rows of the product to include in the returned Table. For example, If one table contains:
a b c dand the
other
table contains
e f g hthen the Cartesian product is the table
a b e f a b g h c d e f c d g hIn the case of a join, the selector is presented with rows from this product.
The Table
returned from Table.select(com.holub.database.Selector, java.lang.String[], com.holub.database.Table[])
cannot be modified by you. The methods Table
methods that normally modify the
table (insert, update, delete, store) throw an
UnsupportedOperationException
if call them.
select
in interface Table
w
- a selector that determines which rows to include
in the result.
Use Selector.ALL
to include all rows.r
- columns to include in the result.
null for all columns.o
- Other tables to join to this one. At most
three other tables may be specified.
This argument must be null if you're not doing a join.
other
table
that were accepted by the Selector
.public Table select(com.holub.database.Selector where, String[] requestedColumns)
Table
select(where, requestedColumns, null);
select
in interface Table
public Table select(com.holub.database.Selector where)
Table
select(where, null, null);
select
in interface Table
public Table select(com.holub.database.Selector w, Collection r, Collection o)
Table
Table.select(Selector,String[],Table[])
;
select
in interface Table
r
- a collection of String objects
representing the desired columns.o
- a collection of additional Table objects to join to
the current one for the purposes of this SELECT
operation.public Table select(com.holub.database.Selector w, Collection r)
Table
select
in interface Table
public Cursor rows()
Table
rows
in interface Table
public void export(Table.Exporter exporter) throws IOException
Table
Table.Importer
using the constructor with an
Table.Importer
argument. The table's
"dirty" status is cleared (set false) on an export.
export
in interface Table
IOException
Table.isDirty()
public String toString()
toString
in class Object
public String name()
Table
name
in interface Table
public void rename(String s)
Table
select(...)
or one of its variants.
rename
in interface Table
public boolean isDirty()
Table
isDirty
in interface Table
public Table extract()
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |