com.workingdogs.village
Class KeyDef

java.lang.Object
  |
  +--com.workingdogs.village.KeyDef

public class KeyDef
extends java.lang.Object

A KeyDef is a way to define the key columns in a table. The KeyDef is generally used in conjunction with a TableDataSet. Essentially a KeyDef is what forms the WHERE clause for an UPDATE or DELETE.

In order to use the KeyDef, you simply use it like this:

KeyDef kd = new KeyDef().addAttrib("key_column_a");
TableDataSet tds = new TableDataSet ( connection, "table", kd );
tds.fetchRecords();
Record rec = tds.getRecord(0);
rec.setValue("column_name", "new value" );
rec.save();
tds.close();
In the above example, Record 0 is retrieved from the database table and the following update statement is generated:

UPDATE table SET column_name=? WHERE key_column_a=?

Version:
$Revision: 1.5 $
Author:
Jon S. Stevens jon@latchkey.com

Field Summary
private  java.util.Vector mySelf
           
 
Constructor Summary
KeyDef()
          Constructor for KeyDef.
 
Method Summary
 KeyDef addAttrib(java.lang.String name)
          Adds the named attribute to the KeyDef.
 boolean containsAttrib(java.lang.String name)
          Determines if the KeyDef contains the requested Attribute.
 java.lang.String getAttrib(int pos)
          getAttrib is 1 based.
 int size()
          KeyDef's are 1 based, returns size - 1
 
Methods inherited from class java.lang.Object
, clone, equals, finalize, getClass, hashCode, notify, notifyAll, registerNatives, toString, wait, wait, wait
 

Field Detail

mySelf

private java.util.Vector mySelf
Constructor Detail

KeyDef

public KeyDef()
Constructor for KeyDef. Make sure to always initialize KeyDef with an initial element because it is 1 based.
Method Detail

addAttrib

public KeyDef addAttrib(java.lang.String name)
Adds the named attribute to the KeyDef.

containsAttrib

public boolean containsAttrib(java.lang.String name)
Determines if the KeyDef contains the requested Attribute.

getAttrib

public java.lang.String getAttrib(int pos)
getAttrib is 1 based. Setting pos to 0 will attempt to return pos 1.

size

public int size()
KeyDef's are 1 based, returns size - 1
See Also:
addAttrib(java.lang.String)


Copyright © 1999-2002 Share.Whichever.com All Rights Reserved.