|
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.erowid.sperowider.hsqldb.BasicTable org.erowid.sperowider.hsqldb.TwoWayMapTable
This is a wrapper around a many-to-many table. The first implementation is likely to be inefficient (no lookup tables, for example), but later versions will actually incorporate multiple tables for efficiency.
The map does have the idea of directionality so it distinguishes between the first and second elements in each mapping, but to keep the model generic, the first element is called "first" and the second "second" (as opposed to "from" and "to", or "parent" and "child"). Most methods on this class should therefore typically appear in triplicate ... once for "first", once for "second", and once that aggregates the two. ThereforecontainsFirst(String)
,
containsSecond(String)
, and contains(String)
.
Field Summary |
Fields inherited from class org.erowid.sperowider.hsqldb.BasicTable |
CACHED, MEMORY |
Constructor Summary | |
TwoWayMapTable(String name,
Connection connection,
int mode)
Constructor, gets everything ready for usage. |
Method Summary | |
void |
add(String firstValue,
String secondValue)
Adds a mapping from one value to another value to this map. |
boolean |
contains(String value)
Returns true if either column has this value. |
boolean |
containsFirst(String value)
Returns true if the first column has this value. |
boolean |
containsSecond(String value)
Returns true if the second column has this value. |
void |
create()
Creates a new table in the backing database corresponding to this object. |
String |
map(String value)
A weird outlier of a method, this provides the same functionality as MapTable.map(String) , allowing this to be used as a
simple map. |
List |
mapFirst(String value)
Returns the second values mapped to this first value. |
List |
mapSecond(String value)
Returns the first values mapped to this second value. |
void |
remove(String value)
Removes all mappings where the passed in value is either column |
void |
remove(String firstValue,
String secondValue)
Removes the mappings from the passed in first value to the passed in second value. |
void |
removeFirst(String value)
Removes all mappings where the passed in value is in the first column |
void |
removeSecond(String value)
Removes all mappings where the passed in value is in the second column |
Methods inherited from class org.erowid.sperowider.hsqldb.BasicTable |
execSQL, getConnection, getMode, getName, getTableCreatePrefix, prepareStatement, tableExists |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
public TwoWayMapTable(String name, Connection connection, int mode) throws SQLException
Method Detail |
public void create() throws SQLException
SQLException
public boolean containsFirst(String value)
public boolean containsSecond(String value)
public boolean contains(String value)
public void add(String firstValue, String secondValue)
public void removeFirst(String value)
public void removeSecond(String value)
public void remove(String value)
public void remove(String firstValue, String secondValue)
public String map(String value)
MapTable.map(String)
, allowing this to be used as a
simple map.
public List mapFirst(String value)
public List mapSecond(String value)
|
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |